interfaces

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRoute = errors.New("no route found to handle given request")
View Source
var ErrPeerNoConnection = errors.New("no connection available for the peer")
View Source
var ErrPeeringDown = errors.New("Peering connection not available")
View Source
var ErrUnknownPeer = errors.New("no route to deliver")

Functions

func MsgLogString

func MsgLogString(msg Message) string

Types

type Advertisement *generated.Advertisement

type AdvertisementProvider

type AdvertisementProvider = func(ctx context.Context) (Advertisement, error)

type Forwarder

type Forwarder interface {
	Close(context.Context) error
}

type HTTPForwarder

type HTTPForwarder interface {
	Forwarder
	NewRoundTripper(cfg *config.HTTPIngressConfig) http.RoundTripper
}

type Ingress

type Ingress interface {
	String() string
	Close(ctx context.Context) error
}

type Message

type Message = *generated.PeerMessage

type MessageHandler

type MessageHandler interface {
	Close(ctx context.Context) error
}

type PeeringClient

type PeeringClient interface {
	String() string
	Close(ctx context.Context) error
	Stat() PeeringClientStat
}

type PeeringClientStat

type PeeringClientStat struct {
	PeeringAttempts     uint64
	PeeringConnected    uint64
	HandshakeAttempts   uint64
	HandshakeSucceeded  uint64
	PeerMessageReceived uint64
}

func (*PeeringClientStat) Clone

func (stat *PeeringClientStat) Clone() PeeringClientStat

func (PeeringClientStat) String

func (stat PeeringClientStat) String() string

type PeeringServer

type PeeringServer interface {
	String() string
	Close(ctx context.Context) error

	Port() int
	Stat() PeeringServerStat
}

type PeeringServerStat

type PeeringServerStat struct {
	PeeringConnections  uint64
	HandshakeAttempts   uint64
	HandshakeSucceeded  uint64
	PeerMessageReceived uint64
}

func (*PeeringServerStat) Clone

func (stat *PeeringServerStat) Clone() PeeringServerStat

func (PeeringServerStat) String

func (stat PeeringServerStat) String() string

type PingForwarder

type PingForwarder interface {
	Forwarder

	Ping(ctx context.Context, dest config.NodeID, timeout time.Duration) error
}

type Router

type Router interface {
	// NodeID returns this node itself's ID
	NodeID() config.NodeID

	SetAdvertisementProvider(advFn AdvertisementProvider)
	// Advertisement returns this node's Advertisement (= this node's capability)
	GenerateAdvertisement(ctx context.Context) (Advertisement, error)
	// Update routing based on incoming advertisement
	Update(ctx context.Context, node config.NodeID, ad Advertisement)
	// Route decides destination route
	// Returns ErrNoRoute if no route found
	Route(ctx context.Context, request Message) (config.NodeID, error)

	// Deliver transfer given message or handle that message in this node itself
	Deliver(ctx context.Context, from config.NodeID, dest config.NodeID, msg Message)

	// RegisterSink registers message deliverery route to another node.
	// Given destination must not equal to this node's ID.
	RegisterSink(dest config.NodeID, callback RouterShink) RouterUnregister

	// Listen regisgers callback for incoming messsage.
	// Lisnter will be called for all mesages that destination is this node.
	// All listeners called every time, should close unnesessary listener.
	Listen(callback RouterListener) RouterUnregister

	Close(ctx context.Context) error
}

type RouterListener

type RouterListener = func(ctx context.Context, from config.NodeID, msg Message) error

type RouterShink

type RouterShink = func(context.Context, Message) error

type RouterUnregister

type RouterUnregister = func()

Jump to

Keyboard shortcuts

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