Workflow API reference

IWorkflow<in TIn, out TOut> : IProcessDefinition

A class must implement this interface to be recognized as a workflow.

Initialize: TOut

The initializer. Constructs the initial state of the workflow.

Returns the output message.
  • context: IInitializationContext - The Flower initialization context. It contains Flower services available for the initializer.
  • arg: TIn - The input message.

Process

Base class of all workflows.

IProcessBuilder

If: IProcessBuilder

Opens a conditionally executed block.
  • condition: IContext -> Boolean - The enter condition.

Else: IProcessBuilder

Opens an alternative block of a conditional execution.

ElseIf: IProcessBuilder

Opens a conditionally executed alternative block.
  • condition: IContext -> Boolean - The enter condition.

While: IProcessBuilder

Opens a loop.
  • condition: IContext -> Boolean - The exit condition.

For: IProcessBuilder

Opens a loop.
  • init: IContext -> - The action to be executed before the loop.
  • condition: IContext -> Boolean - The exit condition.
  • loop: IContext -> - The action to be executed after each iteration of the loop.

ForEach<T>: IProcessBuilder

Iterates messages in a subset.
  • subset: IContext -> String - The path of the subset. If the path starts with '/', it is considered a global path of a subset; otherwise, it is considered a path of a local subset. In the later case the value will be transformed to the global path '/Sets/Local/[pid]/[subset]'.
  • orderBy: IContext -> MessageProperty - Message property by which the messages are to be sorted.
  • order: IContext -> SortOrder - The sort order.
  • batchSize: IContext -> Int32 - How many items to load in one round trip.
  • wait: IContext -> Boolean - Whether to wait for the messages if the subset is empty.
  • item: IContext, T -> - An action called on each iteration of the loop. Each next message is passed as argument to this action. The first argument is the message name, the second is the message data.

RemoveCurrent: IProcessBuilder

Removes the current item in a ForEach loop from the iterated subset.

UpdateCurrent<T>: IProcessBuilder

Updates the current item in a ForEach loop and saves it to the subset.
  • name: IContext -> String - The new name of the message.
  • message: IContext -> T - The new message data.
  • format: IContext -> MessageFormat - The format of the serialized message.

Break: IProcessBuilder

Jumps out from the current loop.

Continue: IProcessBuilder

Jumps to the next iteration of the current loop.

Invoke<TSvc>: IProcessBuilder

Invokes a service by path.
  • servicePath: IContext -> String - The path of the service. If the path starts with '/', it is considered a global path and not transformed; otherwise, it is prepended with '/Services/'.
  • call: IContext, TSvc -> - The action performing the call.
  • flags: ExecutionFlags - Optional. The activity execution flags.

Invoke<TSvc>: IProcessBuilder

Invokes an injected service.
  • service: TSvc - An instance of the service.
  • call: IContext, TSvc -> - The action performing the call.
  • flags: ExecutionFlags - Optional. The activity execution flags.

Exec: IProcessBuilder

Executes an arbitrary action.
  • action: IContext -> - The action to execute.

ExecAndSave: IProcessBuilder

Executes an arbitrary action and saves the current process state to the directory.
  • action: IContext -> - The action to execute.

ExecAsync: IProcessBuilder

Executes an arbitrary asynchronous action.
  • action: IContext -> Task - The action to execute (usually async method).

StartProcess<TIn, TOut>: IProcessBuilder

Starts a process.
  • workflowPath: IContext -> String - The path of the workflow defining the process.
  • arg: IContext -> TIn - The input message of the initializer.
  • result: IContext, String -> TOut - The action processing the result. The second argument of the action is the pid of the new process.

JoinProcess: IProcessBuilder

Waits for a process to finish.
  • pid: IContext -> String - Pid of the process to wait.
  • waitingFinished: IContext -> - Optional. The action to perform when the waiting is finished.

Enqueue<TMsg>: IProcessBuilder

Puts a message to a subset. Blocks if the set has limited capacity and it's full.
  • subset: IContext -> String - The path of the subset. If the path starts with '/', it is considered a global path of a subset; otherwise, it is considered a path of a local subset. In the later case the value will be transformed to the global path '/Sets/Local/[pid]/[subset]'.
  • messageName: IContext -> String - Optional. The message name.
  • message: IContext -> TMsg - The message data.
  • format: IContext -> MessageFormat - The format of the serialized message.
  • waitingFinished: IContext -> - Optional. The action to perform when the waiting is finished.

