Documentation
¶
Index ¶
- Variables
- func CleanMesh(networkID int, verbose bool) error
- type App
- type Cmd
- type CostFunction
- type Defaults
- type Environer
- type Graph
- type Health
- type HealthData
- type LinkData
- type LinkID
- type Listeners
- type Mesh
- func (m *Mesh) AddServer(pos Position) error
- func (m *Mesh) Close() error
- func (m *Mesh) Defaults() Defaults
- func (m *Mesh) DelLinkHealth(s1, s2 int, field string)
- func (m *Mesh) EncodeGraphML(w io.Writer) error
- func (m *Mesh) Host() string
- func (m *Mesh) Init(ctx context.Context, g Graph) error
- func (m *Mesh) MarshalJSON() ([]byte, error)
- func (m *Mesh) MoveServer(id int, pos Position) error
- func (m *Mesh) NetworkID() int
- func (m *Mesh) Path(fromID, toID int64) ([]int64, error)
- func (m *Mesh) PutLinkHealth(s1, s2 int, field string, value int)
- func (m *Mesh) SetDefaults(defaults *Defaults)
- func (m *Mesh) SetListeners(l Listeners)
- func (m *Mesh) SetState(g Graph)
- type NodeData
- type Options
- type Overrides
- type Peer
- type Position
- type Route
- type Server
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotFound = fmt.Errorf("not found")
)
Functions ¶
Types ¶
type App ¶
type App struct {
// Logger is the event logger.
Logger *elog.Logger
// Mesh is the state of the network.
Mesh *Mesh
// contains filtered or unexported fields
}
App manages the lifecycle of the application.
type Cmd ¶
type Cmd struct {
*exec.Cmd
Out *bytes.Buffer
Err *bytes.Buffer
// contains filtered or unexported fields
}
Cmd is a basic struct that combine an exec.Cmd together with its stdout and stderr buffers.
type CostFunction ¶
type CostFunction string
const ( CostMinLatency CostFunction = "cost_min_latency" CostMaxBandwidth CostFunction = "cost_max_bandwidth" )
func (*CostFunction) UnmarshalText ¶
func (f *CostFunction) UnmarshalText(val []byte) error
type Defaults ¶
type Defaults struct {
Bandwidth float64 `json:"bandwidth,string"`
DecayBandwidth bool `json:"decay_bandwidth"`
LatencyScale float64 `json:"latency_scale,string"`
MaxLatency float64 `json:"max_latency,string"`
MinBandwidth float64 `json:"min_bandwidth,string"`
Jitter float64 `json:"jitter,string"`
PacketLoss float64 `json:"packet_loss,string"`
CostFunction CostFunction `json:"cost_function"` // Deprecated: this is currently unused
}
type Environer ¶
type Environer interface {
// Environ returns a list of environment variables like [os.Environ].
Environ() []string
}
type Graph ¶
type Graph interface {
graph.WeightedUndirected
WeightedEdges() graph.WeightedEdges
}
Graph is a minimal interface of a graph that can be used to override the state of the mesh using Mesh.SetState.
type Health ¶
type Health struct {
Peer Peer `json:"peer"`
HealthData
}
type HealthData ¶
type LinkData ¶
type LinkData struct {
LinkID
HealthData
Overrides Overrides `json:"overrides,omitempty"`
}
LinkData is the structure used to (de)serialize the data of a link in JSON.
type Listeners ¶
type Listeners struct {
// Updated is called after the mesh was modified with [Mesh.SetState]
Updated func()
}
Listeners is a collection of functions that can be overriden and will be called upon certain events.
type Mesh ¶
type Mesh struct {
Autowired bool // If the mesh should create links automatically
Verbose bool // Set to true to output debug messages
StartCmd string // Command used by meshem to start a container
Overrides map[LinkID]Overrides
Listeners Listeners
// contains filtered or unexported fields
}
Mesh contains the state of an emulated network and has methods to mutate it.
func (*Mesh) DelLinkHealth ¶
func (*Mesh) EncodeGraphML ¶
EncodeGraphML exports the data of the mesh into w in GraphML format. For now, it only contains the global topology, the link data is not included.
func (*Mesh) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface to create a custom JSON representation.