Documentation ¶
Overview ¶
Package registry provides the main glue between services
It wraps micro registry (running services declared to the discovery server) into a more generic registry where all actual plugins are self-declared.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Default registry Default = NewRegistry() )
Functions ¶
Types ¶
type Nodes ¶
Nodes wraps an array of registry nodes
func (Nodes) StringArray ¶
StringArray representation of the registry nodes
type Option ¶
type Option func(*Options)
Option is a gateway to setting Options to the Registry
func PollInterval ¶
PollInterval defines an interval option to a watcher
type Options ¶
type Options struct { Name string PollInterval time.Duration // Other options for implementations of the interface // can be stored in a context Context context.Context }
Options defines options to the Registry itself
type RegisterOption ¶
type RegisterOption func(*RegisterOptions)
RegisterOption is a gateway to setting RegisterOptions to a Registry Entry
func RegisterDependencies ¶
func RegisterDependencies(d ...string) RegisterOption
RegisterDependencies adds dependencies between services to the registry entry
func RegisterFlags ¶
func RegisterFlags(f ...*pflag.Flag) RegisterOption
RegisterFlags adds flags to the registry entry service
type RegisterOptions ¶
type RegisterOptions struct { Dependencies []string Flags []*pflag.Flag // Other options for implementations of the interface // can be stored in a context Context context.Context }
RegisterOptions defines different options for the Register entry
type Registry ¶
type Registry interface { Init(...Option) Register(Service, ...RegisterOption) error Deregister(Service) error GetService(string) ([]Service, error) GetServicesByName(string) []Service ListServices(withExcluded ...bool) ([]Service, error) ListRunningServices() ([]Service, error) ListServicesWithMicroMeta(string, ...string) ([]Service, error) Filter(func(Service) bool) error Watch() (Watcher, error) String() string Options() Options BeforeInit() error AfterInit() error }
Registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}
func NewRegistry ¶
NewRegistry provides a new registry object
type Service ¶
type Service interface { Start() Stop() IsRunning() bool IsExcluded() bool SetExcluded(ex bool) Check(context.Context) error Name() string Regexp() *regexp.Regexp Version() string Description() string Tags() []string GetDependencies() []Service AddDependency(string) SetRunningNodes([]*registry.Node) RunningNodes() []*registry.Node ExposedConfigs() *forms.Form IsGeneric() bool IsGRPC() bool IsREST() bool MatchesRegexp(string) bool BeforeInit() error AfterInit() error }
Service defines the primary functions a service must be able to answer to for the registry
func ListRunningServices ¶
ListRunningServices returns the list of services that are started in the system
func ListServices ¶
ListServices returns the list of services that are started in the system