registry

package
v0.0.0-...-9d38f52 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilEtcd when etcd client is nil.
	ErrNilEtcd = errors.New("nil etcd")
	// ErrFailedInsert when etcd returns no error for a key
	// insert but the success flag is false.
	ErrFailedInsert = errors.New("failed insert")
	// ErrFailedDelete when etcd returns no error for a key
	// delete but the success flag is false.
	ErrFailedDelete = errors.New("failed delete")
	// ErrAlreadyDeleted when the given entry already exists.
	ErrAlreadyDeleted = errors.New("already deleted")
	// ErrAlreadyInserted when the given entry already exists.
	ErrAlreadyInserted = errors.New("already inserted")
	// ErrZeroValues when no value is found.
	ErrZeroValues = errors.New("zero values")
	// ErrMultipleValues when multiple values are found under one
	// key, meaning that the key is not a key but a prefix.
	ErrMultipleValues = errors.New("multiple values")
	// ErrWatchClosedUnexpectedly when a watch closes and no error
	// is reported by the etcd client.
	ErrWatchClosedUnexpectedly = errors.New("watch closed unexpectedly")
)

Functions

This section is empty.

Types

type EventType

type EventType int

EventType of a watch event.

const (
	// Error in the watch.
	Error EventType = 0
	// Delete of a key and its value.
	Delete EventType = 1
	// Modify of a key's value.
	Modify EventType = 2
	// Create of a key and its value.
	Create EventType = 3
)

type Registration

type Registration struct {
	Type   string `json:"type"`
	Name   string `json:"name"`
	Wanted string `json:"wanted"`
	Config string `json:"config"`
}

Registration information.

func (*Registration) String

func (r *Registration) String() string

String descritpion of registration.

func (*Registration) UnmarshalConfig

func (r *Registration) UnmarshalConfig() ([]byte, error)

UnmarshalConfig which has a base type of []byte but is marshalled as a base64 string.

type Registry

type Registry struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

Registry for discovery.

func New

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

New Registry.

func (*Registry) Delete

func (rr *Registry) Delete(ctx context.Context, graphType, graphName string) error

Delete the graph entry.

func (*Registry) Insert

func (rr *Registry) Insert(ctx context.Context, graphType, graphName string, state State, config []byte) error

Insert the graph entry.

func (*Registry) Select

func (rr *Registry) Select(ctx context.Context, graphType, graphName string) (*Registration, error)

Select the graph entry.

func (*Registry) SetWanted

func (rr *Registry) SetWanted(ctx context.Context, graphType, graphName string, state State) error

SetWanted state of the graph under the given namespace.

func (*Registry) Watch

func (rr *Registry) Watch(ctx context.Context) ([]*WatchEvent, <-chan *WatchEvent, error)

Watch a prefix in the registry.

type State

type State string

State of the graph, either wanted or actual.

const (
	// Unknown state.
	Unknown State = "unknown"
	// Running state.
	Running State = "running"
	// Stopping state, graceful stop.
	Stopping State = "stopping"
	// Terminating state, drop everything on the floor stop.
	Terminating State = "terminating"
)

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