Documentation ¶
Overview ¶
Package catalog/service implements storage backend, RESTful API handlers, and a client SDK for service catalog implementation.
Index ¶
- Constants
- func ErrorMsg(res *http.Response) string
- func ErrorResponse(w http.ResponseWriter, code int, msgs ...string)
- func RegisterService(client CatalogClient, s *Service) error
- func RegisterServiceWithKeepalive(endpoint string, discover bool, s Service, sigCh <-chan bool, ...)
- type BadRequestError
- type CatalogAPI
- func (a *CatalogAPI) Delete(w http.ResponseWriter, req *http.Request)
- func (a *CatalogAPI) Filter(w http.ResponseWriter, req *http.Request)
- func (a *CatalogAPI) Get(w http.ResponseWriter, req *http.Request)
- func (a *CatalogAPI) List(w http.ResponseWriter, req *http.Request)
- func (a *CatalogAPI) Post(w http.ResponseWriter, req *http.Request)
- func (a *CatalogAPI) Put(w http.ResponseWriter, req *http.Request)
- type CatalogClient
- type CatalogController
- type CatalogStorage
- type Collection
- type ConflictError
- type Controller
- type Error
- type GCPublisher
- type JSONLDService
- type LevelDBStorage
- type Listener
- type Map
- type MemoryStorage
- type NotFoundError
- type Protocol
- type RemoteCatalogClient
- func (c *RemoteCatalogClient) Add(s *Service) (string, error)
- func (c *RemoteCatalogClient) Delete(id string) error
- func (c *RemoteCatalogClient) Filter(path, op, value string, page, perPage int) ([]Service, int, error)
- func (c *RemoteCatalogClient) Get(id string) (*Service, error)
- func (c *RemoteCatalogClient) List(page, perPage int) ([]Service, int, error)
- func (c *RemoteCatalogClient) Update(id string, s *Service) error
- type Service
- type ServiceConfig
- type TunneledService
Constants ¶
const ( DNSSDServiceType = "_linksmart-sc._tcp" MaxPerPage = 100 ApiVersion = "1.0.0" ApiCollectionType = "ServiceCatalog" ApiRegistrationType = "Service" // MetaKeyGCExpose is the meta key indicating // that the service needs to be tunneled in GC MetaKeyGCExpose = "gc_expose" )
const ( // HTTPBackboneName is the fully qualified java class name for HTTP backbone used in LS GC HTTPBackboneName = "eu.linksmart.gc.network.backbone.protocol.http.HttpImpl" // ProtocolTypeREST used in LC Service registration for Web/HTTP services ProtocolTypeREST = "REST" // RESTEndpointURL is the key in Protocol.Endpoint describing the endpoint of an Web/HTTP service RESTEndpointURL = "url" // ServiceAttributeRegistration is the attribute key for TunneledService storing the (modified) Service object ServiceAttributeRegistration = "SC" // ServiceAttributeID is the attribute key for TunneledService storing the Service ID ServiceAttributeID = "SID" // ServiceAttributeDescription is the attribute key for TunneledService storing the Service description ServiceAttributeDescription = "DESCRIPTION" )
const (
CtxPath = "/ctx/sc.jsonld"
)
Variables ¶
This section is empty.
Functions ¶
func ErrorResponse ¶
func ErrorResponse(w http.ResponseWriter, code int, msgs ...string)
ErrorResponse writes error to HTTP ResponseWriter
func RegisterService ¶
func RegisterService(client CatalogClient, s *Service) error
Registers service given a configured Catalog Client
func RegisterServiceWithKeepalive ¶
func RegisterServiceWithKeepalive(endpoint string, discover bool, s Service, sigCh <-chan bool, wg *sync.WaitGroup, ticket *obtainer.Client)
Registers service in the remote catalog endpoint: catalog endpoint. If empty - will be discovered using DNS-SD s: service registration sigCh: channel for shutdown signalisation from upstream ticket: set to nil for no auth
Types ¶
type BadRequestError ¶
type BadRequestError struct {
// contains filtered or unexported fields
}
Bad Request
func (*BadRequestError) Error ¶
func (e *BadRequestError) Error() string
type CatalogAPI ¶
type CatalogAPI struct {
// contains filtered or unexported fields
}
Read-only catalog api
func NewCatalogAPI ¶
func NewCatalogAPI(controller CatalogController, apiLocation, staticLocation, description string) *CatalogAPI
func (*CatalogAPI) Delete ¶
func (a *CatalogAPI) Delete(w http.ResponseWriter, req *http.Request)
Deletes a service
func (*CatalogAPI) Filter ¶
func (a *CatalogAPI) Filter(w http.ResponseWriter, req *http.Request)
Filters services
func (*CatalogAPI) Get ¶
func (a *CatalogAPI) Get(w http.ResponseWriter, req *http.Request)
Retrieves a service
func (*CatalogAPI) List ¶
func (a *CatalogAPI) List(w http.ResponseWriter, req *http.Request)
API Index: Lists services
func (*CatalogAPI) Post ¶
func (a *CatalogAPI) Post(w http.ResponseWriter, req *http.Request)
Adds a service
func (*CatalogAPI) Put ¶
func (a *CatalogAPI) Put(w http.ResponseWriter, req *http.Request)
Updates an existing service (Response: StatusOK) or creates a new one with the given id (Response: StatusCreated)
type CatalogClient ¶
type CatalogClient interface { // CRUD Get(id string) (*Service, error) Add(s *Service) (string, error) Update(id string, s *Service) error Delete(id string) error // Returns a slice of Services given: // page - page in the collection // perPage - number of entries per page List(page, perPage int) ([]Service, int, error) // Returns a slice of Services given: path, operation, value, page, perPage Filter(path, op, value string, page, perPage int) ([]Service, int, error) }
Catalog client
func NewRemoteCatalogClient ¶
func NewRemoteCatalogClient(serverEndpoint string, ticket *obtainer.Client) (CatalogClient, error)
type CatalogController ¶
type CatalogController interface { Stop() error // contains filtered or unexported methods }
Controller interface
func NewController ¶
func NewController(storage CatalogStorage, apiLocation string, listeners ...Listener) (CatalogController, error)
type CatalogStorage ¶
type CatalogStorage interface { Close() error // contains filtered or unexported methods }
Storage interface
func NewLevelDBStorage ¶
func NewLevelDBStorage(dsn string, opts *opt.Options) (CatalogStorage, error)
type Collection ¶
type ConflictError ¶
type ConflictError struct {
// contains filtered or unexported fields
}
Conflict (non-unique id, assignment to read-only data)
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
type Controller ¶
type Error ¶
type Error struct { // Code is the (http) code of the error Code int `json:"code"` // Message is the (human-readable) error message Message string `json:"message"` }
Error describes an API error (serializable in JSON)
type GCPublisher ¶
type GCPublisher struct {
// contains filtered or unexported fields
}
GCPublisher is a catalog Listener publishing catalog updates to the GlobalConnect
func NewGCPublisher ¶
func NewGCPublisher(endpoint url.URL) *GCPublisher
NewGCPublisher instantiates a GCPublisher
type JSONLDService ¶
type LevelDBStorage ¶
type LevelDBStorage struct {
// contains filtered or unexported fields
}
LevelDB storage
func (*LevelDBStorage) Close ¶
func (s *LevelDBStorage) Close() error
type Listener ¶
type Listener interface {
// contains filtered or unexported methods
}
Listener interface can be used for notification of the catalog updates NOTE: Implementations are expected to be thread safe
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
AVL Tree: sorted nodes according to keys
A node of the AVL Tree (go-avltree)
type MemoryStorage ¶
In-memory storage
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
func (*MemoryStorage) Close ¶
func (ms *MemoryStorage) Close() error
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
Not Found
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Protocol ¶
type Protocol struct { Type string `json:"type"` Endpoint map[string]interface{} `json:"endpoint"` Methods []string `json:"methods,omitempty"` ContentTypes []string `json:"content-types,omitempty"` }
Protocol describes the service API
type RemoteCatalogClient ¶
type RemoteCatalogClient struct {
// contains filtered or unexported fields
}
func (*RemoteCatalogClient) Add ¶
func (c *RemoteCatalogClient) Add(s *Service) (string, error)
Adds a service
func (*RemoteCatalogClient) Delete ¶
func (c *RemoteCatalogClient) Delete(id string) error
Deletes a service
func (*RemoteCatalogClient) Filter ¶
func (c *RemoteCatalogClient) Filter(path, op, value string, page, perPage int) ([]Service, int, error)
Filter services
func (*RemoteCatalogClient) Get ¶
func (c *RemoteCatalogClient) Get(id string) (*Service, error)
Retrieves a service
type Service ¶
type Service struct { Id string `json:"id"` URL string `json:"url"` Type string `json:"type"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Meta map[string]interface{} `json:"meta,omitempty"` Protocols []Protocol `json:"protocols"` Representation map[string]interface{} `json:"representation,omitempty"` Ttl int `json:"ttl,omitempty"` Created time.Time `json:"created"` Updated time.Time `json:"updated"` Expires *time.Time `json:"expires,omitempty"` }
Service is a service entry in the catalog
type ServiceConfig ¶
ServiceConfig is a wrapper for Service to be used by clients to configure a Service (e.g., read from file)
func (*ServiceConfig) GetService ¶
func (sc *ServiceConfig) GetService() (*Service, error)
Returns a Service object from the ServiceConfig
type TunneledService ¶
type TunneledService struct { Endpoint string `json:"Endpoint"` BackboneName string `json:"BackboneName"` VirtualAddress string `json:"VirtualAddress,omitempty"` // set in responses and used for DELETE Attributes map[string]interface{} `json:"Attributes"` }
TunneledService describes a service tunneled with LinkSmart GC
func NewTunneledService ¶
func NewTunneledService(s *Service, vad string) (*TunneledService, error)
NewTunneledService creates a TunneledService given a Service