Documentation
¶
Overview ¶
Package store defines and implements a backend store for the registry
Index ¶
Constants ¶
const ( // ServiceNameMaxLength is the maximum length of a service instance name, specified in bytes ServiceNameMaxLength int = 64 // EndpointValueMaxLength is the maximum length of a service instance endpoint value, specified in bytes EndpointValueMaxLength int = 128 // StatusMaxLength is the maximum length of a service instance status field, specified in bytes StatusMaxLength int = 32 // MetadataMaxLength is the maximum length of a service instance metadata, specifie in bytes MetadataMaxLength int = 1024 )
const ( Starting = "STARTING" Up = "UP" OutOfService = "OUT_OF_SERVICE" All = "ALL" // ALL is only a valid status for the query string param and not for the register )
Registered instance status related constants
const ( REGISTER replicationType = iota DEREGISTER RENEW SETSTATUS READREPAIR )
Enumeration implementation for the replication actions types
Variables ¶
var DefaultConfig = NewConfig(defaultDefaultTTL, defaultMinimumTTL, defaultMaximumTTL, defaultNamespaceCapacity, nil, nil, defaultStore, defaultStoreAddr, defaultStorePassword, nil)
DefaultConfig is the default configuration parameters for the registry
Functions ¶
This section is empty.
Types ¶
type Catalog ¶
type Catalog interface { Register(si *ServiceInstance) (*ServiceInstance, error) Deregister(instanceID string) (*ServiceInstance, error) Renew(instanceID string) (*ServiceInstance, error) SetStatus(instanceID, status string) (*ServiceInstance, error) Instance(instanceID string) (*ServiceInstance, error) List(serviceName string, predicate Predicate) ([]*ServiceInstance, error) ListServices(predicate Predicate) []*Service }
Catalog for managing instances within a registry namespace
type CatalogFactory ¶
CatalogFactory represents the interface of the Catalog Factory
func NewDiscoveryAdapter ¶ added in v1.0.0
func NewDiscoveryAdapter(factory DiscoveryFactory) CatalogFactory
NewDiscoveryAdapter creates a CatalogFactory from the given DiscoveryFactory
type CatalogMap ¶
CatalogMap represents the interface of the Service store
func New ¶
func New(conf *Config) CatalogMap
New creates a new CatalogMap instance, bounded with the specified configuration
type Config ¶
type Config struct { DefaultTTL time.Duration MinimumTTL time.Duration MaximumTTL time.Duration NamespaceCapacity int SyncWaitTime time.Duration Extensions []CatalogFactory Replication replication.Replication Store string StoreAddr string StorePassword string StoreDatabase database.Database }
Config encapsulates the registry configuration parameters
func NewConfig ¶
func NewConfig(defaultTTL, minimumTTL, maximumTTL time.Duration, namespaceCapacity int, extensions []CatalogFactory, rep replication.Replication, store string, storeAddr string, storePassword string, storeDatabase database.Database) *Config
NewConfig creates a new registry configuration according to the specified TTL values
type DiscoveryFactory ¶ added in v1.0.0
type DiscoveryFactory func(namespace auth.Namespace) (api.ServiceDiscovery, error)
DiscoveryFactory is a function which accepts a namespace and returns a discovery object for that namespace
type Endpoint ¶
Endpoint represents a network endpoint. Immutable by convention.
type Error ¶
Error is an error implementation that is associated with an ErrorCode
type ErrorCode ¶
type ErrorCode int
ErrorCode represents an error condition that might occur during a registry operation
const ( ErrorBadRequest ErrorCode = iota ErrorNoSuchServiceName ErrorNoSuchServiceInstance ErrorNamespaceQuotaExceeded ErrorInternalServerError ErrorNoInstanceServiceName ErrorInstanceServiceNameTooLong ErrorInstanceEndpointValueTooLong ErrorInstanceStatusLengthTooLong ErrorInstanceMetaDataTooLong )
ErrorCode predefined values
type ExternalRegistry ¶
type ExternalRegistry interface { ReadKeys(namespace auth.Namespace) ([]string, error) ReadServiceInstanceByInstID(namespace auth.Namespace, instanceID string) (*ServiceInstance, error) ListServiceInstancesByName(namespace auth.Namespace, name string) (map[string]*ServiceInstance, error) ListAllServiceInstances(namespace auth.Namespace) (map[string]ServiceInstanceMap, error) InsertServiceInstance(namespace auth.Namespace, instance *ServiceInstance) error DeleteServiceInstance(namespace auth.Namespace, instanceID string) (int, error) }
ExternalRegistry calls to manage the instances in an external store
func NewMockExternalRegistry ¶
func NewMockExternalRegistry(mockServiceInstances map[string]*ServiceInstance) ExternalRegistry
NewMockExternalRegistry is a mock version of the external registry
func NewRedisRegistry ¶
func NewRedisRegistry(db database.Database) ExternalRegistry
NewRedisRegistry is backed by a Redis db
type Predicate ¶
type Predicate func(si *ServiceInstance) bool
Predicate for filtering returned instances
type Service ¶
type Service struct {
ServiceName string
}
Service represents a runtime service group.
type ServiceInstance ¶
type ServiceInstance struct { ID string ServiceName string Endpoint *Endpoint Status string Metadata []byte RegistrationTime time.Time LastRenewal time.Time TTL time.Duration Tags []string Extension map[string]interface{} }
ServiceInstance represents a runtime instance of a service.
func (*ServiceInstance) DeepClone ¶
func (si *ServiceInstance) DeepClone() *ServiceInstance
DeepClone creates a deep copy of the receiver
func (*ServiceInstance) String ¶
func (si *ServiceInstance) String() string
String output the structure
type ServiceInstanceMap ¶
type ServiceInstanceMap map[DBKey]*ServiceInstance
ServiceInstanceMap is a map of ServiceInstances keyed by instance id and service name