service

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2014 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CatalogBaseUrl   = "/sc"
	DnssdServiceType = "_patchwork-sc._tcp"
)
View Source
const (
	PatternReg         = ":regid"
	PatternHostid      = ":hostid"
	PatternFType       = ":type"
	PatternFPath       = ":path"
	PatternFOp         = ":op"
	PatternFValue      = ":value"
	FTypeRegistration  = "service"
	FTypeRegistrations = "services"
	CurrentApiVersion  = "0.1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CatalogClient

type CatalogClient interface {
	Get(string) (Registration, error)
	Add(Registration) (Registration, error)
	Update(string, Registration) (Registration, error)
	Delete(string) (Registration, error)
	GetAll() ([]Registration, error)
}

Catalog client

type CatalogStorage

type CatalogStorage interface {
	// contains filtered or unexported methods
}

Storage interface

type Collection

type Collection struct {
	Context  string         `json:"@context,omitempty"`
	Id       string         `json:"id"`
	Type     string         `json:"type"`
	Services []Registration `json:"services"`
}

type MemoryStorage

type MemoryStorage struct {
	// contains filtered or unexported fields
}

In-memory storage

func NewCatalogMemoryStorage

func NewCatalogMemoryStorage() *MemoryStorage

type Protocol

type Protocol struct {
	Type         string                 `json:"type"`
	Endpoint     map[string]interface{} `json:"endpoint"`
	Methods      []string               `json:"methods"`
	ContentTypes []string               `json:"content-types"`
}

Protocol describes the service API

type ReadableCatalogAPI

type ReadableCatalogAPI struct {
	// contains filtered or unexported fields
}

Read-only catalog api

func NewReadableCatalogAPI

func NewReadableCatalogAPI(storage CatalogStorage, contextUrl string) *ReadableCatalogAPI

func (ReadableCatalogAPI) Filter

func (self ReadableCatalogAPI) Filter(w http.ResponseWriter, req *http.Request)

func (ReadableCatalogAPI) Get

func (ReadableCatalogAPI) List

func (self ReadableCatalogAPI) List(w http.ResponseWriter, req *http.Request)

type Registration

type Registration struct {
	Id             string                 `json:"id"`
	Type           string                 `json:"type"`
	Name           string                 `json:"name"`
	Description    string                 `json:"description"`
	Meta           map[string]interface{} `json:"meta"`
	Protocols      []Protocol             `json:"protocols"`
	Representation map[string]interface{} `json:"representation"`
	Ttl            int                    `json:"ttl"`
	Created        time.Time              `json:"created"`
	Updated        time.Time              `json:"updated"`
	Expires        time.Time              `json:"expires"`
}

Registration is a service entry in the catalog

type Registrator

type Registrator struct {
	// contains filtered or unexported fields
}

The agent of a service responsible for registering a service in the Service Catalog and keeping this registration up to date

func NewRegistrator

func NewRegistrator(serverEndpoint string) *Registrator

func (*Registrator) DeregisterService

func (self *Registrator) DeregisterService(config *ServiceConfig) error

func (*Registrator) LoadConfigFromFile

func (self *Registrator) LoadConfigFromFile(confPath string) (*ServiceConfig, error)

Loads service registration from config file

func (*Registrator) RegisterService

func (self *Registrator) RegisterService(config *ServiceConfig, keepalive bool) error

type RemoteCatalogClient

type RemoteCatalogClient struct {
	// contains filtered or unexported fields
}

func NewRemoteCatalogClient

func NewRemoteCatalogClient(serverEndpoint string) *RemoteCatalogClient

func (*RemoteCatalogClient) Add

func (*RemoteCatalogClient) Delete

func (self *RemoteCatalogClient) Delete(id string) (Registration, error)

Empty registration and nil error should be interpreted as "not found"

func (*RemoteCatalogClient) Get

func (self *RemoteCatalogClient) Get(id string) (Registration, error)

Empty registration and nil error should be interpreted as "not found"

func (*RemoteCatalogClient) GetAll

func (self *RemoteCatalogClient) GetAll() ([]Registration, error)

func (*RemoteCatalogClient) Update

func (self *RemoteCatalogClient) Update(id string, r Registration) (Registration, error)

Empty registration and nil error should be interpreted as "not found"

type ServiceConfig

type ServiceConfig struct {
	Host           string
	Name           string
	Description    string
	Meta           map[string]interface{}
	Ttl            int
	Protocols      []Protocol
	Representation map[string]interface{}
}

Configuration object

type WritableCatalogAPI

type WritableCatalogAPI struct {
	*ReadableCatalogAPI
}

Writable catalog api

func NewWritableCatalogAPI

func NewWritableCatalogAPI(storage CatalogStorage, contextUrl string) *WritableCatalogAPI

func (WritableCatalogAPI) Add

func (WritableCatalogAPI) Delete

func (self WritableCatalogAPI) Delete(w http.ResponseWriter, req *http.Request)

func (WritableCatalogAPI) Update

func (self WritableCatalogAPI) Update(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL