strategies

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action added in v0.1.3

type Action struct {
	Name string
	Do   func(*Context, *apiserver.APIServer) error
}

func ActionSequence added in v0.1.4

func ActionSequence(actions ...Action) *Action

func DeliverMany added in v0.2.2

func DeliverMany(messages []*types.Message) *Action

func DeliverMessage added in v0.1.3

func DeliverMessage(m *types.Message) *Action

func DoNothing added in v0.1.3

func DoNothing() *Action

type Context added in v0.1.1

type Context struct {
	*sm.Context
	ActionSequence *types.List[*Action]
	// contains filtered or unexported fields
}

func (*Context) Abort added in v0.2.0

func (c *Context) Abort()

func (*Context) AbortCh added in v0.2.0

func (c *Context) AbortCh() <-chan struct{}

func (*Context) CurIteration added in v0.1.3

func (c *Context) CurIteration() int

func (*Context) NextIteration added in v0.1.3

func (c *Context) NextIteration()

type Driver

type Driver struct {
	*types.BaseService
	// contains filtered or unexported fields
}

func NewStrategyDriver added in v0.1.3

func NewStrategyDriver(
	config *config.Config,
	mp types.MessageParser,
	strategy Strategy,
	sConfig *StrategyConfig,
) *Driver

func (*Driver) Name

func (srv *Driver) Name() string

Name implements DashboardRouter

func (*Driver) SetupRouter

func (srv *Driver) SetupRouter(router *gin.RouterGroup)

SetupRouter for setting up the dashboard routes implements DashboardRouter

func (*Driver) Start

func (d *Driver) Start() error

func (*Driver) Stop

func (d *Driver) Stop() error

type DummyStrategy added in v0.1.1

type DummyStrategy struct {
	*types.BaseService
	Actions *types.Channel[*Action]
}

func NewDummyStrategy added in v0.1.1

func NewDummyStrategy() *DummyStrategy

func (*DummyStrategy) ActionsCh added in v0.2.7

func (d *DummyStrategy) ActionsCh() *types.Channel[*Action]

func (*DummyStrategy) EndCurIteration added in v0.1.5

func (f *DummyStrategy) EndCurIteration(*Context)

func (*DummyStrategy) Finalize added in v0.1.4

func (d *DummyStrategy) Finalize(*Context)

func (*DummyStrategy) NextIteration added in v0.1.3

func (d *DummyStrategy) NextIteration(*Context)

func (*DummyStrategy) Start added in v0.1.1

func (d *DummyStrategy) Start() error

func (*DummyStrategy) Step added in v0.1.1

func (d *DummyStrategy) Step(event *types.Event, c *Context)

func (*DummyStrategy) Stop added in v0.1.1

func (d *DummyStrategy) Stop() error

type Strategy

type Strategy interface {
	types.Service
	ActionsCh() *types.Channel[*Action]
	Step(*types.Event, *Context)
	EndCurIteration(*Context)
	NextIteration(*Context)
	Finalize(*Context)
}

func NewStrategyWithProperty added in v0.2.0

func NewStrategyWithProperty(strategy Strategy, prop *sm.StateMachine) Strategy

type StrategyConfig added in v0.1.4

type StrategyConfig struct {
	// Iterations the number of iterations to be run
	Iterations int `json:"iterations"`
	// IterationTimeout timeout for each iteration
	IterationTimeout time.Duration `json:"iteration_timeout"`
	// SetupFunc invoked at the start of every iteration
	SetupFunc func(*Context)
	// StepFunc invoked for every event in all iterations
	StepFunc func(*types.Event, *Context)
	// FinalizeFunc is invoked after all the iterations are completed
	FinalizeFunc func(*Context)
}

StrategyConfig store the config used for running strategies

type StrategyWithProperty added in v0.2.0

type StrategyWithProperty struct {
	Strategy
	Property *sm.StateMachine
	// contains filtered or unexported fields
}

func (*StrategyWithProperty) EndCurIteration added in v0.2.0

func (s *StrategyWithProperty) EndCurIteration(ctx *Context)

func (*StrategyWithProperty) Finalize added in v0.2.0

func (s *StrategyWithProperty) Finalize(ctx *Context)

func (*StrategyWithProperty) NextIteration added in v0.2.0

func (s *StrategyWithProperty) NextIteration(ctx *Context)

func (*StrategyWithProperty) Step added in v0.2.0

func (s *StrategyWithProperty) Step(e *types.Event, ctx *Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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