routing

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const KeyTTL = 10 * time.Minute

Variables

This section is empty.

Functions

This section is empty.

Types

type Bootstrapper

type Bootstrapper interface {
	// Run starts the bootstrap process. Should be blocking even if not needed.
	Run(ctx context.Context, id string) error
	// Get returns a list of peers that should be used as bootstrap nodes.
	// If the peer ID is empty it will be resolved.
	// If the address is missing a port the P2P router port will be used.
	Get(ctx context.Context) ([]peer.AddrInfo, error)
}

Bootstrapper resolves peers to bootstrap with for the P2P router.

type DNSBootstrapper added in v0.0.29

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

func NewDNSBootstrapper added in v0.0.29

func NewDNSBootstrapper(host string, limit int) *DNSBootstrapper

func (*DNSBootstrapper) Get added in v0.0.29

func (b *DNSBootstrapper) Get(ctx context.Context) ([]peer.AddrInfo, error)

func (*DNSBootstrapper) Run added in v0.0.29

func (b *DNSBootstrapper) Run(ctx context.Context, id string) error

type HTTPBootstrapper

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

func NewHTTPBootstrapper

func NewHTTPBootstrapper(addr, peer string) *HTTPBootstrapper

func (*HTTPBootstrapper) Get

func (bs *HTTPBootstrapper) Get(ctx context.Context) ([]peer.AddrInfo, error)

func (*HTTPBootstrapper) Run

func (bs *HTTPBootstrapper) Run(ctx context.Context, id string) error

type KubernetesBootstrapper

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

func NewKubernetesBootstrapper

func NewKubernetesBootstrapper(cs kubernetes.Interface, namespace, name string) *KubernetesBootstrapper

func (*KubernetesBootstrapper) Get

func (*KubernetesBootstrapper) Run

type MemoryRouter added in v0.0.23

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

func NewMemoryRouter added in v0.0.23

func NewMemoryRouter(resolver map[string][]netip.AddrPort, self netip.AddrPort) *MemoryRouter

func (*MemoryRouter) Add added in v0.0.23

func (m *MemoryRouter) Add(key string, ap netip.AddrPort)

func (*MemoryRouter) Advertise added in v0.0.23

func (m *MemoryRouter) Advertise(ctx context.Context, keys []string) error

func (*MemoryRouter) Lookup added in v0.0.23

func (m *MemoryRouter) Lookup(key string) ([]netip.AddrPort, bool)

func (*MemoryRouter) Ready added in v0.0.23

func (m *MemoryRouter) Ready(ctx context.Context) (bool, error)

func (*MemoryRouter) Resolve added in v0.0.23

func (m *MemoryRouter) Resolve(ctx context.Context, key string, allowSelf bool, count int) (<-chan netip.AddrPort, error)

type P2PRouter

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

func NewP2PRouter

func NewP2PRouter(ctx context.Context, addr string, bs Bootstrapper, registryPortStr string, opts ...libp2p.Option) (*P2PRouter, error)

func (*P2PRouter) Advertise

func (r *P2PRouter) Advertise(ctx context.Context, keys []string) error

func (*P2PRouter) Ready

func (r *P2PRouter) Ready(ctx context.Context) (bool, error)

func (*P2PRouter) Resolve

func (r *P2PRouter) Resolve(ctx context.Context, key string, allowSelf bool, count int) (<-chan netip.AddrPort, error)

func (*P2PRouter) Run

func (r *P2PRouter) Run(ctx context.Context) error

type Router

type Router interface {
	// Ready returns true when the router is ready.
	Ready(ctx context.Context) (bool, error)
	// Resolve asynchronously discovers addresses that can serve the content defined by the give key.
	Resolve(ctx context.Context, key string, allowSelf bool, count int) (<-chan netip.AddrPort, error)
	// Advertise broadcasts that the current router can serve the content.
	Advertise(ctx context.Context, keys []string) error
}

Router implements the discovery of content.

type StaticBootstrapper added in v0.0.29

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

func NewStaticBootstrapper added in v0.0.29

func NewStaticBootstrapper() *StaticBootstrapper

func (*StaticBootstrapper) Get added in v0.0.29

func (*StaticBootstrapper) Run added in v0.0.29

func (b *StaticBootstrapper) Run(ctx context.Context, id string) error

func (*StaticBootstrapper) SetPeers added in v0.0.30

func (b *StaticBootstrapper) SetPeers(peers []peer.AddrInfo)

Jump to

Keyboard shortcuts

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