registry

package
v0.2.23 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package registry is an interface for service discovery

Index

Constants

View Source
const (
	// DefaultMaxMsgSize define maximum message size that server can send or receive.
	// Default value is 4MB.
	DefaultMaxMsgSize = 1024 * 1024 * 4

	DefaultSleepAfterDeRegister = time.Second * 2

	// DefaultRegisterTTL The register expiry time
	DefaultRegisterTTL = time.Minute

	// DefaultRegisterInterval The interval on which to register
	DefaultRegisterInterval = time.Second * 30

	DefaultSleepAfterDeregister = time.Second * 2
)
View Source
const DefaultPrefix = "/registry"

Variables

View Source
var (
	ErrWatcherStopped = errors.New("watcher stopped")
	ErrNotFound       = errors.New("not found")
)

ErrWatcherStopped Watcher stopped error when watcher is stopped

View Source
var Name = "registry"

Functions

func New added in v0.2.11

func New(c *Config, lifecycle lifecycle.Lifecycle, regs map[string]Registry)

func SetDefault

func SetDefault(r Registry)

Types

type Config added in v0.2.11

type Config struct {
	RegisterInterval time.Duration          `yaml:"registerInterval"`
	Driver           string                 `json:"driver" yaml:"driver"`
	DriverCfg        map[string]interface{} `json:"driver_config" yaml:"driver_config"`
}

func DefaultCfg

func DefaultCfg() Config

func (*Config) Check added in v0.2.11

func (cfg *Config) Check() *Config

type DeregOpt

type DeregOpt func(*DeregOpts)

type DeregOpts

type DeregOpts struct {
	Context context.Context
}

type GetOpts

type GetOpts struct {
	Timeout time.Duration
	Context context.Context
}

type ListOpts

type ListOpts struct {
	Context context.Context
}

type Opt

type Opt func(*Opts)

func Addrs

func Addrs(addrs ...string) Opt

Addrs is the registry addresses to use

func Secure

func Secure(b bool) Opt

Secure communication with the registry

func Services

func Services(s map[string][]*service.Service) Opt

Services is an option that preloads service data

func TLSConfig

func TLSConfig(t *tls.Config) Opt

TLSConfig Specify TLS Config

func Timeout

func Timeout(t time.Duration) Opt

type Opts

type Opts struct {
	Addrs     []string
	Timeout   time.Duration
	Secure    bool
	TLSConfig *tls.Config
	Context   context.Context
}

type RegOpt

type RegOpt func(*RegOpts)

func RegisterContext

func RegisterContext(ctx context.Context) RegOpt

func RegisterTTL

func RegisterTTL(t time.Duration) RegOpt

func TTL

func TTL(dur time.Duration) RegOpt

type RegOpts

type RegOpts struct {
	TTL     time.Duration
	Context context.Context
}

type Registry

type Registry interface {
	String() string
	Register(context.Context, *service.Service, ...RegOpt) error
	Deregister(context.Context, *service.Service, ...DeregOpt) error
}

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

func Default

func Default() Registry

type WatchOpts

type WatchOpts struct {
	Service string
	Context context.Context
}

Directories

Path Synopsis
drivers
mdns
Package mdns is a multicast dns registry
Package mdns is a multicast dns registry

Jump to

Keyboard shortcuts

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