| Class | Ruote::ProcessObserver |
| In: |
lib/ruote/util/process_observer.rb
|
| Parent: | Object |
A base class for process observers, just to provide convenience. It (heavily) sugar coats the Ruote::Observer and translate the messages into actions. Each such action is provided with pre-distilled information relevant for processes.
class WebsocketSubscriber < Ruote::ProcessObserver
# override initialize to warm-up a websocket client
def initialize(context, options={})
super
@client = WebsocketClient.new()
end
# tell the listeners that a new process launched
def on_launch(wfid, opts)
@client.publish(
"/process/launch",
{ :name => opts[:workitem].wf_name,
:wfid => wfid,
:definition => opts[:pdef],
}
)
end
# tell the listeners that a new process ended
def on_end(wfid)
@client.publish("/process/#{wfid}", { :end => true })
end
end
The ProcessObserver adheres closely to the message actions, it calls the following methods:
| on_launch: | When a process or sub-process starts |
| on_terminated: | When a process ends |
| on_error_intercepted: | When an error was intercepted |
| on_cancel: | When a process or sub-process was canceled |
| on_dispatch: | When a participant is dispatched |
| on_receive: | Whenever a workitem is received |
And others, but if you are interested in those; you might be better of using the more low-level Ruote::Observer
The methods are called with (wfid[, options])
You can provide a method-signature like:
def on_launch(wfid, options) def on_launch(wfid)
If the ProcessObserver cannot call the method with the options, it tries to call without options
The following options are provided:
| :workitem: | The workitem, if available |
| :action: | The original name of the action |
| :child: | Boolean; This is an event of a child, or sub-flow |
| :error: | The intercepted error (only provided with on_error_intercepted) |
| :pdef: | The (sub-)process definition (only provided with on_launch) |
| :variables: | The process variables, if available |
| :flavour: | The flavour of canceling (only on_cancel) |
If anywhere in your implementation an action raises an error, it is caught by the ProcessObserver and silently ignored.
| context | [R] | |
| filtered_actions | [R] | |
| options | [R] |