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 ¶
func GetClient ¶
GetClient returns the default client for the service name
Types ¶
type Nodes ¶
Nodes wraps an array of registry nodes
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, ...}
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
Source Files
¶
- ctl.go
- mock-service.go
- options.go
- registry.go
- running.go
- services.go
- utils.go
- watcher.go