# README
Adding a custom scheduler
IScheduler interface
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{})
}
Register a custom scheduler
Once there's an implementation of the Ischeduler interface it can be registered using the scheduler.RegisterScheduler
or RegisterSchedulerOverride
methods.
Examples registering a scheduler
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{})
}
Generated documentation
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
.
Example scheduler
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.
# Constants
No description provided by the author
# Structs
No description provided by the author
No description provided by the author