nats

package
v2.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServerAddrValidator added in v2.4.0

func NewServerAddrValidator(server string) validation.Validator

NewServerAddrValidator validates the nats server address

Types

type Config

type Config struct {
	// NatsServer defines the nats server in the format nats://host:port
	NatsServer string
	// NatsSubject defines the custom NATS subject
	NatsSubject string
	// The actor system name
	ActorSystemName string
	// ApplicationName specifies the running application
	ApplicationName string
	// Timeout defines the nodes discovery timeout
	Timeout time.Duration
	// MaxJoinAttempts denotes the maximum number of attempts to connect an existing NATs server
	// Default to 5
	MaxJoinAttempts int
	// ReconnectWait sets the time to backoff after attempting a reconnect
	// to a server that we were already connected to previously.
	// Defaults to 2s.
	ReconnectWait time.Duration
}

Config represents the nats provider discoConfig

func (Config) Validate

func (x Config) Validate() error

Validate checks whether the given discovery configuration is valid

type Discovery

type Discovery struct {
	// contains filtered or unexported fields
}

Discovery represents the kubernetes discovery

func NewDiscovery

func NewDiscovery(config *Config, hostNode *discovery.Node, opts ...Option) *Discovery

NewDiscovery returns an instance of the kubernetes discovery provider

func (*Discovery) Close

func (d *Discovery) Close() error

Close closes the provider

func (*Discovery) Deregister

func (d *Discovery) Deregister() error

Deregister removes this node from a service discovery directory.

func (*Discovery) DiscoverPeers

func (d *Discovery) DiscoverPeers() ([]string, error)

DiscoverPeers returns a list of known nodes.

func (*Discovery) ID

func (d *Discovery) ID() string

ID returns the discovery provider id

func (*Discovery) Initialize

func (d *Discovery) Initialize() error

Initialize initializes the plugin: registers some internal data structures, clients etc.

func (*Discovery) Register

func (d *Discovery) Register() error

Register registers this node to a service discovery directory.

type Option

type Option interface {
	// Apply sets the Option value of a config.
	Apply(disco *Discovery)
}

Option is the interface that applies a configuration option.

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets the logger

type OptionFunc

type OptionFunc func(disco *Discovery)

OptionFunc implements the Option interface.

func (OptionFunc) Apply

func (f OptionFunc) Apply(disco *Discovery)

Apply applies the Cluster's option

type ServerAddrValidator added in v2.4.0

type ServerAddrValidator struct {
	// contains filtered or unexported fields
}

ServerAddrValidator helps validates the NATs server address

func (*ServerAddrValidator) Validate added in v2.4.0

func (x *ServerAddrValidator) Validate() error

Validate execute the validation code

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL