Class | Ruote::Worker |
In: |
lib/ruote/worker.rb
|
Parent: | Object |
Workers fetch ‘msgs’ and ‘schedules’ from the storage and process them.
Read more at ruote.rubyforge.org/configuration.html
EXP_ACTIONS | = | %w[ reply cancel fail receive dispatched pause resume ] | ||
PROC_ACTIONS | = | %w[ cancel kill pause resume ].collect { |a| a + '_process' } | ‘apply’ is comprised in ‘launch’ ‘receive’ is a ParticipantExpression alias for ‘reply‘ | |
DISP_ACTIONS | = | %w[ dispatch dispatch_cancel dispatch_pause dispatch_resume ] |
context | [R] | |
name | [R] | |
run_thread | [R] | |
state | [R] | |
storage | [R] |
Returns true if the engine system is inactive, ie if all the process instances are terminated or are stuck in an error.
NOTE : for now, if a branch of a process is in error while another is still running, this method will consider the process instance inactive (and it will return true if all the processes are considered inactive).
Joins the run thread of this worker (if there is no such thread, this method will return immediately, without any effect).
Some storage implementations cache information before a step begins, reducing the number of requests to the underlying data system. This begin step notifies the storage that a new step is on and it should refresh the cached information.
The storage implementation, if it supports this feature, will cache the information in the thread local info.
Handles a ‘cancel_process’ msg (translates it into a "cancel root expression of that process" msg).
Also works for ‘kill_process’ msgs.
This default implementation dumps error information to $stderr as soon as step intercepts the error.
Normally such information should only appear when developing a storage, the information here is thus helpful for storage developers. If such info is emitted in production or in application development, you should pass the info to the storage developer/maintainer.
Feel free to override this method if you need it to output to a channel different than $stderr (or rebind $stderr).
The second parameter is "msg", if the error occured while processing a msg, then this message is passed to handle_step_error. msg will be nil if the error occurred while doing get_msgs or get_schedules.
Processes one msg.
Will return false immediately if the msg reservation failed (another worker grabbed the message.
Else will execute the action ordered in the msg, and return true.
Exceptions in execution are intercepted here and passed to the engine‘s (context‘s) error_handler.
Gets schedules from the storage and if their time has come, turns them into msg (for immediate execution).
Reputs a doc or a msg.
Used by certain storage implementations to pass documents around workers or to reschedule msgs (see ruote-swf).
This action resparks a stalled workflow instance. It‘s usually triggered via Dashboard#respark
It‘s been made into a msg (worker action) in order to facilitate migration tooling (ruote-swf for example).
One worker step, fetches schedules and triggers those whose time has came, then fetches msgs and processes them.
In order not to hammer the storage for msgs too much, take a rest.
If the number of processed messages is more than zero, there are probably more msgs coming, no time for a rest…
If @sleep_time is nil (restless_worker option set to true), the worker will never rest.