Documentation
¶
Overview ¶
Package nats provides a NATS registry using broadcast queries
Index ¶
- Constants
- Variables
- func ProvideRegistryNATS(name types.ServiceName, version types.ServiceVersion, datas types.ConfigData, ...) (registry.Type, error)
- func WithAddress(n ...string) registry.Option
- func WithQueryTopic(n string) registry.Option
- func WithQuorum(n int) registry.Option
- func WithSecure(n bool) registry.Option
- func WithTLSConfig(n *tls.Config) registry.Option
- func WithWatchTopic(n string) registry.Option
- type Config
- type RegistryNATS
- func (n *RegistryNATS) Deregister(service *registry.Service, _ ...registry.DeregisterOption) error
- func (n *RegistryNATS) GetService(s string, _ ...registry.GetOption) ([]*registry.Service, error)
- func (n *RegistryNATS) ListServices(_ ...registry.ListOption) ([]*registry.Service, error)
- func (n *RegistryNATS) NodeID() string
- func (n *RegistryNATS) Register(s *registry.Service, _ ...registry.RegisterOption) error
- func (n *RegistryNATS) ServiceName() string
- func (n *RegistryNATS) ServiceVersion() string
- func (n *RegistryNATS) Start() error
- func (n *RegistryNATS) Stop(_ context.Context) error
- func (n *RegistryNATS) String() string
- func (n *RegistryNATS) Type() string
- func (n *RegistryNATS) Watch(opts ...registry.WatchOption) (registry.Watcher, error)
Constants ¶
const Name = "nats"
Name provides the name of this registry.
Variables ¶
var ( DefaultAddresses = []string{"nats://localhost:4222"} DefaultQueryTopic = "micro.registry.nats.query" DefaultWatchTopic = "micro.registry.nats.watch" )
Defaults.
Functions ¶
func ProvideRegistryNATS ¶
func ProvideRegistryNATS( name types.ServiceName, version types.ServiceVersion, datas types.ConfigData, logger log.Logger, opts ...registry.Option, ) (registry.Type, error)
ProvideRegistryNATS creates a new NATS registry.
func WithAddress ¶
WithAddress sets the NATS server addresses.
func WithQueryTopic ¶
WithQueryTopic sets the NATS query topic.
func WithSecure ¶
WithSecure defines if we want a secure connection to nats.
func WithTLSConfig ¶
WithTLSConfig defines the TLS config to use for the secure connection.
func WithWatchTopic ¶
WithWatchTopic sets the NATS watch topic.
Types ¶
type Config ¶
type Config struct { registry.Config `yaml:",inline"` Addresses []string `json:"addresses,omitempty" yaml:"addresses,omitempty"` Secure bool `json:"secure,omitempty" yaml:"secure,omitempty"` TLSConfig *tls.Config `json:"-" yaml:"-"` Quorum int `json:"quorum,omitempty" yaml:"quorum,omitempty"` QueryTopic string `json:"queryTopic,omitempty" yaml:"queryTopic,omitempty"` WatchTopic string `json:"watchTopic,omitempty" yaml:"watchTopic,omitempty"` }
Config provides configuration for the NATS registry.
func NewConfig ¶
func NewConfig( serviceName types.ServiceName, datas types.ConfigData, opts ...registry.Option, ) (Config, error)
NewConfig creates a new config object.
func (*Config) ApplyOptions ¶
ApplyOptions applies a set of options to the config.
type RegistryNATS ¶
RegistryNATS implements the registry interface. It runs a NATS service registry.
func New ¶
New creates a new NATS registry. This functions should rarely be called manually. To create a new registry use ProvideRegistryNATS.
func (*RegistryNATS) Deregister ¶
func (n *RegistryNATS) Deregister( service *registry.Service, _ ...registry.DeregisterOption, ) error
Deregister deregisters a service within the registry.
func (*RegistryNATS) GetService ¶
GetService returns a service from the registry.
func (*RegistryNATS) ListServices ¶
func (n *RegistryNATS) ListServices(_ ...registry.ListOption) ([]*registry.Service, error)
ListServices lists services within the registry.
func (*RegistryNATS) NodeID ¶
func (n *RegistryNATS) NodeID() string
NodeID returns the ID of this service node in the registry.
func (*RegistryNATS) Register ¶
func (n *RegistryNATS) Register(s *registry.Service, _ ...registry.RegisterOption) error
Register registers a service within the registry.
func (*RegistryNATS) ServiceName ¶
func (n *RegistryNATS) ServiceName() string
ServiceName returns the configured name of this service.
func (*RegistryNATS) ServiceVersion ¶
func (n *RegistryNATS) ServiceVersion() string
ServiceVersion returns the configured version of this service.
func (*RegistryNATS) String ¶
func (n *RegistryNATS) String() string
String returns the plugin name.
func (*RegistryNATS) Watch ¶
func (n *RegistryNATS) Watch(opts ...registry.WatchOption) (registry.Watcher, error)
Watch returns a registry.Watcher which you can watch on.