Class: Temporal::Workflow::History
- Inherits:
-
Object
- Object
- Temporal::Workflow::History
- Defined in:
- lib/temporal/workflow/history.rb,
lib/temporal/workflow/history/event.rb,
lib/temporal/workflow/history/window.rb,
lib/temporal/workflow/history/event_target.rb
Defined Under Namespace
Classes: Event, EventTarget, Window
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
-
#initialize(events) ⇒ History
constructor
A new instance of History.
- #last_completed_workflow_task ⇒ Object
-
#next_window ⇒ Object
It is very important to replay the History window by window in order to simulate the exact same state the workflow was in when it processed the workflow task for the first time.
Constructor Details
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
7 8 9 |
# File 'lib/temporal/workflow/history.rb', line 7 def events @events end |
Instance Method Details
#last_completed_workflow_task ⇒ Object
14 15 16 |
# File 'lib/temporal/workflow/history.rb', line 14 def last_completed_workflow_task events.select { |event| event.type == 'WORKFLOW_TASK_COMPLETED' }.last end |
#next_window ⇒ Object
It is very important to replay the History window by window in order to simulate the exact same state the workflow was in when it processed the workflow task for the first time.
A history window consists of 3 parts:
-
Events that happened since the last window (timer fired, activity completed, etc)
-
A workflow task related events (workflow task started, completed, failed, etc)
-
Commands issued by the last workflow task (^) (schedule activity, start timer, etc)
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/temporal/workflow/history.rb', line 28 def next_window return unless peek_event window = History::Window.new while event = next_event window.add(event) break if event.type == 'WORKFLOW_TASK_COMPLETED' end # Find the end of the window by exhausting all the commands window.add(next_event) while command?(peek_event) window.freeze end |