gencontroller

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: 12 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 target number of teams to be created.
	NumTeams int64 `default:"2" validate:"range:[0,]"`
	// The target number of channels to be created.
	NumChannels int64 `default:"20" validate:"range:[0,]"`
	// The target number of posts to be created.
	NumPosts int64 `default:"1000" validate:"range:[0,]"`
	// The target number of reactions to be created.
	NumReactions int64 `default:"200" validate:"range:[0,]"`
	// The percentage of replies to be created.
	PercentReplies float64 `default:"0.5" validate:"range:[0,1]"`

	// The percentage of public channels to be created.
	PercentPublicChannels float64 `default:"0.2" validate:"range:[0,1]"`
	// The percentage of private channels to be created.
	PercentPrivateChannels float64 `default:"0.1" validate:"range:[0,1]"`
	// The percentage of direct channels to be created.
	PercentDirectChannels float64 `default:"0.6" validate:"range:[0,1]"`
	// The percentage of group channels to be created.
	PercentGroupChannels float64 `default:"0.1" validate:"range:[0,1]"`
}

Config holds information about the data to be generated by the GenController.

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.

func (*Config) IsValid

func (c *Config) IsValid() error

IsValid reports whether a given gencontroller.Config is valid or not. Returns an error if the validation fails.

type GenController

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

GenController is an implementation of a UserController used to generate realistic initial data.

func New

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

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

func (c *GenController) 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 (*GenController) SetRate

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

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

func (*GenController) Stop

func (c *GenController) Stop()

Stop stops the controller.

Jump to

Keyboard shortcuts

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