Documentation ¶
Index ¶
- Constants
- type Registry
- type RegistryEvent
- type RegistryWatcher
- type ServiceEvent
- type ServiceInstanceSpec
- type ServiceRegistry
- func (sr *ServiceRegistry) ApplyServiceInstances(registryName string, serviceInstances map[string]*ServiceInstanceSpec) error
- func (sr *ServiceRegistry) Category() supervisor.ObjectCategory
- func (sr *ServiceRegistry) Close()
- func (sr *ServiceRegistry) DefaultSpec() interface{}
- func (sr *ServiceRegistry) DeleteServiceInstances(registryName string, serviceInstances map[string]*ServiceInstanceSpec) error
- func (sr *ServiceRegistry) DeregisterRegistry(registryName string) error
- func (sr *ServiceRegistry) GetServiceInstance(registryName, serviceName, instanceID string) (*ServiceInstanceSpec, error)
- func (sr *ServiceRegistry) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object)
- func (sr *ServiceRegistry) Init(superSpec *supervisor.Spec)
- func (sr *ServiceRegistry) Kind() string
- func (sr *ServiceRegistry) ListAllServiceInstances(registryName string) (map[string]*ServiceInstanceSpec, error)
- func (sr *ServiceRegistry) ListServiceInstances(registryName, serviceName string) (map[string]*ServiceInstanceSpec, error)
- func (sr *ServiceRegistry) NewRegistryWatcher(registryName string) RegistryWatcher
- func (sr *ServiceRegistry) NewServiceWatcher(registryName, serviceName string) ServiceWatcher
- func (sr *ServiceRegistry) RegisterRegistry(registry Registry) error
- func (sr *ServiceRegistry) Status() *supervisor.Status
- type ServiceWatcher
- type Spec
- type Status
Constants ¶
const ( // Category is the category of ServiceRegistry. Category = supervisor.CategorySystemController // Kind is the kind of ServiceRegistry. Kind = "ServiceRegistry" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶ added in v1.3.0
type Registry interface { Name() string // Operation from the registry. Notify() <-chan *RegistryEvent // Operations to the registry. // The key of maps is key of service instance. ApplyServiceInstances(serviceInstances map[string]*ServiceInstanceSpec) error DeleteServiceInstances(serviceInstances map[string]*ServiceInstanceSpec) error // GetServiceInstance must return error if not found. GetServiceInstance(serviceName, instanceID string) (*ServiceInstanceSpec, error) // ListServiceInstances could return zero elements of instances with nil error. ListServiceInstances(serviceName string) (map[string]*ServiceInstanceSpec, error) // ListServiceInstances could return zero elements of instances with nil error. ListAllServiceInstances() (map[string]*ServiceInstanceSpec, error) }
Registry stands for the specific service registry.
type RegistryEvent ¶ added in v1.3.0
type RegistryEvent struct { // SourceRegistryName is the registry which caused the event, // the RegistryName of specs may not be the same with it. SourceRegistryName string UseReplace bool // Replace replaces all service instances of the registry. Replace map[string]*ServiceInstanceSpec // Apply creates or updates service instances of the registry. Apply map[string]*ServiceInstanceSpec // Delete deletes service instances of the registry. Delete map[string]*ServiceInstanceSpec }
RegistryEvent is the event of service registry. If UseReplace is true, the event handler should use Replace field even it is empty. NOTE: Changing inner fields needs to adapt to its methods Empty, DeepCopy, Validate, etc.
func NewRegistryEventFromDiff ¶ added in v1.3.0
func NewRegistryEventFromDiff(registryName string, oldSpecs, newSpecs map[string]*ServiceInstanceSpec) *RegistryEvent
NewRegistryEventFromDiff creates a registry event from diff old and new specs. It only uses Apply and Delete excluding Replace. External drivers should use event.Replace in first time, then use this utility to generate next events. registryName is only assigned to the event, the registry name of service instance spec won't change.
func (*RegistryEvent) DeepCopy ¶ added in v1.3.0
func (e *RegistryEvent) DeepCopy() *RegistryEvent
DeepCopy deep copies RegistryEvent.
func (*RegistryEvent) Empty ¶ added in v1.3.0
func (e *RegistryEvent) Empty() bool
Empty returns if the event contains nothing to handle.
func (*RegistryEvent) Validate ¶ added in v1.3.0
func (e *RegistryEvent) Validate() error
Validate validates RegistryEvent.
type RegistryWatcher ¶ added in v1.3.0
type RegistryWatcher interface { ID() string RegistryName() string // Exists returns if the registry exists. Exists() bool // The channel will be closed if the registry is closed. Watch() <-chan *RegistryEvent Stop() }
RegistryWatcher is the watcher of service registry.
type ServiceEvent ¶ added in v1.3.0
type ServiceEvent struct { // SourceRegistryName is the registry which caused the event, // the RegistryName of specs may not be the same with it. SourceRegistryName string Instances map[string]*ServiceInstanceSpec }
ServiceEvent is the event of service. It concludes complete instances of the service. NOTE: Changing inner fields needs to adapt to its methods DeepCopy, etc.
func (*ServiceEvent) DeepCopy ¶ added in v1.3.0
func (e *ServiceEvent) DeepCopy() *ServiceEvent
DeepCopy deep copies ServiceEvent.
type ServiceInstanceSpec ¶ added in v1.3.0
type ServiceInstanceSpec struct { // RegistryName is required. RegistryName string `yaml:"registryName"` // ServiceName is required. ServiceName string `yaml:"serviceName"` // InstanceID is required. InstanceID string `yaml:"instanceID"` // Address is required. Address string `yaml:"address"` // Port is required. Port uint16 `yaml:"port"` // Scheme is optional. Scheme string `yaml:"scheme"` // Tags is optional. Tags []string `yaml:"tags"` // Weight is optional. Weight int `yaml:"weight"` }
ServiceInstanceSpec is the service instance spec in Easegress.
func (*ServiceInstanceSpec) DeepCopy ¶ added in v1.3.0
func (s *ServiceInstanceSpec) DeepCopy() *ServiceInstanceSpec
DeepCopy deep copies ServiceInstanceSpec.
func (*ServiceInstanceSpec) Key ¶ added in v1.3.0
func (s *ServiceInstanceSpec) Key() string
Key returns the unique key for the service instance.
func (*ServiceInstanceSpec) URL ¶ added in v1.3.0
func (s *ServiceInstanceSpec) URL() string
URL returns the url of the server.
func (*ServiceInstanceSpec) Validate ¶ added in v1.3.0
func (s *ServiceInstanceSpec) Validate() error
Validate validates itself.
type ServiceRegistry ¶
type ServiceRegistry struct {
// contains filtered or unexported fields
}
ServiceRegistry is a system controller to be center registry between external registries and internal handlers and watchers. To be specific: it dispatches event from every registry to every watcher, and wraps the operations from handlers to every registry.
func (*ServiceRegistry) ApplyServiceInstances ¶ added in v1.3.0
func (sr *ServiceRegistry) ApplyServiceInstances(registryName string, serviceInstances map[string]*ServiceInstanceSpec) error
ApplyServiceInstances applies the services to the registry with change RegistryName of all specs.
func (*ServiceRegistry) Category ¶ added in v1.3.0
func (sr *ServiceRegistry) Category() supervisor.ObjectCategory
Category returns the category of ServiceRegistry.
func (*ServiceRegistry) Close ¶ added in v1.3.0
func (sr *ServiceRegistry) Close()
Close closes ServiceRegistry.
func (*ServiceRegistry) DefaultSpec ¶ added in v1.3.0
func (sr *ServiceRegistry) DefaultSpec() interface{}
DefaultSpec returns the default spec of ServiceRegistry.
func (*ServiceRegistry) DeleteServiceInstances ¶ added in v1.3.0
func (sr *ServiceRegistry) DeleteServiceInstances(registryName string, serviceInstances map[string]*ServiceInstanceSpec) error
DeleteServiceInstances service instances of one service.
func (*ServiceRegistry) DeregisterRegistry ¶ added in v1.3.0
func (sr *ServiceRegistry) DeregisterRegistry(registryName string) error
DeregisterRegistry remove the registry.
func (*ServiceRegistry) GetServiceInstance ¶ added in v1.3.0
func (sr *ServiceRegistry) GetServiceInstance(registryName, serviceName, instanceID string) (*ServiceInstanceSpec, error)
GetServiceInstance get service instance.
func (*ServiceRegistry) Inherit ¶ added in v1.3.0
func (sr *ServiceRegistry) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object)
Inherit inherits previous generation of ServiceRegistry.
func (*ServiceRegistry) Init ¶ added in v1.3.0
func (sr *ServiceRegistry) Init(superSpec *supervisor.Spec)
Init initializes ServiceRegistry.
func (*ServiceRegistry) Kind ¶ added in v1.3.0
func (sr *ServiceRegistry) Kind() string
Kind returns the kind of ServiceRegistry.
func (*ServiceRegistry) ListAllServiceInstances ¶ added in v1.3.0
func (sr *ServiceRegistry) ListAllServiceInstances(registryName string) (map[string]*ServiceInstanceSpec, error)
ListAllServiceInstances service instances of all services.
func (*ServiceRegistry) ListServiceInstances ¶ added in v1.3.0
func (sr *ServiceRegistry) ListServiceInstances(registryName, serviceName string) (map[string]*ServiceInstanceSpec, error)
ListServiceInstances service instances of one service.
func (*ServiceRegistry) NewRegistryWatcher ¶ added in v1.3.0
func (sr *ServiceRegistry) NewRegistryWatcher(registryName string) RegistryWatcher
NewRegistryWatcher creates a registry watcher.
func (*ServiceRegistry) NewServiceWatcher ¶ added in v1.3.0
func (sr *ServiceRegistry) NewServiceWatcher(registryName, serviceName string) ServiceWatcher
NewServiceWatcher creates a service watcher.
func (*ServiceRegistry) RegisterRegistry ¶ added in v1.3.0
func (sr *ServiceRegistry) RegisterRegistry(registry Registry) error
RegisterRegistry registers the registry and watch it.
func (*ServiceRegistry) Status ¶ added in v1.3.0
func (sr *ServiceRegistry) Status() *supervisor.Status
Status returns status of ServiceRegistry.
type ServiceWatcher ¶ added in v1.3.0
type ServiceWatcher interface { ID() string RegistryName() string ServiceName() string Watch() <-chan *ServiceEvent Stop() }
ServiceWatcher is the watcher of service.
type Spec ¶ added in v1.3.0
type Spec struct { // TODO: Support updating for system controller. // Please notice some components may reference of old system controller // after reloading, this should be fixed. SyncInterval string `yaml:"syncInterval" jsonschema:"required,format=duration"` }
Spec describes ServiceRegistry.