Documentation ¶
Index ¶
- Constants
- func ReadRouter(data json.RawMessage) (flows.Router, error)
- func RegisterType(name string, initFunc func() flows.Router)
- func RegisteredTypes() map[string](func() flows.Router)
- type BaseRouter
- func (r *BaseRouter) EnumerateDependencies(localization flows.Localization, include func(assets.Reference))
- func (r *BaseRouter) EnumerateResults(include func(*flows.ResultSpec))
- func (r *BaseRouter) EnumerateTemplates(localization flows.Localization, include func(string))
- func (r *BaseRouter) ResultName() string
- func (r *BaseRouter) RewriteTemplates(localization flows.Localization, rewrite func(string) string)
- func (r *BaseRouter) Type() string
- type Case
- func (c *Case) EnumerateDependencies(localization flows.Localization, include func(assets.Reference))
- func (c *Case) EnumerateResults(include func(*flows.ResultSpec))
- func (c *Case) EnumerateTemplates(localization flows.Localization, include func(string))
- func (c *Case) Inspect(inspect func(flows.Inspectable))
- func (c *Case) LocalizationUUID() utils.UUID
- func (c *Case) RewriteTemplates(localization flows.Localization, rewrite func(string) string)
- type Category
- type RandomRouter
- type SwitchRouter
- func (r *SwitchRouter) EnumerateDependencies(localization flows.Localization, include func(assets.Reference))
- func (r *SwitchRouter) EnumerateTemplates(localization flows.Localization, include func(string))
- func (r *SwitchRouter) Inspect(inspect func(flows.Inspectable))
- func (r *SwitchRouter) PickExit(run flows.FlowRun, step flows.Step, logEvent flows.EventCallback) (flows.ExitUUID, error)
- func (r *SwitchRouter) RewriteTemplates(localization flows.Localization, rewrite func(string) string)
- func (r *SwitchRouter) Validate(exits []flows.Exit) error
Constants ¶
const TypeRandom string = "random"
TypeRandom is the type for a random router
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 RegisterType ¶ added in v0.11.0
RegisterType registers a new type of router
func RegisteredTypes ¶ added in v0.29.7
RegisteredTypes gets the registered types of router
Types ¶
type BaseRouter ¶
type BaseRouter struct { Type_ string `json:"type" validate:"required"` ResultName_ string `json:"result_name,omitempty"` Categories_ []*Category `json:"categories,omitempty" validate:"required,min=1"` }
BaseRouter is the base class for all our router classes
func (*BaseRouter) EnumerateDependencies ¶ added in v0.29.0
func (r *BaseRouter) EnumerateDependencies(localization flows.Localization, include func(assets.Reference))
EnumerateDependencies enumerates all dependencies on this object
func (*BaseRouter) EnumerateResults ¶ added in v0.30.2
func (r *BaseRouter) EnumerateResults(include func(*flows.ResultSpec))
EnumerateResults enumerates all potential results on this object
func (*BaseRouter) EnumerateTemplates ¶ added in v0.29.0
func (r *BaseRouter) EnumerateTemplates(localization flows.Localization, include func(string))
EnumerateTemplates enumerates all expressions on this object and its children
func (*BaseRouter) ResultName ¶
func (r *BaseRouter) ResultName() string
ResultName returns the name which the result of this router should be saved as (if any)
func (*BaseRouter) RewriteTemplates ¶ added in v0.29.0
func (r *BaseRouter) RewriteTemplates(localization flows.Localization, rewrite func(string) string)
RewriteTemplates rewrites all templates on this object and its children
func (*BaseRouter) Type ¶ added in v0.22.0
func (r *BaseRouter) Type() string
Type returns the type of this router
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"` 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 utils.UUID, type_ string, arguments []string, omitOperand bool, categoryUUID flows.CategoryUUID) *Case
NewCase creates a new case
func (*Case) EnumerateDependencies ¶ added in v0.29.0
func (c *Case) EnumerateDependencies(localization flows.Localization, include func(assets.Reference))
EnumerateDependencies enumerates all dependencies on this object and its children
func (*Case) EnumerateResults ¶ added in v0.30.2
func (c *Case) EnumerateResults(include func(*flows.ResultSpec))
EnumerateResults enumerates all potential results on this object
func (*Case) EnumerateTemplates ¶ added in v0.29.0
func (c *Case) EnumerateTemplates(localization flows.Localization, include func(string))
EnumerateTemplates enumerates all expressions on this object and its children
func (*Case) Inspect ¶ added in v0.29.0
func (c *Case) Inspect(inspect func(flows.Inspectable))
Inspect inspects this object and any children
func (*Case) LocalizationUUID ¶ added in v0.29.0
LocalizationUUID gets the UUID which identifies this object for localization
func (*Case) RewriteTemplates ¶ added in v0.29.0
func (c *Case) RewriteTemplates(localization flows.Localization, rewrite func(string) string)
RewriteTemplates rewrites all templates on this object and its children
type Category ¶ added in v0.30.2
type Category struct {
// contains filtered or unexported fields
}
func NewCategory ¶ added in v0.30.2
NewCategory creates a new category
func (*Category) LocalizationUUID ¶ added in v0.30.2
LocalizationUUID gets the UUID which identifies this object for localization
func (*Category) MarshalJSON ¶ added in v0.30.2
MarshalJSON marshals this node category into JSON
func (*Category) UUID ¶ added in v0.30.2
func (c *Category) UUID() flows.CategoryUUID
func (*Category) UnmarshalJSON ¶ added in v0.30.2
UnmarshalJSON unmarshals a node category from the given JSON
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, categories []*Category) *RandomRouter
NewRandomRouter creates a new random router
func (*RandomRouter) Inspect ¶ added in v0.29.0
func (r *RandomRouter) Inspect(inspect func(flows.Inspectable))
Inspect inspects this object and any children
type SwitchRouter ¶
type SwitchRouter struct { BaseRouter Operand string `json:"operand" validate:"required"` Cases []*Case `json:"cases"` Default flows.CategoryUUID `json:"default_category_uuid" validate:"omitempty,uuid4"` }
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 NewSwitchRouter ¶ added in v0.4.0
func NewSwitchRouter(resultName string, categories []*Category, operand string, cases []*Case, defaultCategory flows.CategoryUUID) *SwitchRouter
NewSwitchRouter creates a new switch router
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) 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) Inspect ¶ added in v0.29.0
func (r *SwitchRouter) Inspect(inspect func(flows.Inspectable))
Inspect inspects this object and any children
func (*SwitchRouter) PickExit ¶ added in v0.30.2
func (r *SwitchRouter) PickExit(run flows.FlowRun, step flows.Step, logEvent flows.EventCallback) (flows.ExitUUID, error)
PickExit determines which exit to take from a node
func (*SwitchRouter) RewriteTemplates ¶ added in v0.29.0
func (r *SwitchRouter) RewriteTemplates(localization flows.Localization, rewrite func(string) string)
RewriteTemplates rewrites all templates on this object and its children