routing

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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 EndpointService interface {
	GetIdentity(endpoint string, pkID []byte) (view.Identity, error)
	GetResolver(ctx context.Context, party view.Identity) (*endpoint.Resolver, error)
}

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

type IDRouter

type IDRouter interface {
	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

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)

Jump to

Keyboard shortcuts

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