The first thing a custom scheduler needs to implement is the IScheduler
interface
// IScheduler interface of scheduler
IScheduler interface {
Validate() ([]string, error)
Execute(
context.Context,
*logger.Log,
time.Duration,
[]scenario.Action,
string, // outputsDir
users.UserGenerator,
*connection.ConnectionSettings,
*statistics.ExecutionCounters,
) error
RequireScenario() bool
// PopulateHookData populate map with data which can be used by go template in hooks
PopulateHookData(data map[string]interface{})
}
Once there's an implementation of the Ischeduler interface it can be registered using the scheduler.RegisterScheduler
or RegisterSchedulerOverride
methods.
The scheduler also needs to be registered using the RegisterScheduler
method.
func init() {
_ = scheduler.RegisterScheduler(MySchedulerName, MyScheduler{})
}
Overriding an existing scheduler with the same name can be done with the RegisterSchedulerOverride
method.
func init() {
_ = scheduler.RegisterSchedulerOverride(MySchedulerName, MyScheduler{})
}
To have documentation for your scheduler included in the generated documentation, do
- Add a folder in
data/schedulers/name_of_your_scheduler
. - Add two files in this folder
description.md
andexamples.md
with description and example of the scheduler. - Add a
doc-key
tag for each setting of your scheduler and add an entry with same key indata/params.json
. - Generate files by running
go generate
.
This package includes an example scheduler randomizing the period inbetween each user get introduced. An example script using this can be found in the examples folder.