registry

package
v1.10.15 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNodeNotFound = errors.New("endpoint not found")
)

Functions

This section is empty.

Types

type ClusterMember

type ClusterMember struct {
	// contains filtered or unexported fields
}

func (*ClusterMember) Deregister

func (c *ClusterMember) Deregister(ctx context.Context) error

func (*ClusterMember) GetWeight

func (c *ClusterMember) GetWeight() uint32

func (*ClusterMember) ID

func (c *ClusterMember) ID() string

func (*ClusterMember) Register

func (c *ClusterMember) Register(ctx context.Context) error

func (*ClusterMember) SetWeight

func (c *ClusterMember) SetWeight(weight uint32) error

type ClusteredRegistry

type ClusteredRegistry struct {
	// contains filtered or unexported fields
}

func NewClusteredRegistry

func NewClusteredRegistry(cluster cluster.Cluster) *ClusteredRegistry

func (*ClusteredRegistry) Close

func (c *ClusteredRegistry) Close()

func (*ClusteredRegistry) GetNode

func (c *ClusteredRegistry) GetNode(id string) (*NodeDescriptor, error)

func (*ClusteredRegistry) GetNodes

func (c *ClusteredRegistry) GetNodes() ([]*NodeDescriptor, error)

func (*ClusteredRegistry) NewNode

func (c *ClusteredRegistry) NewNode(addr string) (Node, error)

func (*ClusteredRegistry) Owner

func (c *ClusteredRegistry) Owner(token []byte) string

func (*ClusteredRegistry) WatchNodes

func (c *ClusteredRegistry) WatchNodes(ctx context.Context) <-chan []*NodeDescriptor

type Node

type Node interface {
	// ID returns the Nodes ID.
	ID() string

	// Register registers the endpoint with zero weighting.
	//
	// The endpoint should be visible to other processes after registering.
	Register(ctx context.Context) error

	// Deregister removes the endpoint from the registry.
	//
	// The endpoint should not be visible to other processes after de-registering.
	Deregister(ctx context.Context) error

	// SetWeight sets the weight (without delay) of the endpoint.
	SetWeight(weight uint32) error

	// GetWeight returns the current weight of the endpoint.
	GetWeight() uint32
}

type NodeAddress

type NodeAddress struct {
	IP   string `json:"ip"`
	Port int    `json:"port"`
}

type NodeDescriptor

type NodeDescriptor struct {
	ID      string      `json:"id"`
	Address NodeAddress `json:"address"`
	Weight  uint32      `json:"weight,omitempty"`
}

type Observer

type Observer interface {
	Reader
	Watcher
}

type Reader

type Reader interface {
	// GetNode returns the node descriptor corresponding to the id.
	//
	// If there is no endpoint registered with the provided ID, ErrNodeNotFound is returned.
	GetNode(id string) (*NodeDescriptor, error)

	// GetNodes returns the set of services that are currently registered.
	GetNodes() ([]*NodeDescriptor, error)

	// Owner returns the Node.ID of the node that owns the specified token.
	//
	// If no owner exists, an empty string is returned.
	Owner(token []byte) string
}

type Watcher

type Watcher interface {
	// WatchNodes returns a channel that emits the entire set of nodes when
	// a change occurs. The channel is closed when the observer is closed,
	// or when the provided context is cancelled.
	WatchNodes(ctx context.Context) <-chan []*NodeDescriptor
}

Jump to

Keyboard shortcuts

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