peers

package
v2.20.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterPeerDiscoveryService

func RegisterPeerDiscoveryService(in RegisterPeersServiceIn)

RegisterPeerDiscoveryService registers a service for peer discovery.

Types

type Constructor

type Constructor struct {
	ConfigKey     string
	DefaultConfig peersconfig.PeerDiscoveryConfig
	Service       string
}

Constructor holds fields to create and configure PeerDiscovery.

func (Constructor) Module

func (constructor Constructor) Module() fx.Option

Module is a fx module that creates peer directory and provides peer discovery.

type PeerDiscovery

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

PeerDiscovery holds fields to manage peer discovery.

func NewPeerDiscovery

func NewPeerDiscovery(
	prefix string,
	client *etcdclient.Client,
	sessionScopedKV *etcdclient.SessionScopedKV,
	watchers PeerWatchers,
) (*PeerDiscovery, error)

NewPeerDiscovery creates a new PeerDiscovery.

func (*PeerDiscovery) DeregisterService added in v2.2.0

func (pd *PeerDiscovery) DeregisterService(name string)

DeregisterService accepts a name and removes the service from the list of services in PeerDiscovery.

func (*PeerDiscovery) GetPeer

func (pd *PeerDiscovery) GetPeer(address string) (*peersv1.Peer, error)

GetPeer returns the peer info in the PeerDiscovery with the given address.

func (*PeerDiscovery) GetPeerKeys

func (pd *PeerDiscovery) GetPeerKeys() []string

GetPeerKeys returns all the peer keys that are added to PeerDiscovery.

func (*PeerDiscovery) GetPeers

func (pd *PeerDiscovery) GetPeers() *peersv1.Peers

GetPeers returns all the peer info that are added to PeerDiscovery.

func (*PeerDiscovery) RegisterService

func (pd *PeerDiscovery) RegisterService(name string, address string)

RegisterService accepts a name, full address (host:port) and adds to the list of services in PeerDiscovery.

func (*PeerDiscovery) Start

func (pd *PeerDiscovery) Start() error

Start starts peer discovery.

func (*PeerDiscovery) Stop

func (pd *PeerDiscovery) Stop() error

Stop stops peer discovery.

type PeerDiscoveryIn

type PeerDiscoveryIn struct {
	fx.In
	Lifecycle       fx.Lifecycle
	Unmarshaller    config.Unmarshaller
	Client          *etcdclient.Client
	SessionScopedKV *etcdclient.SessionScopedKV
	Listener        *listener.Listener
	StatusRegistry  status.Registry
	Prefix          PeerDiscoveryPrefix
	Watchers        PeerWatchers `group:"peer-watchers"`
}

PeerDiscoveryIn holds parameters for newPeerDiscovery.

type PeerDiscoveryPrefix

type PeerDiscoveryPrefix string

PeerDiscoveryPrefix is the prefix for peer discovery service.

type PeerDiscoveryService

type PeerDiscoveryService struct {
	peersv1.UnimplementedPeerDiscoveryServiceServer
	// contains filtered or unexported fields
}

PeerDiscoveryService is the implementation of peersv1.PeerDiscoveryServiceServer interface.

func (*PeerDiscoveryService) GetPeer

GetPeer returns a peer.

func (*PeerDiscoveryService) GetPeers

func (svc *PeerDiscoveryService) GetPeers(ctx context.Context, _ *emptypb.Empty) (*peersv1.Peers, error)

GetPeers returns all peers.

type PeerWatcher

type PeerWatcher interface {
	OnPeerAdded(peer *peersv1.Peer)
	OnPeerRemoved(peer *peersv1.Peer)
}

PeerWatcher is used for tracking changes to peers.

type PeerWatchers

type PeerWatchers []PeerWatcher

PeerWatchers is a collection of PeerWatcher.

func (PeerWatchers) OnPeerAdded

func (pw PeerWatchers) OnPeerAdded(peer *peersv1.Peer)

OnPeerAdded calls OnPeerAdded for each PeerWatcher in the collection.

func (PeerWatchers) OnPeerRemoved

func (pw PeerWatchers) OnPeerRemoved(peer *peersv1.Peer)

OnPeerRemoved calls OnPeerRemoved for each PeerWatcher in the collection.

type RegisterPeersServiceIn added in v2.16.0

type RegisterPeersServiceIn struct {
	fx.In
	Server        *grpc.Server `name:"default"`
	PeerDiscovery *PeerDiscovery
}

RegisterPeersServiceIn bundles and annotates parameters.

Directories

Path Synopsis
+kubebuilder:validation:Optional
+kubebuilder:validation:Optional

Jump to

Keyboard shortcuts

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