router

package
v1.10.8-rc.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: BSD-3-Clause Imports: 27 Imported by: 18

Documentation

Overview

Package router is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainRouter

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

ChainRouter routes incoming messages from the validator network to the consensus engines that the messages are intended for. Note that consensus engines are uniquely identified by the ID of the chain that they are working on. Invariant: P-chain must be registered before processing any messages

func (*ChainRouter) AddChain

func (cr *ChainRouter) AddChain(ctx context.Context, chain handler.Handler)

AddChain registers the specified chain so that incoming messages can be routed to it

func (*ChainRouter) Benched

func (cr *ChainRouter) Benched(chainID ids.ID, nodeID ids.NodeID)

Benched routes an incoming notification that a validator was benched

func (*ChainRouter) Connected

func (cr *ChainRouter) Connected(nodeID ids.NodeID, nodeVersion *version.Application, subnetID ids.ID)

Connected routes an incoming notification that a validator was just connected

func (*ChainRouter) Disconnected

func (cr *ChainRouter) Disconnected(nodeID ids.NodeID)

Disconnected routes an incoming notification that a validator was connected

func (*ChainRouter) HandleInbound

func (cr *ChainRouter) HandleInbound(ctx context.Context, msg message.InboundMessage)

func (*ChainRouter) HealthCheck

func (cr *ChainRouter) HealthCheck(context.Context) (interface{}, error)

HealthCheck returns results of router health checks. Returns: 1) Information about health check results 2) An error if the health check reports unhealthy

func (*ChainRouter) Initialize

func (cr *ChainRouter) Initialize(
	nodeID ids.NodeID,
	log logging.Logger,
	timeoutManager timeout.Manager,
	closeTimeout time.Duration,
	criticalChains set.Set[ids.ID],
	sybilProtectionEnabled bool,
	trackedSubnets set.Set[ids.ID],
	onFatal func(exitCode int),
	healthConfig HealthConfig,
	metricsNamespace string,
	metricsRegisterer prometheus.Registerer,
) error

Initialize the router.

When this router receives an incoming message, it cancels the timeout in [timeouts] associated with the request that caused the incoming message, if applicable.

func (*ChainRouter) RegisterRequest

func (cr *ChainRouter) RegisterRequest(
	ctx context.Context,
	nodeID ids.NodeID,
	requestingChainID ids.ID,
	respondingChainID ids.ID,
	requestID uint32,
	op message.Op,
	timeoutMsg message.InboundMessage,
	engineType p2p.EngineType,
)

RegisterRequest marks that we should expect to receive a reply for a request issued by [requestingChainID] from the given node's [respondingChainID] and the reply should have the given requestID.

The type of message we expect is [op].

Every registered request must be cleared either by receiving a valid reply and passing it to the appropriate chain or by a timeout. This method registers a timeout that calls such methods if we don't get a reply in time.

func (*ChainRouter) Shutdown

func (cr *ChainRouter) Shutdown(ctx context.Context)

Shutdown shuts down this router

func (*ChainRouter) Unbenched

func (cr *ChainRouter) Unbenched(chainID ids.ID, nodeID ids.NodeID)

Unbenched routes an incoming notification that a validator was just unbenched

type ExternalHandler

type ExternalHandler interface {
	InboundHandler

	Connected(nodeID ids.NodeID, nodeVersion *version.Application, subnetID ids.ID)
	Disconnected(nodeID ids.NodeID)
}

ExternalHandler handles messages from external parties

type HealthConfig

type HealthConfig struct {
	// Reports unhealthy if we drop more than [MaxDropRate] of messages
	MaxDropRate float64 `json:"maxDropRate"`

	// Halflife of averager used to calculate the message drop rate
	// Must be > 0.
	// Larger value --> Drop rate affected less by recent messages
	MaxDropRateHalflife time.Duration `json:"maxDropRateHalflife"`

	// Reports unhealthy if more than this number of requests are outstanding.
	// Must be > 0
	MaxOutstandingRequests int `json:"maxOutstandingRequests"`

	// Reports unhealthy if there is a request outstanding for longer than this
	MaxOutstandingDuration time.Duration `json:"maxOutstandingDuration"`

	// Reports unhealthy if there is at least 1 outstanding not processed
	// before this mark
	MaxRunTimeRequests time.Duration `json:"maxRunTimeRequests"`
}

HealthConfig describes parameters for router health checks.

type InboundHandler

type InboundHandler interface {
	HandleInbound(context.Context, message.InboundMessage)
}

InboundHandler handles inbound messages

type InboundHandlerFunc

type InboundHandlerFunc func(context.Context, message.InboundMessage)

The ExternalRouterFunc type is an adapter to allow the use of ordinary functions as ExternalRouters. If f is a function with the appropriate signature, ExternalRouterFunc(f) is an ExternalRouter that calls f.

func (InboundHandlerFunc) HandleInbound

func (f InboundHandlerFunc) HandleInbound(ctx context.Context, msg message.InboundMessage)

type InternalHandler

type InternalHandler interface {
	benchlist.Benchable

	RegisterRequest(
		ctx context.Context,
		nodeID ids.NodeID,
		sourceChainID ids.ID,
		destinationChainID ids.ID,
		requestID uint32,
		op message.Op,
		failedMsg message.InboundMessage,
		engineType p2p.EngineType,
	)
}

InternalHandler deals with messages internal to this node

type MockRouter added in v1.9.4

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

MockRouter is a mock of Router interface.

func NewMockRouter added in v1.9.4

func NewMockRouter(ctrl *gomock.Controller) *MockRouter

