registry

package
v3.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 9 Imported by: 4 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

registry

The registry package is not meant for use outside of grid. Please consider this a private package.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotOwner                    = errors.New("registry: not owner")
	ErrNotStarted                  = errors.New("registry: not started")
	ErrUnknownKey                  = errors.New("registry: unknown key")
	ErrNilEtcd                     = errors.New("registry: nil etcd")
	ErrAlreadyRegistered           = errors.New("registry: already registered")
	ErrFailedRegistration          = errors.New("registry: failed registration")
	ErrFailedDeregistration        = errors.New("registry: failed deregistration")
	ErrLeaseDurationTooShort       = errors.New("registry: lease duration too short")
	ErrUnknownNetAddressType       = errors.New("registry: unknown net address type")
	ErrWatchClosedUnexpectedly     = errors.New("registry: watch closed unexpectedly")
	ErrUnspecifiedNetAddressIP     = errors.New("registry: unspecified net address ip")
	ErrKeepAliveClosedUnexpectedly = errors.New("registry: keep alive closed unexpectedly")
)

Functions

This section is empty.

Types

type EventType

type EventType int

EventType of a watch event.

const (
	Error  EventType = 0
	Delete EventType = 1
	Modify EventType = 2
	Create EventType = 3
)

type Logger

type Logger interface {
	Printf(string, ...interface{})
}

Logger hides the logging function Printf behind a simple interface so libraries such as logrus can be used. Copied from package grid to avoid interndependencies.

type Option

type Option int
const (
	// OpAllowReentrantRegistration will cause a registration
	// to the same key to succeed if it is requested by the
	// same registry, ie: host, address, process.
	OpAllowReentrantRegistration Option = 0
)

type Registration

type Registration struct {
	Key      string `json:"key"`
	Address  string `json:"address"`
	Registry string `json:"registry"`
}

Registration information.

func (*Registration) String

func (r *Registration) String() string

String descritpion of registration.

type Registry

type Registry struct {
	Logger        Logger
	Timeout       time.Duration
	LeaseDuration time.Duration
	// contains filtered or unexported fields
}

Registry for discovery.

func New

func New(client *etcdv3.Client) (*Registry, error)

New Registry.

func (*Registry) Address

func (rr *Registry) Address() string

Address of this registry in the format of <ip>:<port>

func (*Registry) Deregister

func (rr *Registry) Deregister(c context.Context, key string) error

Deregister under the given key.

func (*Registry) FindRegistration

func (rr *Registry) FindRegistration(c context.Context, key string) (*Registration, error)

FindRegistration associated with the given key.

func (*Registry) FindRegistrations

func (rr *Registry) FindRegistrations(c context.Context, prefix string) ([]*Registration, error)

FindRegistrations associated with the prefix.

func (*Registry) Register

func (rr *Registry) Register(c context.Context, key string, options ...Option) error

Register under the given key. A registration can happen only once, and registering more than once will return an error. Hence, registration can be used for mutual-exclusion.

func (*Registry) Registry

func (rr *Registry) Registry() string

Registry name, which is a human readable all ASCII transformation of the network address.

func (*Registry) Start

func (rr *Registry) Start(addr net.Addr) (<-chan error, error)

Start Registry.

func (*Registry) Stop

func (rr *Registry) Stop() error

Stop Registry.

func (*Registry) Watch

func (rr *Registry) Watch(c context.Context, prefix string) ([]*Registration, <-chan *WatchEvent, error)

Watch a prefix in the registry.

type WatchEvent

type WatchEvent struct {
	Key   string
	Reg   *Registration
	Type  EventType
	Error error
}

WatchEvent triggred by a change in the registry.

func (*WatchEvent) String

func (we *WatchEvent) String() string

String representation of the watch event.

Jump to

Keyboard shortcuts

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