Flow Builder
Type parameters
- CT
-
the current input type of the latest task
- CU
-
the current output type of the latest task
- T
-
the input type of the flow
- U
-
the output type of the flow
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Abstract methods
Apply the provided onAtomComplete
handler to all tasks of the workflow.
Apply the provided onAtomComplete
handler to all tasks of the workflow.
Value parameters
- onAtomComplete
-
the onAtomComplete handler to be applied to all tasks
Attributes
- Returns
-
the transformed flow
Apply and wrap the provided wrapper f
to all tasks of the workflow.
Apply and wrap the provided wrapper f
to all tasks of the workflow.
Value parameters
- f
-
the wrapper to be applied to all tasks
Attributes
- Returns
-
the transformed flow
Transform the flow by an asker task, binds to portal p
and executes the asker handler f
.
Transform the flow by an asker task, binds to portal p
and executes the asker handler f
.
Value parameters
- f
-
the asker handler
- portals
-
the portals to bind to
Attributes
Transform the flow by an askerReplier task, binds to portals askerportals
and replierportals
, executes the handler f1
on regular events, and executes handler f2
on requests.
Transform the flow by an askerReplier task, binds to portals askerportals
and replierportals
, executes the handler f1
on regular events, and executes handler f2
on requests.
Value parameters
- askerportals
-
the portals to bind to for asker
- f1
-
the event handler
- f2
-
the request handler
- replierportals
-
the portals to bind to for replier
Attributes
Check the current type against the provided expected type.
Check the current type against the provided expected type.
Compares FlowBuilder[T, U, CT, CU] with CCU, succeeds if CU <: CCU <: CU.
Type parameters
- CCU
-
the expected type
Attributes
Use predicate p
to filter the events of the flow.
Use predicate p
to filter the events of the flow.
Value parameters
- p
-
the predicate to filter the flow
Attributes
- Returns
-
the filtered flow
Transform the flow by flatMapping by the provided function f
.
Transform the flow by flatMapping by the provided function f
.
Note, you cannot emit events from the provided flatMap function, instead the events produced by the flatMap function will be emitted by the returned flow.
Type parameters
- CCU
-
the new output type of the mapped flow
Value parameters
- f
-
the function to flatMap the current flow
Attributes
- Returns
-
the flatMapped flow
Freeze the flow builder, returns the frozen workflow.
Freeze the flow builder, returns the frozen workflow.
Attributes
- Returns
-
the frozen workflow
- Note
-
The workflow cannot be modified once frozen.
Transform by the identity function (i.e. do nothing).
Transform by the identity function (i.e. do nothing).
Can be used to create actual transforming behavior using the modifiers such as withOnNext
.
Attributes
- Returns
-
the transformed flow
Provide an initialization factory for a task that transforms this flow.
Provide an initialization factory for a task that transforms this flow.
The initialization factory is called at runtime to create the task. This can be used to initial various objects, such as state, to be used by the processing behaviors.
Note: this may be re-executed more than once, every time that the task is restarted (e.g. after a failure).
Type parameters
- CCU
-
the new output type of the transformed flow
Value parameters
- initFactory
-
the task initialization factory
Attributes
- Returns
-
the transformed flow
Compute and shuffle the flow according to a key extracted by f
.
Compute and shuffle the flow according to a key extracted by f
.
Value parameters
- f
-
key extractor function
Attributes
- Returns
-
flow shuffled by new key
Log the current flow with the provided prefix.
Log the current flow with the provided prefix.
Value parameters
- prefix
-
the prefix for logged messages
Attributes
- Returns
-
the logged flow
Map the current flow with the provided function f
.
Map the current flow with the provided function f
.
Type parameters
- CCU
-
the new output type of the mapped flow
Value parameters
- f
-
the function to map the current flow
Attributes
- Returns
-
the map flow
Transform the flow by a provided processor f
.
Transform the flow by a provided processor f
.
The processor function f
may access the ProcessorTaskContext
, which allows it to emit
events, access state
, log messages, etc.
Type parameters
- CCU
-
the new output type of the mapped flow
Value parameters
- f
-
the processor function
Attributes
- Returns
-
the transformed flow by the processor function
Transform the flow by a replier task, binds to portal p
, executes the handler f1
on regular events, executes the replier handler f2
on requests.
Transform the flow by a replier task, binds to portal p
, executes the handler f1
on regular events, executes the replier handler f2
on requests.
Value parameters
- f1
-
the processor handler
- f2
-
the replier handler
- portals
-
the portals to bind to
Attributes
End the flow in the sink.
End the flow in the sink.
Attributes
- Returns
-
a new flow builder
- Note
-
The output type of the current flowbuilder shas to have the same type as the sink / workflow output.
Transform the flow by the provided taskBehavior.
Transform the flow by the provided taskBehavior.
Type parameters
- CCU
-
the new output type of the mapped flow
Value parameters
- taskBehavior
-
the task behavior to transform the flow
Attributes
- Returns
-
the transformed flow by the provided task
Union the flow of the current flow with the others
flows.
Union the flow of the current flow with the others
flows.
Value parameters
- others
-
list of other flows which will be unioned with the current flow
Attributes
- Returns
-
a new flow builder
Start an instance of a VSM task.
Start an instance of a VSM task.
Starts an instance of a VSM task. The VSM task is a stateful task behavior which manages the task in a per-key context. To use this you must provide an initial VSMTask
behavior, which can be created using VSMTasks.processor
. The VSMTask can still access state, emit events, and more as can the normal tasks.
Value parameters
- defaultTask
-
the default task to use as an initial task behavior
Attributes
- See also
-
portals.api.builder.TaskExtensions.VSMTask
- Example
-
// VSMTasks val init = VSMExtension.processor { event => started } val started = VSMExtension.processor { event => init } val vsm = VSMExtension.vsm[Int, Int] { init } // flow val flow: FlowBuilder[...] = ... flow.vsm(init)
Chaining task
after the current task.
Chaining task
after the current task.
This is used to explicitly chain tasks as a single task behavior.
Value parameters
- task
-
the task to chain after the current task
Attributes
- Returns
-
the transformed flow
Behavior modifier to loop over atoms for current task.
Behavior modifier to loop over atoms for current task.
This will loop and execute the provided task
on the count
next atoms.
Value parameters
- count
-
the number of times to loop
- task
-
the task to looped
Attributes
- Returns
-
the transformed flow
Give a name to the current task (latest task).
Give a name to the current task (latest task).
The current task is the latest task that was used to transform on this flow.
Value parameters
- name
-
the new name of the current task
Attributes
- Returns
-
the current flow
Set the onAtomComplete handler of the current task to the provided handler.
Set the onAtomComplete handler of the current task to the provided handler.
Value parameters
- onAtomComplete
-
the new onAtomComplete handler
Attributes
- Returns
-
the current flow
Set the onComplete handler of the current task to the provided handler.
Set the onComplete handler of the current task to the provided handler.
Value parameters
- onComplete
-
the new onComplete handler
Attributes
- Returns
-
the current flow
Set the onError handler of the current task to the provided handler.
Set the onError handler of the current task to the provided handler.
Value parameters
- onError
-
the new onError handler
Attributes
- Returns
-
the current flow
Set the onNext handler of the current task to the provided handler.
Set the onNext handler of the current task to the provided handler.
Value parameters
- onNext
-
the new onNext handler
Attributes
- Returns
-
the current flow
Behavior modifier to step over atoms for current task.
Behavior modifier to step over atoms for current task.
This will execute the provided task
on the subsequent atom.
Value parameters
- task
-
the task to execute on the subsequent atom
Attributes
- Returns
-
the transformed flow
Wrap around the behavior of the current task by the wrapping function f
.
Wrap around the behavior of the current task by the wrapping function f
.
Type parameters
- V
-
additional type for widening the output type by union
Value parameters
- f
-
the wrapping function
Attributes
- Returns
-
the current flow
- Example
-
FlowBuilder[_, _, Int, Int] .withWrapper[String]{ ctx ?=> wrapped => event => if event < 3 then ctx.emit("0") else wrapped(event) }
Concrete methods
Combine and union all provided flows
and process by task
. Note, this does not union with the current flow.
Combine and union all provided flows
and process by task
. Note, this does not union with the current flow.
TODO: this should not be here, as it is confusing that it does not union with the current flow.
Value parameters
- flows
-
the flows which will be unioned (NOT unioned with current flow)
- task
-
the task to process the combined flows
Attributes
- Returns
-
a new flow builder
Split a flow into two disjoint flows by the provided predicates p1
and p2
.
Split a flow into two disjoint flows by the provided predicates p1
and p2
.
Value parameters
- p1
-
the first splitting predicate
- p2
-
the second splitting predicate
Attributes
- Returns
-
two flow builders, one for each split
Union the flow of the current flow with the others
flows.
Union the flow of the current flow with the others
flows.
Value parameters
- others
-
the other flows which will be unioned with the current flow
Attributes
- Returns
-
a new flow builder