registry

package
v0.0.0-...-1d97044 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	Name     string            `json:"name"`
	Request  *Value            `json:"request"`
	Response *Value            `json:"response"`
	Metadata map[string]string `json:"metadata"`
}

type Event

type Event struct {
	// Id is registry id
	Id string
	// Type defines type of event
	Type EventType
	// Timestamp is event timestamp
	Timestamp time.Time
	// Service is registry service
	Service *Service
}

Event is registry event

type EventType

type EventType int32

EventType x ENUM( Create // Create is emitted when a new service is registered Delete // Delete is emitted when an existing service is deregsitered Update // Update is emitted when an existing servicec is updated Unknown )

const (
	// EventTypeCreate is a EventType of type Create
	// Create is emitted when a new service is registered
	EventTypeCreate EventType = iota
	// EventTypeDelete is a EventType of type Delete
	// Delete is emitted when an existing service is deregsitered
	EventTypeDelete
	// EventTypeUpdate is a EventType of type Update
	// Update is emitted when an existing servicec is updated
	EventTypeUpdate
	// EventTypeUnknown is a EventType of type Unknown
	EventTypeUnknown
)

func ParseMessage

func ParseMessage(name string) (EventType, *errorAVA.Error)

ParseMessage attempts to convert a string to a Message

func (EventType) MarshalText

func (x EventType) MarshalText() ([]byte, *errorAVA.Error)

MarshalText implements the text marshaller method

func (EventType) String

func (x EventType) String() string

String implements the Stringer interface.

func (EventType) UnmarshalText

func (x EventType) UnmarshalText(text []byte) (EventType, *errorAVA.Error)

UnmarshalText implements the text unmarshaller method

type Node

type Node struct {
	Id       string            `json:"id"`
	Address  string            `json:"address"`
	Metadata map[string]string `json:"metadata"`
}

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 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 RegistryI

type RegistryI interface {
	Init(...Option) *errorAVA.Error
	Options() Options
	Register(*Service, ...RegisterOption) *errorAVA.Error
	Deregister(*Service) *errorAVA.Error
	GetService(string) ([]*Service, *errorAVA.Error)
	ListServices() ([]*Service, *errorAVA.Error)
	Watch(...WatchOption) (WatcherI, *errorAVA.Error)
	String() string
}

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

type Result

type Result struct {
	Action  string
	Service *Service
}

Result is returned by a call to Next on the watcher. Actions can be create, update, delete

type Service

type Service struct {
	Name      string            `json:"name"`
	Version   string            `json:"version"`
	Metadata  map[string]string `json:"metadata"`
	Endpoints []*Endpoint       `json:"endpoints"`
	Nodes     []*Node           `json:"nodes"`
}

type Value

type Value struct {
	Name   string   `json:"name"`
	Type   string   `json:"type"`
	Values []*Value `json:"values"`
}

type WatchOption

type WatchOption func(*WatchOptions)

func WatchService

func WatchService(name string) WatchOption

Watch 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 WatcherI

type WatcherI interface {
	// Next is a blocking call
	Next() (*Result, *errorAVA.Error)
	Stop()
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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