registry

package
v0.0.1-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 3 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Evt  EventType
	Data []byte
}

type EventType

type EventType int
const (
	Create EventType = iota
	Update
	Delete
)

func (EventType) String

func (et EventType) String() string

type Getter

type Getter interface {
	GetNodes(string) ([]Node, error)
}

type Marshaler

type Marshaler func(Node) ([]byte, error)

type Node

type Node interface {
	Key() string
	Data() []byte
	Addr() string
}

type Option

type Option func(*Options)

func Addrs

func Addrs(addrs ...string) Option

func Context

func Context(ctx context.Context) Option

func Decoder

func Decoder(unmarshal Unmarshaler) Option

func Encoder

func Encoder(marshal Marshaler) Option

func TLSConfig

func TLSConfig(t *tls.Config) Option

func Timeout

func Timeout(timeout time.Duration) Option

type Options

type Options struct {
	Addrs     []string
	Timeout   time.Duration
	TLSConfig *tls.Config
	Encode    Marshaler
	Decode    Unmarshaler

	Context context.Context
}

type RegisterOption

type RegisterOption func(*RegisterOptions)

func RegisterTTL

func RegisterTTL(ttl time.Duration) RegisterOption

type RegisterOptions

type RegisterOptions struct {
	TTL time.Duration
}

type Registry

type Registry interface {
	Getter
	Init(...Option)
	Options() Options
	Register(Node, ...RegisterOption) error
	Deregister(Node) error
	Watch(context.Context, string) (Watcher, error)
	String() string
}

type Unmarshaler

type Unmarshaler func([]byte) (Node, error)

type Watcher

type Watcher interface {
	Next() (*Event, error)
	Stop()
}

Jump to

Keyboard shortcuts

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