server

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0, BSD-2-Clause Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// PluginName is the name of the analysis server plugin.
	PluginName = "Analysis-Server"

	// CfgAnalysisServerBindAddress defines the bind address of the analysis server.
	CfgAnalysisServerBindAddress = "analysis.server.bindAddress"

	// IdleTimeout defines the idle timeout of the read from the client's connection.
	IdleTimeout = 1 * time.Minute
)

Variables

View Source
var Events = struct {
	// AddNode triggers when adding a new node.
	AddNode *events.Event
	// RemoveNode triggers when removing a node.
	RemoveNode *events.Event
	// ConnectNodes triggers when connecting two nodes.
	ConnectNodes *events.Event
	// DisconnectNodes triggers when disconnecting two nodes.
	DisconnectNodes *events.Event
	// Error triggers when an error occurs.
	Error *events.Event
	// Heartbeat triggers when an heartbeat has been received.
	Heartbeat *events.Event
	// FPCHeartbeat triggers when an FPC heartbeat has been received.
	FPCHeartbeat *events.Event
	// MetricHeartbeat triggers when an MetricHeartbeat heartbeat has been received.
	MetricHeartbeat *events.Event
}{
	events.NewEvent(addNodeCaller),
	events.NewEvent(removeNodeCaller),
	events.NewEvent(connectNodesCaller),
	events.NewEvent(disconnectNodesCaller),
	events.NewEvent(errorCaller),
	events.NewEvent(heartbeatPacketCaller),
	events.NewEvent(fpcHeartbeatPacketCaller),
	events.NewEvent(metricHeartbeatPacketCaller),
}

Events holds the events of the analysis server package.

View Source
var Networks = make(map[string]*NetworkMap)

Networks maps all available versions to network map

Functions

func HandleConnection

func HandleConnection(conn *network.ManagedConnection)

HandleConnection handles the given connection.

func Plugin added in v0.2.0

func Plugin() *node.Plugin

Plugin gets the plugin instance.

func ReplayAutopeeringEvents added in v0.2.2

func ReplayAutopeeringEvents(handlers *EventHandlers)

ReplayAutopeeringEvents replays recorded events on the given event handler.

func ShortNodeIDString added in v0.2.2

func ShortNodeIDString(b []byte) string

ShortNodeIDString returns the short nodeID as a string.

Types

type AddNodeEvent added in v0.2.2

type AddNodeEvent struct {
	NetworkVersion string
	NodeID         string
}

AddNodeEvent is the payload type of an AddNode event.

type ConnectNodesEvent added in v0.2.2

type ConnectNodesEvent struct {
	NetworkVersion string
	SourceID       string
	TargetID       string
}

ConnectNodesEvent is the payload type of a ConnectNodesEvent.

type DisconnectNodesEvent added in v0.2.2

type DisconnectNodesEvent struct {
	NetworkVersion string
	SourceID       string
	TargetID       string
}

DisconnectNodesEvent is the payload type f a DisconnectNodesEvent.

type EventHandlers added in v0.2.2

type EventHandlers struct {
	// Addnode defines the handler called when adding a new node.
	AddNode func(event *AddNodeEvent)
	// RemoveNode defines the handler called when adding removing a node.
	RemoveNode func(event *RemoveNodeEvent)
	// ConnectNodes defines the handler called when connecting two nodes.
	ConnectNodes func(event *ConnectNodesEvent)
	// DisconnectNodes defines the handler called when connecting two nodes.
	DisconnectNodes func(event *DisconnectNodesEvent)
}

EventHandlers holds the handler for each event of the record manager.

type EventHandlersConsumer added in v0.2.2

type EventHandlersConsumer = func(handler *EventHandlers)

EventHandlersConsumer defines the consumer function of an *EventHandlers.

type NeighborMetric added in v0.2.2

type NeighborMetric struct {
	Inbound  uint
	Outbound uint
}

NeighborMetric contains the number of inbound/outbound neighbors.

type NetworkMap added in v0.2.2

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

NetworkMap contains information about the peer connections on a specific network.

func NewNetworkMap added in v0.2.2

func NewNetworkMap(networkVersion string) *NetworkMap

NewNetworkMap creates a new network map with a given network version

func (*NetworkMap) NetworkGraph added in v0.2.2

func (nm *NetworkMap) NetworkGraph() *graph.Graph

NetworkGraph returns the autopeering network graph for the current network.

func (*NetworkMap) NumOfNeighbors added in v0.2.2

func (nm *NetworkMap) NumOfNeighbors() map[string]*NeighborMetric

NumOfNeighbors returns a map of nodeIDs to their neighbor count.

type RemoveNodeEvent added in v0.2.2

type RemoveNodeEvent struct {
	NetworkVersion string
	NodeID         string
}

RemoveNodeEvent is the payload type of a RemoveNode event.

Jump to

Keyboard shortcuts

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