Documentation ¶
Index ¶
- Constants
- Variables
- func NewServer() *server
- type APIEvent
- type APIEventType
- type ErrorEvent
- type InterfaceEntry
- type MethodEntry
- type ProgramEvent
- type ProgramEventType
- type PropertyEntry
- type ScenarioDoc
- type Script
- type ScriptEngine
- type Simulation
- func (s *Simulation) AddScenario(scenario *ScenarioDoc)
- func (s Simulation) CallMethod(service string, method string, params map[string]any) error
- func (s Simulation) LookupInterface(ifaceName string) *InterfaceEntry
- func (s Simulation) LookupMethod(ifaceName string, methodName string) *MethodEntry
- func (s *Simulation) RemoveAll()
- func (s *Simulation) RemoveScenario(name string)
- type Symbol
Constants ¶
const ( EventSimulationStart ProgramEventType = "simulation.start" EventSimulationStop ProgramEventType = "simulation.stop" EventCall APIEventType = "call" EventResponse APIEventType = "response" EventSignal APIEventType = "signal" EventPropertySet APIEventType = "property.set" EventPropertyChanged APIEventType = "property.changed" )
Variables ¶
var ApiEventEmitter = make(chan APIEvent)
var ErrorEventEmitter = make(chan ErrorEvent)
var ProgramEventEmitter = make(chan ProgramEvent)
Functions ¶
Types ¶
type APIEventType ¶
type APIEventType string
type ErrorEvent ¶
type InterfaceEntry ¶
type InterfaceEntry struct { Name string `json:"name" yaml:"name"` Description string `json:"description" yaml:"description"` Properties []PropertyEntry `json:"properties" yaml:"properties"` Methods map[string]MethodEntry `json:"methods" yaml:"methods"` }
InterfaceEntry is a single interface entry in a scenario.
type MethodEntry ¶
type ProgramEvent ¶
type ProgramEvent struct { Type APIEventType `json:"type"` Message string `json:"message"` }
type ProgramEventType ¶
type ProgramEventType string
type PropertyEntry ¶
type PropertyEntry struct { Name string `json:"name" yaml:"name"` Description string `json:"description" yaml:"description"` Value any `json:"value" yaml:"value"` }
PropertyEntry is a named value of an interface method or return entry. { "name": "count", "value": 0 }
type ScenarioDoc ¶
type ScenarioDoc struct { Name string `json:"name" yaml:"name"` Version string `json:"version" yaml:"version"` Description string `json:"description" yaml:"description"` Interfaces map[string]InterfaceEntry `json:"interfaces" yaml:"interfaces"` }
Scenario is a scenario of a simulation.
func ReadJsonScenario ¶
func ReadJsonScenario(file string) (*ScenarioDoc, error)
func ReadScenario ¶
func ReadScenario(file string) (*ScenarioDoc, error)
func ReadYamlScenario ¶
func ReadYamlScenario(file string) (*ScenarioDoc, error)
type ScriptEngine ¶
type ScriptEngine struct {
// contains filtered or unexported fields
}
ScriptEngine is a runs the different scripts in the context of a simulation. The engine produces events which are sent via a channel. Typically the simulation listens to all script engines passes them on to the network communication.
func NewScriptEngine ¶
func NewScriptEngine() *ScriptEngine
func (*ScriptEngine) Run ¶
func (s *ScriptEngine) Run(script Script) error
func (*ScriptEngine) Set ¶
func (s *ScriptEngine) Set(key string, value any)
type Simulation ¶
type Simulation struct {
Scenarios []*ScenarioDoc
}
Simulate runs one or more simulation scenarios. To unload a scenario call the Stop method with the scenario name. To stop all scenarios call the StopAll method. A scenario can simulation properties, methods and signals using static values or scripted behavior. The scripted behavior can be either triggered by a call or by a script entry All results are send out via the event channel.
func NewSimulation ¶
func NewSimulation() *Simulation
func (*Simulation) AddScenario ¶
func (s *Simulation) AddScenario(scenario *ScenarioDoc)
func (Simulation) CallMethod ¶
func (Simulation) LookupInterface ¶
func (s Simulation) LookupInterface(ifaceName string) *InterfaceEntry
func (Simulation) LookupMethod ¶
func (s Simulation) LookupMethod(ifaceName string, methodName string) *MethodEntry
func (*Simulation) RemoveAll ¶
func (s *Simulation) RemoveAll()
func (*Simulation) RemoveScenario ¶
func (s *Simulation) RemoveScenario(name string)
type Symbol ¶
type Symbol string
Symbol is a symbol in the form of <interface>/<resource>.
func MakeSymbol ¶
MakeSymbol creates a symbol from a path and resource.