Dequeue<TMsg>: IProcessBuilder

Picks the next message in a subset, processes it and removes from the subset
in a single transaction.

The messages are picked in the default order i.e. the order close to that in which they
were put to the subset.
  • subset: IContext -> String - The path of the subset. If the path starts with '/', it is considered a global path of a subset; otherwise, it is considered a path of a local subset. In the later case the value will be transformed to the global path '/Sets/Local/[pid]/[subset]'.
  • message: IContext, TMsg -> - The action processing the message.

Lock: IProcessBuilder

Locks specified resources.
  • resources: IContext -> IEnumerable<string> - The resources to lock. Each resource is a path of a subset with System.Int32 message type. If the path starts with '/', it is considered a global path of a subset; otherwise, it is considered a path of a local subset. In the later case the value will be transformed to the global path '/Sets/Local/[pid]/[subset]'.
  • owner: IContext -> String - An arbitrary string identifying the owner of the lock.
  • wait: IContext -> Boolean - Whether to until a resource is unlocked if it's locked by another owner.
  • result: IContext, LockFailure[] -> - Optional. The action to perform after the operation. The second argument is the collection of failed locks. If this collection is empty, all the resources has been locked successfully. If the operation waits for unlocks, the locks never fail.

BeginLock: IProcessBuilder

Locks specified resources and opens a block within which the resources are locked. At the end of the block the resources are unlocked automatically.
  • resources: IContext -> IEnumerable<string> - The resources to lock. Each resource is a path of a subset with System.Int32 message type. If the path starts with '/', it is considered a global path of a subset; otherwise, it is considered a path of a local subset. In the later case the value will be transformed to the global path '/Sets/Local/[pid]/[subset]'.
  • owner: IContext -> String - An arbitrary string identifying the owner of the lock.
  • wait: IContext -> Boolean - Whether to until a resource is unlocked if it's locked by another owner.
  • result: IContext, LockFailure[] -> - Optional. The action to perform after the operation. The second argument is the collection of failed locks. If this collection is empty, all the resources has been locked successfully. If the operation waits for unlocks, the locks never fail.

Unlock: IProcessBuilder

Unlocks specified resources.
  • resources: IContext -> IEnumerable<string> - The resources to unlock. Each resource is a path of a subset with System.Int32 message type. If the path starts with '/', it is considered a global path of a subset; otherwise, it is considered a path of a local subset. In the later case the value will be transformed to the global path '/Sets/Local/[pid]/[subset]'.
  • owner: IContext -> String - An arbitrary string identifying the owner of the lock.

WaitUntil: IProcessBuilder

Waits until a specified moment.
  • moment: IContext -> DateTime -
  • waitingFinished: IContext -> - Optional. The action to perform when the waiting is finished.

WaitAny: IProcessBuilder

Opens a block where various waiting statements may be waited simultaneously.

Try: IProcessBuilder

Opens an exception handling block.

Catch<TException>: IProcessBuilder

Catches exceptions of a specified type.
  • handler: IContext, TException -> - The action to perform to handle an exception.

Finally: IProcessBuilder

Opens a block executed regardless of whether an exception was thrown in an exception handling block.

Throw<TException>: IProcessBuilder

Throws an exception.
  • exception: IContext -> TException - The exception to throw.

End: IProcessBuilder

Closes a block.

Name: IProcessBuilder

Assigns a name to the next activity.
  • name: String - The name to assign.

Breakpoint: IProcessBuilder

Places a breakpoint.
  • name: String - Name of the breakpoint.

Finish: IProcessBuilder

Finishes the process.

ProcessBuilderException : Exception

The exception thrown by the process builder.

IContext

  • Pid: String - The id of the current process.
  • ProcessorName: String - The name of the processor in the directory.
  • ServicesProvider: IServicesProvider.
  • Log: ILog.

IInitializationContext

  • ServicesProvider: IServicesProvider.
  • LockManager: ILockManager.
  • ProcessesManager: IProcessesManager.
  • Log: ILog.

ILockManager

Lock

Locks specified resources.

Returns the collection of failed locks. It's empty if all locks succeeded.
  • resources: IEnumerable<String> - The resources to lock.
  • owner: String - The owner of the lock.

Unlock

Unlocks specified resources.
  • resources: IEnumerable<String> - The resources to unlock.
  • owner: String - The owner of the lock.