NewMockRouter creates a new mock instance.

func (*MockRouter) AddChain added in v1.9.4

func (m *MockRouter) AddChain(arg0 context.Context, arg1 handler.Handler)

AddChain mocks base method.

func (*MockRouter) Benched added in v1.9.4

func (m *MockRouter) Benched(arg0 ids.ID, arg1 ids.NodeID)

Benched mocks base method.

func (*MockRouter) Connected added in v1.9.4

func (m *MockRouter) Connected(arg0 ids.NodeID, arg1 *version.Application, arg2 ids.ID)

Connected mocks base method.

func (*MockRouter) Disconnected added in v1.9.4

func (m *MockRouter) Disconnected(arg0 ids.NodeID)

Disconnected mocks base method.

func (*MockRouter) EXPECT added in v1.9.4

func (m *MockRouter) EXPECT() *MockRouterMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRouter) HandleInbound added in v1.9.4

func (m *MockRouter) HandleInbound(arg0 context.Context, arg1 message.InboundMessage)

HandleInbound mocks base method.

func (*MockRouter) HealthCheck added in v1.9.4

func (m *MockRouter) HealthCheck(arg0 context.Context) (interface{}, error)

HealthCheck mocks base method.

func (*MockRouter) Initialize added in v1.9.4

func (m *MockRouter) Initialize(arg0 ids.NodeID, arg1 logging.Logger, arg2 timeout.Manager, arg3 time.Duration, arg4 set.Set[ids.ID], arg5 bool, arg6 set.Set[ids.ID], arg7 func(int), arg8 HealthConfig, arg9 string, arg10 prometheus.Registerer) error

Initialize mocks base method.

func (*MockRouter) RegisterRequest added in v1.9.4

func (m *MockRouter) RegisterRequest(arg0 context.Context, arg1 ids.NodeID, arg2, arg3 ids.ID, arg4 uint32, arg5 message.Op, arg6 message.InboundMessage, arg7 p2p.EngineType)

RegisterRequest mocks base method.

func (*MockRouter) Shutdown added in v1.9.4

func (m *MockRouter) Shutdown(arg0 context.Context)

Shutdown mocks base method.

func (*MockRouter) Unbenched added in v1.9.4

func (m *MockRouter) Unbenched(arg0 ids.ID, arg1 ids.NodeID)

Unbenched mocks base method.

type MockRouterMockRecorder added in v1.9.4

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

MockRouterMockRecorder is the mock recorder for MockRouter.

func (*MockRouterMockRecorder) AddChain added in v1.9.4

func (mr *MockRouterMockRecorder) AddChain(arg0, arg1 interface{}) *gomock.Call

AddChain indicates an expected call of AddChain.

func (*MockRouterMockRecorder) Benched added in v1.9.4

func (mr *MockRouterMockRecorder) Benched(arg0, arg1 interface{}) *gomock.Call

Benched indicates an expected call of Benched.

func (*MockRouterMockRecorder) Connected added in v1.9.4

func (mr *MockRouterMockRecorder) Connected(arg0, arg1, arg2 interface{}) *gomock.Call

Connected indicates an expected call of Connected.

func (*MockRouterMockRecorder) Disconnected added in v1.9.4

func (mr *MockRouterMockRecorder) Disconnected(arg0 interface{}) *gomock.Call

Disconnected indicates an expected call of Disconnected.

func (*MockRouterMockRecorder) HandleInbound added in v1.9.4

func (mr *MockRouterMockRecorder) HandleInbound(arg0, arg1 interface{}) *gomock.Call

HandleInbound indicates an expected call of HandleInbound.

func (*MockRouterMockRecorder) HealthCheck added in v1.9.4

func (mr *MockRouterMockRecorder) HealthCheck(arg0 interface{}) *gomock.Call

HealthCheck indicates an expected call of HealthCheck.

func (*MockRouterMockRecorder) Initialize added in v1.9.4

func (mr *MockRouterMockRecorder) Initialize(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 interface{}) *gomock.Call

Initialize indicates an expected call of Initialize.

func (*MockRouterMockRecorder) RegisterRequest added in v1.9.4

func (mr *MockRouterMockRecorder) RegisterRequest(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 interface{}) *gomock.Call

RegisterRequest indicates an expected call of RegisterRequest.

func (*MockRouterMockRecorder) Shutdown added in v1.9.4

func (mr *MockRouterMockRecorder) Shutdown(arg0 interface{}) *gomock.Call

Shutdown indicates an expected call of Shutdown.

func (*MockRouterMockRecorder) Unbenched added in v1.9.4

func (mr *MockRouterMockRecorder) Unbenched(arg0, arg1 interface{}) *gomock.Call

Unbenched indicates an expected call of Unbenched.

type Router

type Router interface {
	ExternalHandler
	InternalHandler

	Initialize(
		nodeID ids.NodeID,
		log logging.Logger,
		timeouts timeout.Manager,
		shutdownTimeout time.Duration,
		criticalChains set.Set[ids.ID],
		sybilProtectionEnabled bool,
		trackedSubnets set.Set[ids.ID],
		onFatal func(exitCode int),
		healthConfig HealthConfig,
		metricsNamespace string,
		metricsRegisterer prometheus.Registerer,
	) error
	Shutdown(context.Context)
	AddChain(ctx context.Context, chain handler.Handler)
	health.Checker
}

Router routes consensus messages to the Handler of the consensus engine that the messages are intended for

func Trace added in v1.9.2

func Trace(router Router, tracer trace.Tracer) Router

Jump to

Keyboard shortcuts

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