Documentation ¶
Index ¶
- func RegisterPeerDiscoveryService(server *grpc.Server, pd *PeerDiscovery)
- type Constructor
- type PeerDiscovery
- func (pd *PeerDiscovery) DeregisterSelf(ctx context.Context) error
- func (pd *PeerDiscovery) DeregisterService(name string)
- func (pd *PeerDiscovery) GetPeer(address string) (*peersv1.Peer, error)
- func (pd *PeerDiscovery) GetPeerKeys() []string
- func (pd *PeerDiscovery) GetPeers() *peersv1.Peers
- func (pd *PeerDiscovery) RegisterSelf(ctx context.Context, advertiseAddr string) error
- func (pd *PeerDiscovery) RegisterService(name string, address string)
- func (pd *PeerDiscovery) Start() error
- func (pd *PeerDiscovery) Stop() error
- type PeerDiscoveryIn
- type PeerDiscoveryPrefix
- type PeerDiscoveryService
- type PeerWatcher
- type PeerWatchers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterPeerDiscoveryService ¶
func RegisterPeerDiscoveryService(server *grpc.Server, pd *PeerDiscovery)
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) DeregisterSelf ¶
func (pd *PeerDiscovery) DeregisterSelf(ctx context.Context) error
DeregisterSelf deregisters self from etcd.
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) RegisterSelf ¶
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.
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 ¶
func (svc *PeerDiscoveryService) GetPeer(ctx context.Context, req *peersv1.PeerRequest) (*peersv1.Peer, error)
GetPeer returns a peer.
type PeerWatcher ¶
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.