LockFailure

  • Resource: String - The resource on which the locking is failed.
  • Owner: String - The current owner of the resource.

ILog

The log.

Use the methods accepting strings to write constant messages. If a message is costly to evaluate, use lambdas. These lambdas will be evaluated only if the message passes the logging level.

Trace

  • message: String - The message.

Trace

  • message: ->String - The message.

Info

  • message: String - The message.

Info

  • message: ->String - The message.

Warning

  • message: String - The message.

Warning

  • message: ->String - The message.

Warning

  • message: String - The message.
  • ex: Exception - The exception.

Warning

  • message: ->String - The message.
  • ex: Exception - The exception.

Error

  • message: String - The message.

Error

  • message: ->String - The message.

Error

  • message: String - The message.
  • ex: Exception - The exception.

Error

  • message: ->String - The message.
  • ex: Exception - The exception.

Fatal

  • message: String - The message.

Fatal

  • message: ->String - The message.

Fatal

  • message: String - The message.
  • ex: Exception - The exception.

Fatal

  • message: ->String - The message.
  • ex: Exception - The exception.

IProcessDefinition

DefineLocalSets

  • bld: ISetsBuilder.

DefineProcess

  • process: IProcessBuilder.

IProcessesManager

StartProcess<TIn, TOut>: ProcessStartResult<TOut>

Starts a process.

Returns the message returned by the initializer of the workflow and the pid of the started process.
  • workflow: String - A path or id of the workflow.
  • args: TIn - The input message.

ProcessStartResult<T> (struct)

The information on a started process.
  • Pid: String - The process id.
  • ProcessorName: String - The name of the processor selected to execute the process.
  • Result: T - The return message of the workflow initializer.

IServicesProvider

GetService<TSvc>: TSvc

Returns an instance of the service registered in the directory.
  • servicePath: String - The path of the service. If the path starts with '/', it is considered a global path and not transformed; otherwise, it is prepended with '/Services/'.

ISetsBuilder

Set: ISetsBuilder

Defines a local set.
  • name: String - Name of the set, so that the path to the set will be '/Sets/Local/[pid]/[subset]'.
  • messageType: Type - The message type of the set.
  • capacity: Int32 - Optional. The capacity of the set (default is 0 i.e. unlimited).
  • acl: ISetPermissionBuilder -> ISetPermissionBuilder - Optional. The action to build an ACL of the set. If not specified, the set will be assigned the default ACL i.e. those who can start the workflow, can put to the set; those who see workflow, can read from the set.

ISetPermissionBuilder

AllowGetTo: ISetPermissionBuilder

Grants the permission to get messages from a set.
  • role: String - The role to be granted the permission.

AllowPutTo: ISetPermissionBuilder

Grants the permission to put messages into a set.
  • role: String - The role to be granted the permission.

MessageFormat (enum)

  • TextXml - XML text.
  • BinXml - Binary encoded XML.
  • GZipXml - XML compressed with GZip.

ExecutionFlags (enum)

  • None - No flags.
  • NoTransaction - Don't wrap an activity into transaction.
  • DontSave - Don't save the process state after an activity.
  • DontRetry - Don't retry an activity.

MessageProperty (enum)

Which property to use in sorting of directory entries.
  • Default.
  • Name.
  • UpdatedOn.
  • CreatedOn.

SortOrder (enum)

  • Asc.
  • Desc.

Path (attribute)

Specifies a path of a workflow under '/Workflows' folder.

For example, for a workflow class named 'MyWorkflow' path values will give the following global paths:
  • '' (default) : '/Workflows/MyWorkflow'
  • 'MySystem' : '/Workflows/MySystem/MyWorkflow'
  • 'MySystem/MySubsystem' : '/Workflows/MySystem/MySubsystem/MyWorkflow'
  • path: String - The path under '/Workflows' folder.

AllowStartTo (attribute)

Allows a role to start processes of a workflow.
  • role: String - The name of the role.

AllowExecuteTo (attribute)

Allows a role to execute processes of a workflow.
  • role: String - The name of the role.

Service (attribute)

Marks a field or property for the service injection.
  • servicePath: String - Path of a service under '/Services' folder. For example, suppose you have a service container '/Services/Container' with a service 'MyService'. Then the path you need to specify to inject the service is 'Container/MyService'.

Last edited Jan 30, 2014 at 6:43 PM by dbratus, version 5

Comments

No comments yet.