mesh

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendInfo added in v1.4.1

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

type Connection

type Connection struct {
	RemoteNode *LibNode
	Protocol   string
	TLS        string
}

Connection is an abstraction that ultimately results in a new running netceptor.Backend.

type LibMesh

type LibMesh struct {
	Name string // Only used for generating test names

	DataDir   string
	LogWriter *utils.TestLogWriter
	Context   context.Context
	// contains filtered or unexported fields
}

LibMesh represents a single Receptor mesh network, used for test simulations.

func NewLibMesh

func NewLibMesh() LibMesh

NewLibMesh constructs a new LibMesh.

func (LibMesh) CheckConnections

func (m LibMesh) CheckConnections() bool

CheckConnections returns true if the connections defined in our mesh definition are consistent with the connections made by the nodes.

func (*LibMesh) CheckControlSockets

func (m *LibMesh) CheckControlSockets() bool

CheckControlSockets Checks if the Control sockets in the mesh are all running and accepting connections.

func (*LibMesh) CheckKnownConnectionCosts

func (m *LibMesh) CheckKnownConnectionCosts() bool

CheckKnownConnectionCosts returns true if every node has the same view of the connections in the mesh.

func (*LibMesh) CheckRoutes

func (m *LibMesh) CheckRoutes() bool

CheckRoutes returns true if every node has a route to every other node.

func (*LibMesh) Destroy

func (m *LibMesh) Destroy()

Shutdown stops all running Netceptors and their backends.

func (*LibMesh) GetDataDir

func (m *LibMesh) GetDataDir() string

GetDataDir returns the path to the data directory for this mesh.

func (*LibMesh) GetNodes

func (m *LibMesh) GetNodes() map[string]*LibNode

GetNodes returns a list of nodes.

func (*LibMesh) NewLibNode

func (m *LibMesh) NewLibNode(nodeID string) *LibNode

m.NewLibNode constructs a node with the name passed as the argument.

func (*LibMesh) Start

func (m *LibMesh) Start(_ string) error

func (*LibMesh) Status

func (m *LibMesh) Status() ([]*netceptor.Status, error)

Status returns a list of statuses from the contained netceptors.

func (*LibMesh) WaitForReady

func (m *LibMesh) WaitForReady(ctx context.Context) error

WaitForReady Waits for connections and routes to converge.

func (LibMesh) WaitForShutdown

func (m LibMesh) WaitForShutdown()

WaitForShutdown Waits for all running Netceptors and their backends to stop.

type LibNode

type LibNode struct {
	Config       types.NodeCfg
	Connections  []Connection
	ListenerCfgs map[listenerName]ListenerCfg

	ControlSocket string

	TLSServerConfigs    []*netceptor.TLSServerConfig
	TLSClientConfigs    []*netceptor.TLSClientConfig
	WorkSigningKey      *workceptor.SigningKeyPrivateCfg
	WorkVerificationKey *workceptor.VerifyingKeyPublicCfg
	// contains filtered or unexported fields
}

LibNode represents a node (it's configuration and running services).

func (*LibNode) Destroy

func (n *LibNode) Destroy()

Destroy instructs the node to stop its services.

func (*LibNode) EstablishRemoteConnections

func (n *LibNode) EstablishRemoteConnections() error

EstablishRemoteConnections discovers which address a remote backend is listening on and then dials out to it.

func (*LibNode) GetControlSocket

func (n *LibNode) GetControlSocket() string

GetControlSocket returns the path to the controlsocket.

func (*LibNode) GetDataDir

func (n *LibNode) GetDataDir() string

GetDataDir returns the path to the directory where data is stored for this node.

func (*LibNode) GetID

func (n *LibNode) GetID() string

GetID returns the ID (name) of this node.

func (*LibNode) Shutdown

func (n *LibNode) Shutdown()

Shutdown stops the node and waits for it to exit.

func (*LibNode) Start

func (n *LibNode) Start() error

Start will start local services (netceptor, workceptor, controlsvc), then start any listeners, finally establishing any remote connections. Note that this requires remote nodes to be running since we need to detect which random port was assigned to the backend. This is typically only used when calling Shutdown in the tests. When starting the mesh for the first time we loop over nodes in 2 phases, first calling StartListeners and then EstablishRemoteConnections.

func (*LibNode) StartListeners

func (n *LibNode) StartListeners() error

StartListeners loops over n.ListenerCfgs, which is an interface that wraps TCPListenerCfg, UDPListenerCfg, and WebsocketListenerCfg and starts listening on the appropriate protocol.

func (*LibNode) StartLocalServices

func (n *LibNode) StartLocalServices() error

func (*LibNode) Status

func (n *LibNode) Status() (*netceptor.Status, error)

Status returns the status of the node.

func (*LibNode) TCPDial

func (n *LibNode) TCPDial(address string, cost float64, tlsCfg *tls.Config) error

TCPDial registers a new netceptor.Backend that will dial a remote node via TCP.

func (*LibNode) TCPListen

func (n *LibNode) TCPListen(listenerCfg ListenerCfg) (*BackendInfo, error)

TCPListen takes a ListenerCfg (backends.TCPListenerCfg) and listens for TCP traffic.

func (*LibNode) UDPDial

func (n *LibNode) UDPDial(address string, cost float64) error

UDPDial registers a new netceptor.Backend that will dial a remote node via UDP.

func (*LibNode) UDPListen

func (n *LibNode) UDPListen(listenerCfg ListenerCfg) (*BackendInfo, error)

UDPListen takes a ListenerCfg (backends.UDPListenerCfg) and listens for UDP traffic.

func (*LibNode) WaitForShutdown

func (n *LibNode) WaitForShutdown()

WaitForShutdown Waits for the node to shutdown completely.

func (*LibNode) WebSocketDial

func (n *LibNode) WebSocketDial(address string, cost float64, tlsCfg *tls.Config) error

WebSocketDial registers a new netceptor.Backend that will dial a remote node via a WebSocket.

func (*LibNode) WebsocketListen

func (n *LibNode) WebsocketListen(listenerCfg ListenerCfg) (*BackendInfo, error)

WebsocketListen takes a ListenerCfg (backends.WebsocketListenerCfg) and listens for Websocket traffic.

type ListenerCfg

type ListenerCfg interface {
	GetCost() float64
	GetNodeCost() map[string]float64
	GetAddr() string
	GetTLS() string
}

type NativeBackend

type NativeBackend interface {
	netceptor.Backend
	GetAddr() string
	GetTLS() *tls.Config
}

type ReceptorControl

type ReceptorControl struct {
	SocketFilename string
	// contains filtered or unexported fields
}

ReceptorControl Connects to a control socket and provides basic commands.

func NewReceptorControl

func NewReceptorControl() *ReceptorControl

New Returns an empty ReceptorControl.

func (*ReceptorControl) AssertWorkCancelled

func (r *ReceptorControl) AssertWorkCancelled(ctx context.Context, unitID string) error

AssertWorkCancelled waits until work status is cancelled.

func (*ReceptorControl) AssertWorkFailed

func (r *ReceptorControl) AssertWorkFailed(ctx context.Context, unitID string) error

AssertWorkFailed waits until status is failed.

func (*ReceptorControl) AssertWorkPending

func (r *ReceptorControl) AssertWorkPending(ctx context.Context, unitID string) error

AssertWorkPending waits until status is pending.

func (*ReceptorControl) AssertWorkReleased

func (r *ReceptorControl) AssertWorkReleased(ctx context.Context, unitID string) error

AssertWorkReleased asserts that work is not in work list.

func (*ReceptorControl) AssertWorkResults

func (r *ReceptorControl) AssertWorkResults(unitID string, expectedResults []byte) error

AssertWorkResults makes sure results match expected byte array.

func (*ReceptorControl) AssertWorkRunning

func (r *ReceptorControl) AssertWorkRunning(ctx context.Context, unitID string) error

AssertWorkRunning waits until work status is running.

func (*ReceptorControl) AssertWorkSizeIncreasing

func (r *ReceptorControl) AssertWorkSizeIncreasing(ctx context.Context, unitID string, size int64) error

assert if the work size is increasing.

func (*ReceptorControl) AssertWorkSucceeded

func (r *ReceptorControl) AssertWorkSucceeded(ctx context.Context, unitID string) error

AssertWorkSucceeded waits until status is successful.

func (*ReceptorControl) AssertWorkTimedOut

func (r *ReceptorControl) AssertWorkTimedOut(ctx context.Context, unitID string) error

AssertWorkTimedOut asserts that work failed.

func (*ReceptorControl) Close

func (r *ReceptorControl) Close() error

Close closes the connection to the socket.

func (*ReceptorControl) CloseWrite

func (r *ReceptorControl) CloseWrite() error

CloseWrite closes the write side of the socket.

func (*ReceptorControl) Connect

func (r *ReceptorControl) Connect(filename string) error

Connect connects to the socket at the specified filename and checks the handshake with the control service.

func (*ReceptorControl) GetWorkStatus

func (r *ReceptorControl) GetWorkStatus(unitID string) (*workceptor.StatusFileData, error)

GetWorkStatus returns JSON of status file for a given unitID.

func (*ReceptorControl) Ping

func (r *ReceptorControl) Ping(node string) (string, error)

Ping pings the specified node.

func (*ReceptorControl) Read

func (r *ReceptorControl) Read() ([]byte, error)

Read reads a line from the socket.

func (*ReceptorControl) ReadAndParseJSON

func (r *ReceptorControl) ReadAndParseJSON() (map[string]interface{}, error)

ReadAndParseJSON reads data from the socket and parses it as json.

func (*ReceptorControl) ReadStr

func (r *ReceptorControl) ReadStr() (string, error)

ReadStr reads some data from the socket and converts it to a string.

func (*ReceptorControl) Reconnect

func (r *ReceptorControl) Reconnect() error

Reconnect to unix socket.

func (*ReceptorControl) Reload

func (r *ReceptorControl) Reload() error

func (*ReceptorControl) Status

func (r *ReceptorControl) Status() (*netceptor.Status, error)

Status retrieves the status of the current node.

func (*ReceptorControl) WorkCancel

func (r *ReceptorControl) WorkCancel(unitID string) (map[string]interface{}, error)

WorkCancel cancels work.

func (*ReceptorControl) WorkRelease

func (r *ReceptorControl) WorkRelease(unitID string) (map[string]interface{}, error)

WorkRelease cancels and deletes work.

func (*ReceptorControl) WorkStart

func (r *ReceptorControl) WorkStart(workType string) (string, error)

WorkStart begins work on local node.

func (*ReceptorControl) WorkSubmit

func (r *ReceptorControl) WorkSubmit(node, workType string) (string, error)

WorkSubmit begins work on remote node.

func (*ReceptorControl) WorkSubmitJSON

func (r *ReceptorControl) WorkSubmitJSON(command string) (string, error)

WorkSubmitJSON begins work on remote node via JSON command.

func (*ReceptorControl) Write

func (r *ReceptorControl) Write(data []byte) (int, error)

Write writes some data to the socket.

func (*ReceptorControl) WriteStr

func (r *ReceptorControl) WriteStr(data string) (int, error)

WriteStr writes string data to the socket.

Jump to

Keyboard shortcuts

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