registry

package
v0.20.14 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRegistry Registry

	// ErrNotFound not found error when GetService is called
	ErrNotFound = errors.New("service not found")
	// ErrWatcherStopped watcher stopped error when watcher is stopped
	ErrWatcherStopped = errors.New("watcher stopped")
)

Functions

func Deregister

func Deregister(s *regpb.Service) error

Deregister a service node

func GetService

func GetService(name string) ([]*regpb.Service, error)

GetService retrieve a service. A slice is returned since we separate Name/Version.

func ListServices

func ListServices() ([]*regpb.Service, error)

ListServices list the services. Only returns service names

func Register

func Register(s *regpb.Service, opts ...RegisterOption) error

Register a service node. Additionally supply options such as TTL.

func String

func String() string

Types

type DeregisterOption

type DeregisterOption func(*DeregisterOptions)

func DeregisterContext

func DeregisterContext(ctx context.Context) DeregisterOption

type DeregisterOptions

type DeregisterOptions struct {
	Context context.Context
}

type GetOption

type GetOption func(*GetOptions)

func GetContext

func GetContext(ctx context.Context) GetOption

type GetOptions

type GetOptions struct {
	Context context.Context
}

type ListOption

type ListOption func(*ListOptions)

func ListContext

func ListContext(ctx context.Context) ListOption

type ListOptions

type ListOptions struct {
	Context context.Context
}

type OpenAPIOption

type OpenAPIOption func(*OpenAPIOptions)

type OpenAPIOptions

type OpenAPIOptions struct {
	Context context.Context
}

type Option

type Option func(*Options)

func Addrs

func Addrs(addrs ...string) Option

Addrs is the registry addresses to use

func Secure

func Secure(b bool) Option

Secure communication with the registry

func TLSConfig

func TLSConfig(t *tls.Config) Option

Specify TLS Config

func Timeout

func Timeout(t time.Duration) Option

type Options

type Options struct {
	Addrs     []string
	Timeout   time.Duration
	Secure    bool
	TLSConfig *tls.Config
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type RegisterOption

type RegisterOption func(*RegisterOptions)

func RegisterContext

func RegisterContext(ctx context.Context) RegisterOption

func RegisterTTL

func RegisterTTL(t time.Duration) RegisterOption

type RegisterOptions

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

type Registry

type Registry interface {
	Init(...Option) error
	Options() Options
	Register(*regpb.Service, ...RegisterOption) error
	Deregister(*regpb.Service, ...DeregisterOption) error
	GetService(string, ...GetOption) ([]*regpb.Service, error)
	ListServices(...ListOption) ([]*regpb.Service, error)
	Watch(...WatchOption) (Watcher, error)
	String() string
}

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

type WatchOption

type WatchOption func(*WatchOptions)

func WatchContext

func WatchContext(ctx context.Context) WatchOption

func WatchService

func WatchService(name string) WatchOption

WatchService watches a service

type WatchOptions

type WatchOptions struct {
	// Specify a service to watch
	// If blank, the watch is for all services
	Service string
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type Watcher

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

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

func Watch

func Watch(opts ...WatchOption) (Watcher, error)

Watch returns a watcher which allows you to track updates to the registry.

Directories

Path Synopsis
Package grpc service uses the registry service
Package grpc service uses the registry service
Package mdns provides a multicast dns registry
Package mdns provides a multicast dns registry
Package memory provides an in-memory registry
Package memory provides an in-memory registry

Jump to

Keyboard shortcuts

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