registry

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 12 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Flag pflag.FlagSet for registry
	Flag = pflag.NewFlagSet("registry", pflag.ExitOnError)

	DefaultRegistry        Registry
	DefaultRegistryTimeout = time.Second * 10
	// DefaultNamespace the default value of namespace
	DefaultNamespace = "vine"

	// ErrNotFound not found error when GetService is called
	ErrNotFound = errors.New("service not found")
	// ErrWatcherStopped watcher stopped error when watcher is stopped
	ErrWatcherStopped = errors.New("watcher stopped")
)
View Source
var (
	ErrInvalidLengthRegistry        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowRegistry          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupRegistry = fmt.Errorf("proto: unexpected end of group")
)

Functions

func Deregister

func Deregister(ctx context.Context, s *Service) error

Deregister a service node

func Register

func Register(ctx context.Context, s *Service, opts ...RegisterOption) error

Register a service node. Additionally supply options such as TTL.

func String

func String() string

Types

type DeregisterOption

type DeregisterOption func(*DeregisterOptions)

func DeregisterNamespace added in v1.6.6

func DeregisterNamespace(ns string) DeregisterOption

type DeregisterOptions

type DeregisterOptions struct {
	Namespace string
}

type Endpoint added in v0.23.0

type Endpoint struct {
	Name     string            `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Request  *Value            `protobuf:"bytes,2,opt,name=request,proto3" json:"request,omitempty"`
	Response *Value            `protobuf:"bytes,3,opt,name=response,proto3" json:"response,omitempty"`
	Metadata map[string]string `` /* 157-byte string literal not displayed */
}

Endpoint is a endpoint provided by a service

func (*Endpoint) DeepCopyInto added in v1.5.6

func (in *Endpoint) DeepCopyInto(out *Endpoint)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Endpoint) Descriptor added in v1.5.6

func (*Endpoint) Descriptor() ([]byte, []int)

func (*Endpoint) Marshal added in v1.5.6

func (m *Endpoint) Marshal() (dAtA []byte, err error)

func (*Endpoint) MarshalTo added in v1.5.6

func (m *Endpoint) MarshalTo(dAtA []byte) (int, error)

func (*Endpoint) MarshalToSizedBuffer added in v1.5.6

func (m *Endpoint) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Endpoint) ProtoMessage added in v1.5.6

func (*Endpoint) ProtoMessage()

func (*Endpoint) Reset added in v1.5.6

func (m *Endpoint) Reset()

func (*Endpoint) String added in v1.5.6

func (m *Endpoint) String() string

func (*Endpoint) Unmarshal added in v1.5.6

func (m *Endpoint) Unmarshal(dAtA []byte) error

func (*Endpoint) XSize added in v1.5.6

func (m *Endpoint) XSize() (n int)

func (*Endpoint) XXX_DiscardUnknown added in v1.5.6

func (m *Endpoint) XXX_DiscardUnknown()

func (*Endpoint) XXX_Marshal added in v1.5.6

func (m *Endpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Endpoint) XXX_Merge added in v1.5.6

func (m *Endpoint) XXX_Merge(src proto.Message)

func (*Endpoint) XXX_Size added in v1.5.6

func (m *Endpoint) XXX_Size() int

func (*Endpoint) XXX_Unmarshal added in v1.5.6

func (m *Endpoint) XXX_Unmarshal(b []byte) error

type Event added in v0.23.0

type Event struct {
	// Event Id
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// type of event
	Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	// unix timestamp of event
	Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// service entry
	Service *Service `protobuf:"bytes,4,opt,name=service,proto3" json:"service,omitempty"`
}

Event is registry event

func (*Event) DeepCopyInto added in v1.5.6

func (in *Event) DeepCopyInto(out *Event)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Event) Descriptor added in v1.5.6

func (*Event) Descriptor() ([]byte, []int)

func (*Event) Marshal added in v1.5.6

func (m *Event) Marshal() (dAtA []byte, err error)

func (*Event) MarshalTo added in v1.5.6

func (m *Event) MarshalTo(dAtA []byte) (int, error)

func (*Event) MarshalToSizedBuffer added in v1.5.6

func (m *Event) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Event) ProtoMessage added in v1.5.6

func (*Event) ProtoMessage()

func (*Event) Reset added in v1.5.6

func (m *Event) Reset()

func (*Event) String added in v1.5.6

func (m *Event) String() string

func (*Event) Unmarshal added in v1.5.6

func (m *Event) Unmarshal(dAtA []byte) error

func (*Event) XSize added in v1.5.6

func (m *Event) XSize() (n int)

func (*Event) XXX_DiscardUnknown added in v1.5.6

func (m *Event) XXX_DiscardUnknown()

func (*Event) XXX_Marshal added in v1.5.6

func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Event) XXX_Merge added in v1.5.6

func (m *Event) XXX_Merge(src proto.Message)

func (*Event) XXX_Size added in v1.5.6

func (m *Event) XXX_Size() int

func (*Event) XXX_Unmarshal added in v1.5.6

func (m *Event) XXX_Unmarshal(b []byte) error

type GetOption

type GetOption func(*GetOptions)

func GetNamespace added in v1.6.6

func GetNamespace(ns string) GetOption

type GetOptions

type GetOptions struct {
	Namespace string
}

type ListOption

type ListOption func(*ListOptions)

func ListNamespace added in v1.6.6

func ListNamespace(ns string) ListOption

type ListOptions

type ListOptions struct {
	Namespace string
}

type Node added in v0.23.0

type Node struct {
	Id       string            `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Address  string            `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
	Port     int64             `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"`
	Metadata map[string]string `` /* 157-byte string literal not displayed */
}

