scheduler

package
v0.17.11 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SchedSimple = "simple"
)

Core schedulers

Variables

This section is empty.

Functions

func RegisterScheduler added in v0.15.0

func RegisterScheduler(sched string, scheduler IScheduler) error

RegisterScheduler register a custom scheduler, this will fail if scheduler with same name exists This should be done as early as possible and must be done before unmarshaling config

func RegisterSchedulerOverride added in v0.15.0

func RegisterSchedulerOverride(sched string, scheduler IScheduler) error

RegisterSchedulerOverride register a custom scheduler and override any existing with same name This should be done as early as possible and must be done before unmarshaling config

func RegisteredSchedulers added in v0.15.0

func RegisteredSchedulers() []string

RegisteredActions returns a list of currently registered actions

func SchedHandler

func SchedHandler(scheduler string) interface{}

SchedHandler get scheduler instance of type

Types

type IScheduler

type IScheduler interface {
	Validate() ([]string, error)
	Execute(
		context.Context,
		*logger.Log,
		time.Duration,
		[]scenario.Action,
		string,
		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{})
}

IScheduler interface of scheduler

func Regression added in v0.10.0

func Regression() IScheduler

func UnmarshalScheduler

func UnmarshalScheduler(raw []byte) (IScheduler, error)

UnmarshalScheduler unmarshal IScheduler

type Scheduler

type Scheduler struct {
	// SchedType type of scheduler
	SchedType SchedulerType `json:"type" doc-key:"config.scheduler.type" displayname:"Scheduler type"`
	// TimeBuf add wait time in between iterations
	TimeBuf TimeBuffer `json:"iterationtimebuffer" doc-key:"config.scheduler.iterationtimebuffer"`
	// InstanceNumber used to ensure different randomizations when running script in multiple different instances
	InstanceNumber uint64 `json:"instance" doc-key:"config.scheduler.instance"  displayname:"Instance number"`
	// ReconnectSettings settings for re-connecting websocket on unexpected disconnect
	ReconnectSettings session.ReconnectSettings `json:"reconnectsettings" doc-key:"config.scheduler.reconnectsettings"`

	ConnectionSettings *connection.ConnectionSettings `json:"-"`
	ContinueOnErrors   bool                           `json:"-"`
}

Scheduler common core of schedulers

func (*Scheduler) SetContinueOnErrors added in v0.6.5

func (sched *Scheduler) SetContinueOnErrors(enabled bool) error

SetContinueOnErrors toggles whether to continue on action errors

func (*Scheduler) StartNewUser added in v0.15.0

func (sched *Scheduler) StartNewUser(ctx context.Context, timeout time.Duration, log *logger.Log, userScenario []scenario.Action, thread uint64,
	outputsDir string, user *users.User, iterations int, onlyInstanceSeed bool, counters *statistics.ExecutionCounters) error

func (*Scheduler) Validate

func (sched *Scheduler) Validate() error

Validate Scheduler settings

type SchedulerType added in v0.15.0

type SchedulerType string

func (SchedulerType) GetEnumMap added in v0.15.0

func (typ SchedulerType) GetEnumMap() *enummap.EnumMap

GetEnumMap fakes a scheduler enum for GUI

type SimpleSchedSettings

type SimpleSchedSettings struct {
	ExecutionTime    int     `json:"executionTime" displayname:"Execution time" doc-key:"config.scheduler.settings.executiontime"` // in seconds
	Iterations       int     `json:"iterations" displayname:"Iterations" doc-key:"config.scheduler.settings.iterations"`
	RampupDelay      float64 `json:"rampupDelay" displayname:"Rampup delay" doc-key:"config.scheduler.settings.rampupdelay"` // in seconds
	ConcurrentUsers  int     `json:"concurrentUsers" displayname:"Concurrent users" doc-key:"config.scheduler.settings.concurrentusers"`
	ReuseUsers       bool    `json:"reuseUsers" displayname:"Reuse users" doc-key:"config.scheduler.settings.reuseusers"`
	OnlyInstanceSeed bool    `json:"onlyinstanceseed" displayname:"Only use instance seed" doc-key:"config.scheduler.settings.onlyinstanceseed"`
}

SimpleSchedSettings simple scheduler settings

type SimpleScheduler

type SimpleScheduler struct {
	Scheduler
	Settings SimpleSchedSettings `json:"settings" doc-key:"config.scheduler.settings"`
}

SimpleScheduler simple scheduler

func (SimpleScheduler) Execute

func (sched SimpleScheduler) Execute(ctx context.Context, log *logger.Log, timeout time.Duration, scenario []scenario.Action, outputsDir string,
	users users.UserGenerator, connectionSettings *connection.ConnectionSettings, counters *statistics.ExecutionCounters) (err error)

Execute execute schedule

func (SimpleScheduler) PopulateHookData added in v0.11.5

func (sched SimpleScheduler) PopulateHookData(data map[string]interface{})

PopulateHookData populate map with data to be used with hooks

func (SimpleScheduler) RequireScenario

func (sched SimpleScheduler) RequireScenario() bool

RequireScenario report that scheduler requires a scenario

func (SimpleScheduler) Validate

func (sched SimpleScheduler) Validate() ([]string, error)

Validate schedule

type TimeBufMode

type TimeBufMode int

TimeBufMode type of time buffer

const (
	// TimeBufNoWait no time buffer
	TimeBufNoWait TimeBufMode = iota
	// TimeBufConstant constant time buffer
	TimeBufConstant
	// TimeBufOnError time buffer on error
	TimeBufOnError
	// TimeBufMinDur buffer time until minimum duration
	TimeBufMinDur
)

func (TimeBufMode) GetEnumMap

func (mode TimeBufMode) GetEnumMap() *enummap.EnumMap

func (TimeBufMode) MarshalJSON

func (mode TimeBufMode) MarshalJSON() ([]byte, error)

MarshalJSON marshal time buffer mode to JSON

func (*TimeBufMode) UnmarshalJSON

func (mode *TimeBufMode) UnmarshalJSON(arg []byte) error

UnmarshalJSON unmarshal time buffer mode from JSON

type TimeBuffer

type TimeBuffer struct {
	Mode     TimeBufMode          `json:"mode,omitempty" displayname:"Time buffer mode" doc-key:"config.scheduler.iterationtimebuffer.mode"`
	Duration helpers.TimeDuration `json:"duration,omitempty" displayname:"Time buffer duration" doc-key:"config.scheduler.iterationtimebuffer.duration"`
	// contains filtered or unexported fields
}

TimeBuffer time buffer at end of a user iteration

func (*TimeBuffer) SetDurationStart

func (timeBuf *TimeBuffer) SetDurationStart(time time.Time)

SetDurationStart mark start of duration time (to be used with TimeBufMinDur)

func (*TimeBuffer) Validate

func (timeBuf *TimeBuffer) Validate() error

Validate settings of time buffer

func (*TimeBuffer) Wait

func (timeBuf *TimeBuffer) Wait(ctx context.Context, hasErrors bool) error

Wait inserts time buffer or context

Jump to

Keyboard shortcuts

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