presence

package
v0.0.0-...-dd72184 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(ctx context.Context, session *concurrency.Session, name string, regs ...EndpointRegistration) ([]*pb.Endpoint, error)

Register one or more endpoints. The entries will be kept alive for the lifetime of the Session.

Types

type EndpointRegistration

type EndpointRegistration struct {
	Prefix string
	Addrs  []net.IP
	Port   int
}

An EndpointRegistration specifies parameters for a presence endpoint registration. Addresses without ports will use the DefaultPort.

func NewRegistration

func NewRegistration(prefix string, addrs []net.IP, port int) EndpointRegistration

NewRegistration creates a new EndpointRegistration.

type EndpointSet

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

EndpointSet is a container of Endpoints that is synchronizable with the contents of a presence tree as created by Register().

Note that while an Endpoint might appear multiple times in the presence registry (before a stale lease expires, for instance), we deduplicate endpoints based on their Name.

func WatchEndpoints

func WatchEndpoints(ctx context.Context, cli *clientv3.Client, prefix string) *EndpointSet

func WatchEndpointsReady

func WatchEndpointsReady(ctx context.Context, cli *clientv3.Client, prefix string) (*EndpointSet, <-chan struct{})

func (*EndpointSet) Delete

func (n *EndpointSet) Delete(k string)

Delete implements the watcher.Watchable interface.

func (*EndpointSet) Endpoints

func (n *EndpointSet) Endpoints() []*pb.Endpoint

Endpoints returns all registered endpoints.

func (*EndpointSet) GetEndpoint

func (n *EndpointSet) GetEndpoint(name string) (*pb.Endpoint, bool)

GetEndpoint returns a specific endpoint by host name.

func (*EndpointSet) RandomEndpoint

func (n *EndpointSet) RandomEndpoint() *pb.Endpoint

RandomEndpoint returns a randomly selected Endpoint (or nil, if none are available).

func (*EndpointSet) RandomEndpointExcluding

func (n *EndpointSet) RandomEndpointExcluding(name string) *pb.Endpoint

RandomEndpointExcluding returns a randomly selected Endpoint except for the named one (or nil, if none are available).

func (*EndpointSet) Reset

func (n *EndpointSet) Reset(m map[string]string)

Reset implements the watcher.Watchable interface.

func (*EndpointSet) Set

func (n *EndpointSet) Set(k, v string)

Set implements the watcher.Watchable interface.

Jump to

Keyboard shortcuts

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