routers

package
v0.55.1-backport Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2019 License: AGPL-3.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const TypeRandom string = "random"

TypeRandom is the type for a random router

View Source
const TypeSwitch string = "switch"

TypeSwitch is the constant for our switch router

Variables

This section is empty.

Functions

func ReadRouter added in v0.11.0

func ReadRouter(data json.RawMessage) (flows.Router, error)

ReadRouter reads a router from the given JSON

func RegisteredTypes added in v0.29.7

func RegisteredTypes() []string

RegisteredTypes gets the registered types of router

Types

type Case

type Case struct {
	UUID         uuids.UUID         `json:"uuid"                   validate:"required"`
	Type         string             `json:"type"                   validate:"required"`
	Arguments    []string           `json:"arguments,omitempty"    engine:"localized,evaluated"`
	CategoryUUID flows.CategoryUUID `json:"category_uuid"          validate:"required"`
}

Case represents a single case and test in our switch

func NewCase added in v0.23.0

func NewCase(uuid uuids.UUID, type_ string, arguments []string, categoryUUID flows.CategoryUUID) *Case

NewCase creates a new case

func (*Case) Dependencies added in v0.42.0

func (c *Case) Dependencies(localization flows.Localization, include func(assets.Reference))

func (*Case) LocalizationUUID added in v0.29.0

func (c *Case) LocalizationUUID() uuids.UUID

LocalizationUUID gets the UUID which identifies this object for localization

type Category added in v0.30.2

type Category struct {
	// contains filtered or unexported fields
}

func NewCategory added in v0.30.2

func NewCategory(uuid flows.CategoryUUID, name string, exit flows.ExitUUID) *Category

NewCategory creates a new category

func (*Category) ExitUUID added in v0.30.2

func (c *Category) ExitUUID() flows.ExitUUID

func (*Category) LocalizationUUID added in v0.30.2

func (c *Category) LocalizationUUID() uuids.UUID

LocalizationUUID gets the UUID which identifies this object for localization

func (*Category) MarshalJSON added in v0.30.2

func (c *Category) MarshalJSON() ([]byte, error)

MarshalJSON marshals this node category into JSON

func (*Category) Name added in v0.30.2

func (c *Category) Name() string

func (*Category) UUID added in v0.30.2

func (c *Category) UUID() flows.CategoryUUID

func (*Category) UnmarshalJSON added in v0.30.2

func (c *Category) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a node category from the given JSON

type RandomRouter

type RandomRouter struct {
	// contains filtered or unexported fields
}

RandomRouter is a router which will exit out a random exit

func NewRandom added in v0.48.0

func NewRandom(wait flows.Wait, resultName string, categories []*Category) *RandomRouter

NewRandom creates a new random router

func (*RandomRouter) AllowTimeout added in v0.48.0

func (r *RandomRouter) AllowTimeout() bool

AllowTimeout returns whether this router can be resumed at with a timeout

func (*RandomRouter) EnumerateDependencies added in v0.48.0

func (r *RandomRouter) EnumerateDependencies(localization flows.Localization, include func(assets.Reference))

EnumerateDependencies enumerates all dependencies on this object

func (*RandomRouter) EnumerateResults added in v0.48.0

func (r *RandomRouter) EnumerateResults(node flows.Node, include func(*flows.ResultInfo))

EnumerateResults enumerates all potential results on this object

func (*RandomRouter) EnumerateTemplates added in v0.48.0

func (r *RandomRouter) EnumerateTemplates(localization flows.Localization, include func(string))

EnumerateTemplates enumerates all expressions on this object and its children

func (*RandomRouter) MarshalJSON added in v0.32.1

func (r *RandomRouter) MarshalJSON() ([]byte, error)

MarshalJSON marshals this resume into JSON

func (*RandomRouter) ResultName added in v0.48.0

func (r *RandomRouter) ResultName() string

ResultName returns the name which the result of this router should be saved as (if any)

func (*RandomRouter) Route added in v0.33.0

func (r *RandomRouter) Route(run flows.FlowRun, step flows.Step, logEvent flows.EventCallback) (flows.ExitUUID, error)

Route determines which exit to take from a node

func (*RandomRouter) RouteTimeout added in v0.48.0

func (r *RandomRouter) RouteTimeout(run flows.FlowRun, step flows.Step, logEvent flows.EventCallback) (flows.ExitUUID, error)

RouteTimeout routes in the case that this router's wait timed out

func (*RandomRouter) Type

func (r *RandomRouter) Type() string

Type returns the type of this router

func (*RandomRouter) Validate

func (r *RandomRouter) Validate(exits []flows.Exit) error

Validate validates that the fields on this router are valid

func (*RandomRouter) Wait added in v0.48.0

func (r *RandomRouter) Wait() flows.Wait

Wait returns the optional wait on this router

type SwitchRouter

type SwitchRouter struct {
	// contains filtered or unexported fields
}

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 category

func NewSwitch added in v0.48.0

func NewSwitch(wait flows.Wait, resultName string, categories []*Category, operand string, cases []*Case, defaultCategory flows.CategoryUUID) *SwitchRouter

NewSwitch creates a new switch router

func (*SwitchRouter) AllowTimeout added in v0.48.0

func (r *SwitchRouter) AllowTimeout() bool

AllowTimeout returns whether this router can be resumed at with a timeout

func (*SwitchRouter) Cases

func (r *SwitchRouter) Cases() []*Case

func (*SwitchRouter) EnumerateDependencies added in v0.29.0

func (r *SwitchRouter) EnumerateDependencies(localization flows.Localization, include func(assets.Reference))

EnumerateDependencies enumerates all dependencies on this object and its children

func (*SwitchRouter) EnumerateResults added in v0.48.0

func (r *SwitchRouter) EnumerateResults(node flows.Node, include func(*flows.ResultInfo))

EnumerateResults enumerates all potential results on this object

func (*SwitchRouter) EnumerateTemplates added in v0.29.0

func (r *SwitchRouter) EnumerateTemplates(localization flows.Localization, include func(string))

EnumerateTemplates enumerates all expressions on this object and its children

func (*SwitchRouter) MarshalJSON added in v0.32.1

func (r *SwitchRouter) MarshalJSON() ([]byte, error)

MarshalJSON marshals this resume into JSON

func (*SwitchRouter) ResultName added in v0.48.0

func (r *SwitchRouter) ResultName() string

ResultName returns the name which the result of this router should be saved as (if any)

func (*SwitchRouter) Route added in v0.33.0

func (r *SwitchRouter) Route(run flows.FlowRun, step flows.Step, logEvent flows.EventCallback) (flows.ExitUUID, error)

Route determines which exit to take from a node

func (*SwitchRouter) RouteTimeout added in v0.48.0

func (r *SwitchRouter) RouteTimeout(run flows.FlowRun, step flows.Step, logEvent flows.EventCallback) (flows.ExitUUID, error)

RouteTimeout routes in the case that this router's wait timed out

func (*SwitchRouter) Type

func (r *SwitchRouter) Type() string

Type returns the type of this router

func (*SwitchRouter) Validate

func (r *SwitchRouter) Validate(exits []flows.Exit) error

Validate validates the arguments for this router

func (*SwitchRouter) Wait added in v0.48.0

func (r *SwitchRouter) Wait() flows.Wait

Wait returns the optional wait on this router

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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