Node represents the node the service is on

func (*Node) DeepCopyInto added in v1.5.6

func (in *Node) DeepCopyInto(out *Node)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Node) Descriptor added in v1.5.6

func (*Node) Descriptor() ([]byte, []int)

func (*Node) Marshal added in v1.5.6

func (m *Node) Marshal() (dAtA []byte, err error)

func (*Node) MarshalTo added in v1.5.6

func (m *Node) MarshalTo(dAtA []byte) (int, error)

func (*Node) MarshalToSizedBuffer added in v1.5.6

func (m *Node) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Node) ProtoMessage added in v1.5.6

func (*Node) ProtoMessage()

func (*Node) Reset added in v1.5.6

func (m *Node) Reset()

func (*Node) String added in v1.5.6

func (m *Node) String() string

func (*Node) Unmarshal added in v1.5.6

func (m *Node) Unmarshal(dAtA []byte) error

func (*Node) XSize added in v1.5.6

func (m *Node) XSize() (n int)

func (*Node) XXX_DiscardUnknown added in v1.5.6

func (m *Node) XXX_DiscardUnknown()

func (*Node) XXX_Marshal added in v1.5.6

func (m *Node) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Node) XXX_Merge added in v1.5.6

func (m *Node) XXX_Merge(src proto.Message)

func (*Node) XXX_Size added in v1.5.6

func (m *Node) XXX_Size() int

func (*Node) XXX_Unmarshal added in v1.5.6

func (m *Node) XXX_Unmarshal(b []byte) error

type OpenAPIOption

type OpenAPIOption func(*OpenAPIOptions)

type OpenAPIOptions

type OpenAPIOptions struct {
}

type Option

type Option func(*Options)

func Addrs

func Addrs(addrs ...string) Option

Addrs is the registry addresses to use

func Namespace added in v1.6.6

func Namespace(ns string) Option

func Secure

func Secure(b bool) Option

Secure communication with the registry

func TLSConfig

func TLSConfig(t *tls.Config) Option

TLSConfig Specify TLS Config

func Timeout

func Timeout(t time.Duration) Option

type Options

type Options struct {
	Addrs     []string
	Namespace 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
}

func NewOptions added in v1.6.6

func NewOptions(opts ...Option) Options

type RegisterOption

type RegisterOption func(*RegisterOptions)

func RegisterNamespace added in v1.6.6

func RegisterNamespace(ns string) RegisterOption

func RegisterTTL

func RegisterTTL(t time.Duration) RegisterOption

type RegisterOptions

type RegisterOptions struct {
	TTL       time.Duration
	Namespace string
}

type Registry

type Registry interface {
	Init(...Option) error
	Options() Options
	Register(context.Context, *Service, ...RegisterOption) error
	Deregister(context.Context, *Service, ...DeregisterOption) error
	GetService(context.Context, string, ...GetOption) ([]*Service, error)
	ListServices(context.Context, ...ListOption) ([]*Service, error)
	Watch(context.Context, ...WatchOption) (Watcher, error)
	String() string
}

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

type Result added in v0.23.0

type Result struct {
	Action    string   `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"`
	Service   *Service `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"`
	Timestamp int64    `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
}

Result is returns by the watcher

func (*Result) DeepCopyInto added in v1.5.6

func (in *Result) DeepCopyInto(out *Result)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Result) Descriptor added in v1.5.6

func (*Result) Descriptor() ([]byte, []int)

func (*Result) Marshal added in v1.5.6

func (m *Result) Marshal() (dAtA []byte, err error)

func (*Result) MarshalTo added in v1.5.6

func (m *Result) MarshalTo(dAtA []byte) (int, error)

func (*Result) MarshalToSizedBuffer added in v1.5.6

func (m *Result) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Result) ProtoMessage added in v1.5.6

func (*Result) ProtoMessage()

func (*Result) Reset added in v1.5.6

func (m *Result) Reset()

func (*Result) String added in v1.5.6

func (m *Result) String() string

func (*Result) Unmarshal added in v1.5.6

func (m *Result) Unmarshal(dAtA []byte) error

func (*Result) XSize added in v1.5.6

func (m *Result) XSize() (n int)

func (*Result) XXX_DiscardUnknown added in v1.5.6

func (m *Result) XXX_DiscardUnknown()

func (*Result) XXX_Marshal added in v1.5.6

func (m *Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Result) XXX_Merge added in v1.5.6

func (m *Result) XXX_Merge(src proto.Message)

func (*Result) XXX_Size added in v1.5.6

func (m *Result) XXX_Size() int

func (*Result) XXX_Unmarshal added in v1.5.6

func (m *Result) XXX_Unmarshal(b []byte) error

type Service added in v0.23.0

type Service struct {
	Name      string            `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Version   string            `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
	Namespace string            `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"`
	Metadata  map[string]string `` /* 157-byte string literal not displayed */
	Endpoints []*Endpoint       `protobuf:"bytes,5,rep,name=endpoints,proto3" json:"endpoints,omitempty"`
	Nodes     []*Node           `protobuf:"bytes,6,rep,name=nodes,proto3" json:"nodes,omitempty"`
	Ttl       int64             `protobuf:"varint,7,opt,name=ttl,proto3" json:"ttl,omitempty"`
}

