Class: Saga
- Inherits:
-
Object
- Object
- Saga
- Defined in:
- lib/cirrocumulus/saga.rb
Overview
Saga. Implements long-running workflows
Constant Summary collapse
- STATE_ERROR =
-1
- STATE_START =
0
- STATE_FINISHED =
255
- @@saga_names =
{}
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #dump_parameters ⇒ Object
- #handle_reply(sender, contents, options = {}) ⇒ Object
-
#initialize(id, ontology) ⇒ Saga
constructor
A new instance of Saga.
- #is_finished? ⇒ Boolean
- #tick ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id, ontology) ⇒ Saga
Returns a new instance of Saga.
20 21 22 23 24 25 26 |
# File 'lib/cirrocumulus/saga.rb', line 20 def initialize(id, ontology) @id = id @ontology = ontology @state = STATE_START @started_at = Time.now @timeout_at = nil end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
18 19 20 |
# File 'lib/cirrocumulus/saga.rb', line 18 def id @id end |
Class Method Details
.saga(saga_name = nil) ⇒ Object
8 9 10 11 |
# File 'lib/cirrocumulus/saga.rb', line 8 def saga(saga_name = nil) return @@saga_names[name] if saga_name.nil? @@saga_names[name] = saga_name end |
Instance Method Details
#dump_parameters ⇒ Object
41 42 43 |
# File 'lib/cirrocumulus/saga.rb', line 41 def dump_parameters "" end |
#handle_reply(sender, contents, options = {}) ⇒ Object
39 |
# File 'lib/cirrocumulus/saga.rb', line 39 def handle_reply(sender, contents, = {}); end |
#is_finished? ⇒ Boolean
28 29 30 |
# File 'lib/cirrocumulus/saga.rb', line 28 def is_finished? @state == STATE_ERROR || @state == STATE_FINISHED end |
#tick ⇒ Object
32 33 34 35 36 37 |
# File 'lib/cirrocumulus/saga.rb', line 32 def tick return if @timeout_at.nil? || @timeout_at > Time.now @timeout_at = nil handle_reply(nil, nil, nil) end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/cirrocumulus/saga.rb', line 45 def to_s "%s type=%s, started at %s, state=%d, params: %s" % [@id, @@saga_names[self.class.name], @started_at, @state, dump_parameters] end |