peers

package
v0.22.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

+kubebuilder:validation:Optional

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterPeerDiscoveryService added in v0.2.1

func RegisterPeerDiscoveryService(server *grpc.Server, pd *PeerDiscovery)

RegisterPeerDiscoveryService registers a service for peer discovery.

Types

type Constructor

type Constructor struct {
	ConfigKey     string
	DefaultConfig 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, watchers PeerWatchers) (*PeerDiscovery, error)

NewPeerDiscovery creates a new PeerDiscovery.

func (*PeerDiscovery) DeregisterSelf added in v0.2.1

func (pd *PeerDiscovery) DeregisterSelf(ctx context.Context) error

DeregisterSelf deregisters self from etcd.

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) RegisterSelf added in v0.2.1

func (pd *PeerDiscovery) RegisterSelf(ctx context.Context, advertiseAddr string) error

RegisterSelf registers self to etcd.

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 PeerDiscoveryConfig

type PeerDiscoveryConfig struct {
	// Network address of aperture server to advertise to peers - this address should be reachable from other agents. Used for nat traversal when provided.
	AdvertisementAddr string `json:"advertisement_addr" validate:"omitempty,hostname_port"`
}

PeerDiscoveryConfig holds configuration for Agent Peer Discovery. swagger:model +kubebuilder:object:generate=true

func (*PeerDiscoveryConfig) DeepCopy added in v0.1.2

func (in *PeerDiscoveryConfig) DeepCopy() *PeerDiscoveryConfig

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PeerDiscoveryConfig.

func (*PeerDiscoveryConfig) DeepCopyInto added in v0.1.2

func (in *PeerDiscoveryConfig) DeepCopyInto(out *PeerDiscoveryConfig)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PeerDiscoveryIn

type PeerDiscoveryIn struct {
	fx.In
	Lifecycle      fx.Lifecycle
	Unmarshaller   config.Unmarshaller
	Client         *etcdclient.Client
	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 added in v0.2.1

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

PeerDiscoveryService is the implementation of peersv1.PeerDiscoveryServiceServer interface.

func (*PeerDiscoveryService) GetPeer added in v0.2.1

GetPeer returns a peer.

func (*PeerDiscoveryService) GetPeers added in v0.2.1

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.

Jump to

Keyboard shortcuts

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