registry

package
v0.21.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeregisterOption

type DeregisterOption func(*DeregisterOptions)

DeregisterOption options' of deregistering service functions

type DeregisterOptions

type DeregisterOptions struct {
	TTL time.Duration
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

DeregisterOptions deregister service Options

type GetOption

type GetOption func(*GetOptions)

GetOption options' of getting service functions

type GetOptions

type GetOptions struct {
	Context context.Context
}

GetOptions get service Options

type NewRegistryFunc

type NewRegistryFunc func(...Option) (Registry, error)

NewRegistryFunc new registry function

type Option

type Option func(*Options)

Option initial options' functions

func Context

func Context(ctx context.Context) Option

func Endpoints

func Endpoints(endpoints []string) Option

func Logger

func Logger(l logger.Logger) Option

func RetryTimes

func RetryTimes(rTimes uint32) Option

func Secure

func Secure(secure bool) Option

func ServerAddr

func ServerAddr(addr string) Option

func TLSConfig

func TLSConfig(tlsConfig *tls.Config) Option

func Timeout

func Timeout(timeout time.Duration) Option

type Options

type Options struct {
	Endpoints []string
	Timeout   time.Duration
	Secure    bool
	TLSConfig *tls.Config

	ServerAddr string
	RetryTimes uint32

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context

	Logger logger.Logger
}

Options new registry Options

type ProcessService

type ProcessService interface {
	Register(*service.Service, ...RegisterOption) error
	Deregister(*service.Service, ...DeregisterOption) error
	Watch(...WatchOption) (Watcher, error)
}

ProcessService Process register service

type RegisterOption

type RegisterOption func(*RegisterOptions)

RegisterOption options' of registing service functions

func RegisterHeartbeat

func RegisterHeartbeat(hb time.Duration) RegisterOption

func RegisterTTL

func RegisterTTL(ttl time.Duration) RegisterOption

func RegisterWeight

func RegisterWeight(w uint32) RegisterOption

type RegisterOptions

type RegisterOptions struct {
	TTL       time.Duration
	Heartbeat time.Duration
	Weight    uint32
}

RegisterOptions regist service Options

func (*RegisterOptions) Check

func (p *RegisterOptions) Check()

type Registry

type Registry interface {
	Init(...Option) error
	Options() Options

	ProcessService

	Stop() error

	ID() string
	String() string
}

Registry The registry provides an interface for service discovery and an abstraction over varying implementations {consul, etcd, zookeeper, ...}

type Result

type Result struct {
	// Id is registry id
	ID string
	// Type defines type of event
	Type service.EventType
	// Timestamp is event timestamp
	Timestamp time.Time
	// Service is registry service
	Service *Service
}

Result is registry result

type Service

type Service struct {
	service.Service `json:",inline" yaml:",inline"`

	*node.Node `json:"node" yaml:"node"`
}

Service service

type WatchOption

type WatchOption func(*WatchOptions)

WatchOption options' of watching service functions

func WatchLogger

func WatchLogger(l logger.Logger) WatchOption

func WatchService

func WatchService(service service.Service) WatchOption

type WatchOptions

type WatchOptions struct {
	Service service.Service

	Logger logger.Logger
}

WatchOptions watch service Options

type Watcher

type Watcher interface {
	// Next is a blocking call
	Next() (*Result, error)
	Stop()
}

Watcher is an interface that returns updates about services within the registry.

Jump to

Keyboard shortcuts

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