gencontroller

package
v1.12.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateTargetTeams             = "teams"
	StateTargetChannelsDM        = "channelsDM"
	StateTargetChannelsGM        = "channelsGM"
	StateTargetChannelsPublic    = "channelsPublic"
	StateTargetChannelsPrivate   = "channelsPrivate"
	StateTargetPosts             = "posts"
	StateTargetReactions         = "reactions"
	StateTargetPostReminders     = "postreminders"
	StateTargetSidebarCategories = "sidebarcategories"
	StateTargetFollowedThreads   = "followedthreads"
	StateTargetUsers             = "users"
)
View Source
const MaxLongRunningThreadsPerChannel = 2

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelMemberDistribution added in v1.10.0

type ChannelMemberDistribution struct {
	MemberLimit     int64
	PercentChannels float64 `validate:"range:[0,1]"`
	Probability     float64 `validate:"range:[0,1]"`
}

ChannelMemberDistribution holds the member limit and what percentage of channels will have the limit. Probability indicates how frequently to choose a range. PercentChannels indicates the what percent of channels will contain the change.

For example, a probability of 0.8 and 0.5 of percentChannels with an array of length 10 would mean that indices [0,5) would be chosen at a 80% probability chance. And then the Memberlimit indicates the max member count for that range.

type Config

type Config struct {
	// The target number of teams to be created.
	NumTeams int64 `default:"2" validate:"range:[0,]"`
	// The target number of direct messages to be created.
	NumChannelsDM int64 `default:"20" validate:"range:[0,]"`
	// The target number of group messages to be created.
	NumChannelsGM int64 `default:"20" validate:"range:[0,]"`
	// The target number of private channels to be created.
	NumChannelsPrivate int64 `default:"20" validate:"range:[0,]"`
	// The target number of public channels to be created.
	NumChannelsPublic 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 target number of post reminders to be created.
	NumPostReminders int64 `default:"200" validate:"range:[0,]"`
	// The target number of sidebar categories to be created.
	NumSidebarCategories int64 `default:"10" validate:"range:[0,]"`
	// The target number of threads to follow.
	NumFollowedThreads int64 `default:"10" validate:"range:[0,]"`
	// The percentage of replies to be created.
	PercentReplies float64 `default:"0.5" validate:"range:[0,1]"`
	// The percentage of replies that should be in long threads.
	PercentRepliesInLongThreads float64 `default:"0.05" validate:"range:[0,1]"`
	// The percentage of post that are marked as urgent.
	PercentUrgentPosts float64 `default:"0.001" validate:"range:[0,1]"`

	// Indicates the distribution of chanel members within channels.
	ChannelMembersDistribution []ChannelMemberDistribution
}

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(numUsers int) error

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

func (*Config) NumTotalChannels added in v1.10.0

func (c *Config) NumTotalChannels() int64

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, sysadmin user.User, config *Config, status chan<- control.UserStatus, numUsers int) (*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) InjectAction added in v1.10.0

func (c *GenController) InjectAction(actionID string) error

InjectAction allows a named UserAction to be injected that is run once, at the next available opportunity. These actions can be injected via the coordinator via CLI or Rest API.

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.

type ThreadInfo added in v1.5.0

type ThreadInfo struct {
	Id        string
	ChannelId string
	TeamId    string
}

Jump to

Keyboard shortcuts

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