Documentation ¶
Index ¶
Constants ¶
const TypeFirst string = "first"
TypeFirst is the type for FirstRouters
const TypeRandom string = "random"
TypeRandom is the type for a random router
const TypeRandomOnce string = "random_once"
TypeRandomOnce is the constant for our random once router
const TypeSwitch string = "switch"
TypeSwitch is the constant for our switch router
Variables ¶
This section is empty.
Functions ¶
func RouterFromEnvelope ¶
func RouterFromEnvelope(envelope *utils.TypedEnvelope) (flows.Router, error)
RouterFromEnvelope attempts to build a router given the passed in TypedEnvelope
Types ¶
type BaseRouter ¶
type BaseRouter struct { // ResultName_ is the name of the which the result of this router should be saved as (if any) ResultName_ string `json:"result_name,omitempty"` }
BaseRouter is the base class for all our router classes
func (*BaseRouter) ResultName ¶
func (r *BaseRouter) ResultName() string
ResultName returns the name which the result of this router should be saved as (if any)
type Case ¶
type Case struct { UUID utils.UUID `json:"uuid" validate:"required"` Type string `json:"type" validate:"required"` Arguments []string `json:"arguments,omitempty"` OmitOperand bool `json:"omit_operand,omitempty"` ExitUUID flows.ExitUUID `json:"exit_uuid" validate:"required"` }
Case represents a single case and test in our switch
type FirstRouter ¶
type FirstRouter struct {
BaseRouter
}
FirstRouter is a simple router that always takes the first exit
func NewFirstRouter ¶ added in v0.4.0
func NewFirstRouter(resultName string) *FirstRouter
type RandomOnceRouter ¶
type RandomOnceRouter struct { BaseRouter Exit flows.ExitUUID `json:"exit" validate:"required"` }
RandomOnceRouter exits of our exits once (randomly) before taking exit
func NewRandomOnceRouter ¶ added in v0.4.0
func NewRandomOnceRouter(exit flows.ExitUUID, resultName string) *RandomOnceRouter
func (*RandomOnceRouter) PickRoute ¶
func (r *RandomOnceRouter) PickRoute(run flows.FlowRun, exits []flows.Exit, step flows.Step) (*string, flows.Route, error)
PickRoute will attempt to take a random exit it hasn't taken before. If all exits have been taken, then it will take the exit specified in it's Exit parameter
func (*RandomOnceRouter) Type ¶
func (r *RandomOnceRouter) Type() string
Type returns the type of our router
type RandomRouter ¶
type RandomRouter struct {
BaseRouter
}
RandomRouter is a router which will exit out a random exit
func NewRandomRouter ¶ added in v0.4.0
func NewRandomRouter(resultName string) *RandomRouter
func (*RandomRouter) PickRoute ¶
func (r *RandomRouter) PickRoute(run flows.FlowRun, exits []flows.Exit, step flows.Step) (*string, flows.Route, error)
PickRoute picks a route randomly from our available exits
func (*RandomRouter) Type ¶
func (r *RandomRouter) Type() string
Type returns the type of this router
type SwitchRouter ¶
type SwitchRouter struct { BaseRouter Default flows.ExitUUID `json:"default_exit_uuid" validate:"omitempty,uuid4"` Operand string `json:"operand" validate:"required"` Cases []Case `json:"cases"` }
SwitchRouter is a router which allows specifying 0-n cases which should each be tested in order, following whichever case returns true, or if none do, then taking the default exit
func NewSwitchRouter ¶ added in v0.4.0
func (*SwitchRouter) PickRoute ¶
func (r *SwitchRouter) PickRoute(run flows.FlowRun, exits []flows.Exit, step flows.Step) (*string, flows.Route, error)
PickRoute evaluates each of the tests on our cases in order, returning the exit for the first case which evaluates to a true. If no cases evaluate to true, then the default exit (if specified) is returned
func (*SwitchRouter) Type ¶
func (r *SwitchRouter) Type() string
Type returns the type of this router