simulcontroller

package
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: 17 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 {
	// The minium amount of time (in milliseconds) the controlled users
	// will wait between actions.
	MinIdleTimeMs int `default:"1000" validate:"range:[0,]"`
	// The average amount of time (in milliseconds) the controlled users
	// will wait between actions.
	AvgIdleTimeMs int `default:"20000" validate:"range:($MinIdleTimeMs,]"`
}

Config holds information needed to run a SimulController.

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 SimulController

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

SimulController is a simulative implementation of a UserController.

func New

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

New creates and initializes a new SimulController 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 (*SimulController) Run

func (c *SimulController) Run()

Run begins performing a set of user actions in a loop. 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 (*SimulController) SetRate

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

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

func (*SimulController) Stop

func (c *SimulController) Stop()

Stop stops the controller.

Jump to

Keyboard shortcuts

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