interfaces

package
v0.0.0-...-6d29b5c Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: MIT Imports: 0 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback interface {
	Stop()
}

Wrapers for callback that is called once after `wait` units of time. Callbacks can be stopped as well.

type ControlTransport

type ControlTransport interface {
	ControlPing(string) bool
	ControlSend(string, interface{})
	ControlRecv() <-chan interface{}
}

type Data

type Data struct {
	Id   string
	Size int
}

type DataTransport

type DataTransport interface {
	NodeCapacity
	Connect(string) Link
}

type ISimulation

type ISimulation interface {
	Run()
	Stop()
	Time() int
}

A Simulation interface exposed when using the SDK.

type Link interface {
	// Functions provided for Uploading and Downloading data from a link.
	Upload(Data)
	Download() <-chan Data

	// Function used to clear the data to be uploaded to the channel.
	Clear()

	// Upload and download capacities(together with an identifier) for each
	// end of the connection.
	From() NodeCapacity
	To() NodeCapacity
}

type Node

type Node interface {
	// constructor interface
	New(util NodeUtil) Node

	// Function that represents what the node should do when notified.
	OnNotify()

	// Function that represent the initial action taken by a node when it
	// joins the network.
	OnJoin()

	// A method that should be called when a node leaves the network.
	OnLeave()
}

This interface needs to be implemented by a node. All the functions OnJoin, OnNotify and OnLeave should be non-blocking since the simulator uses coroutines.

type NodeCapacity

type NodeCapacity interface {
	Up() int
	Down() int
}

type NodeUtil

type NodeUtil interface {
	RoutineCapabilities

	Transport() Transport

	Id() string
	Join() string

	Time() func() int
}

The Util interface is provided to a node.

type Routine

type Routine interface {
	Interval() int
	SetInterval(interval int)

	Stop()
}

Wrapers for routines that run at fixed intervals. The inital call of the routine is right after the routine is built. The next ones are done after the set interval. When the interval is changed via SetInterval the interval is changed only after the first call schduled by the old scheduling interval. Routines can be stopped.

type RoutineCapabilities

type RoutineCapabilities interface {
	Routine(interval int, routine func()) Routine
	Callback(timeout int, routine func()) Callback
}

type Transport

type Transport interface {
	ControlTransport
	DataTransport
}

Jump to

Keyboard shortcuts

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