Documentation
¶
Index ¶
- func NewServiceDiscovery(router IDRouter, strategy EndpointSelector) *serviceDiscovery
- type EndpointSelector
- type EndpointService
- type EndpointServiceIDRouter
- type IDRouter
- type LabelResolver
- type LabelRouter
- type ResolvedStaticIDRouter
- type SelectionStrategy
- type ServiceDiscovery
- type StaticIDRouter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewServiceDiscovery ¶
func NewServiceDiscovery(router IDRouter, strategy EndpointSelector) *serviceDiscovery
Types ¶
type EndpointSelector ¶
type EndpointSelector = SelectionStrategy[host2.PeerIPAddress]
type EndpointService ¶ added in v0.4.1
type EndpointServiceIDRouter ¶ added in v0.4.1
type EndpointServiceIDRouter struct {
// contains filtered or unexported fields
}
EndpointServiceIDRouter resolves the IP addresses using the resolvers of the endpoint service.
func NewEndpointServiceIDRouter ¶
func NewEndpointServiceIDRouter(es EndpointService) *EndpointServiceIDRouter
func (*EndpointServiceIDRouter) Lookup ¶ added in v0.4.1
func (r *EndpointServiceIDRouter) Lookup(id host2.PeerID) ([]host2.PeerIPAddress, bool)
type LabelResolver ¶ added in v0.4.1
type LabelResolver struct {
// contains filtered or unexported fields
}
LabelResolver resolves a peer ID into its label
type LabelRouter ¶
type LabelRouter interface {
Lookup(label string) ([]host2.PeerIPAddress, bool)
}
LabelRouter is an interface to the service discovery based on the label of a peer
type ResolvedStaticIDRouter ¶ added in v0.4.1
type ResolvedStaticIDRouter struct {
// contains filtered or unexported fields
}
ResolvedStaticIDRouter resolves the address of a peer ID by finding the label with the help of the endpoint service, and then using a LabelResolver to find the IPs of the peers that share this label.
func NewResolvedStaticIDRouter ¶
func NewResolvedStaticIDRouter(configPath string, es EndpointService) (*ResolvedStaticIDRouter, error)
func (*ResolvedStaticIDRouter) Lookup ¶ added in v0.4.1
func (r *ResolvedStaticIDRouter) Lookup(id host2.PeerID) ([]host2.PeerIPAddress, bool)
type SelectionStrategy ¶
type SelectionStrategy[T any] func([]T) T
func AlwaysFirst ¶
func AlwaysFirst[T any]() SelectionStrategy[T]
func AlwaysLast ¶
func AlwaysLast[T any]() SelectionStrategy[T]
func Random ¶
func Random[T any]() SelectionStrategy[T]
func RoundRobin ¶
func RoundRobin[T any]() SelectionStrategy[T]
type ServiceDiscovery ¶
type ServiceDiscovery interface {
LookupAll(id host2.PeerID) ([]host2.PeerIPAddress, bool)
Lookup(id host2.PeerID) host2.PeerIPAddress
}
ServiceDiscovery is the interface that resolves the IP addresses given the ID of a peer
type StaticIDRouter ¶
type StaticIDRouter map[host2.PeerID][]host2.PeerIPAddress
StaticIDRouter is a map implementation that contains all hard-coded routes
func (StaticIDRouter) Lookup ¶
func (r StaticIDRouter) Lookup(id string) ([]host2.PeerIPAddress, bool)
func (StaticIDRouter) ReverseLookup ¶
func (r StaticIDRouter) ReverseLookup(ipAddress host2.PeerIPAddress) (host2.PeerID, bool)
Click to show internal directories.
Click to hide internal directories.