Service represents a vine service

func GetService

func GetService(ctx context.Context, name string) ([]*Service, error)

GetService retrieve a service. A slice is returned since we separate Name/Version.

func ListServices

func ListServices(ctx context.Context) ([]*Service, error)

ListServices list the services. Only returns service names

func (*Service) DeepCopyInto added in v1.5.6

func (in *Service) DeepCopyInto(out *Service)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Service) Descriptor added in v1.5.6

func (*Service) Descriptor() ([]byte, []int)

func (*Service) Marshal added in v1.5.6

func (m *Service) Marshal() (dAtA []byte, err error)

func (*Service) MarshalTo added in v1.5.6

func (m *Service) MarshalTo(dAtA []byte) (int, error)

func (*Service) MarshalToSizedBuffer added in v1.5.6

func (m *Service) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Service) ProtoMessage added in v1.5.6

func (*Service) ProtoMessage()

func (*Service) Reset added in v1.5.6

func (m *Service) Reset()

func (*Service) String added in v1.5.6

func (m *Service) String() string

func (*Service) Unmarshal added in v1.5.6

func (m *Service) Unmarshal(dAtA []byte) error

func (*Service) XSize added in v1.5.6

func (m *Service) XSize() (n int)

func (*Service) XXX_DiscardUnknown added in v1.5.6

func (m *Service) XXX_DiscardUnknown()

func (*Service) XXX_Marshal added in v1.5.6

func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Service) XXX_Merge added in v1.5.6

func (m *Service) XXX_Merge(src proto.Message)

func (*Service) XXX_Size added in v1.5.6

func (m *Service) XXX_Size() int

func (*Service) XXX_Unmarshal added in v1.5.6

func (m *Service) XXX_Unmarshal(b []byte) error

type Value added in v0.23.0

type Value struct {
	Name   string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Type   string   `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	Values []*Value `protobuf:"bytes,3,rep,name=values,proto3" json:"values,omitempty"`
}

Value is an opaque value for a request or response

func (*Value) DeepCopyInto added in v1.5.6

func (in *Value) DeepCopyInto(out *Value)

DeepCopyInto is an auto-generated deepcopy function, coping the receiver, writing into out. in must be no-nil.

func (*Value) Descriptor added in v1.5.6

func (*Value) Descriptor() ([]byte, []int)

func (*Value) Marshal added in v1.5.6

func (m *Value) Marshal() (dAtA []byte, err error)

func (*Value) MarshalTo added in v1.5.6

func (m *Value) MarshalTo(dAtA []byte) (int, error)

func (*Value) MarshalToSizedBuffer added in v1.5.6

func (m *Value) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Value) ProtoMessage added in v1.5.6

func (*Value) ProtoMessage()

func (*Value) Reset added in v1.5.6

func (m *Value) Reset()

func (*Value) String added in v1.5.6

func (m *Value) String() string

func (*Value) Unmarshal added in v1.5.6

func (m *Value) Unmarshal(dAtA []byte) error

func (*Value) XSize added in v1.5.6

func (m *Value) XSize() (n int)

func (*Value) XXX_DiscardUnknown added in v1.5.6

func (m *Value) XXX_DiscardUnknown()

func (*Value) XXX_Marshal added in v1.5.6

func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Value) XXX_Merge added in v1.5.6

func (m *Value) XXX_Merge(src proto.Message)

func (*Value) XXX_Size added in v1.5.6

func (m *Value) XXX_Size() int

func (*Value) XXX_Unmarshal added in v1.5.6

func (m *Value) XXX_Unmarshal(b []byte) error

type WatchOption

type WatchOption func(*WatchOptions)

func WatchNamespace added in v1.6.6

func WatchNamespace(ns string) WatchOption

func WatchService

func WatchService(name string) WatchOption

WatchService watches a service

type WatchOptions

type WatchOptions struct {
	// Specify a service to watch
	// If blank, the watch is for all services
	Service   string
	Namespace string
}

type Watcher

type Watcher interface {
	// Next is a blocking call
	Next() (*Result, error)
	Stop()
}

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

func Watch

func Watch(ctx context.Context, opts ...WatchOption) (Watcher, error)

Watch returns a watcher which allows you to track updates to the registry.

Directories

Path Synopsis
Package mdns provides a multicast dns registry
Package mdns provides a multicast dns registry
Package memory provides an in-memory registry
Package memory provides an in-memory registry

Jump to

Keyboard shortcuts

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