simplecontroller

package
Version: v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Actions are the user action definitions that will be run by the controller.
	Actions []actionDefinition
}

Config holds the the rate and user actions definitions that will be run by the SimpleController.

func ReadConfig

func ReadConfig(configFilePath string) (*Config, error)

ReadConfig reads the configuration file from the given string. If the string is empty, it will return a config with default values.

type SimpleController

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

SimpleController is a very basic implementation of a controller. Currently, it just performs a pre-defined set of actions in a loop.

func New

func New(id int, user user.User, config *Config, status chan<- control.UserStatus) (*SimpleController, error)

New creates and initializes a new SimpleController with given parameters. An id is provided to identify the controller, a User is passed as the entity to be controlled and a UserStatus channel is passed to communicate errors and information about the user's status.

func (*SimpleController) Run

func (c *SimpleController) Run()

Run begins performing a set of actions in a loop with a defined wait in between the actions. It keeps on doing it until Stop is invoked. This is also a blocking function, so it is recommended to invoke it inside a goroutine.

func (*SimpleController) SetRate

func (c *SimpleController) SetRate(rate float64) error

SetRate sets the relative speed of execution of actions by the user.

func (*SimpleController) Stop

func (c *SimpleController) Stop()

Stop stops the controller.

type UserAction

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL