Class: Temporalio::WorkflowHistory
- Inherits:
-
Object
- Object
- Temporalio::WorkflowHistory
- Defined in:
- lib/temporalio/workflow_history.rb
Overview
Representation of a workflow’s history.
Instance Attribute Summary collapse
-
#events ⇒ Array<Api::History::V1::HistoryEvent>
readonly
History events for the workflow.
Class Method Summary collapse
-
.from_history_json(json) ⇒ WorkflowHistory
Convert a JSON string to workflow history.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compare history.
-
#to_history_json ⇒ String
Convert to history JSON.
-
#workflow_id ⇒ String
ID of the workflow, extracted from the first event.
Instance Attribute Details
#events ⇒ Array<Api::History::V1::HistoryEvent> (readonly)
Returns History events for the workflow.
17 18 19 |
# File 'lib/temporalio/workflow_history.rb', line 17 def events @events end |
Class Method Details
.from_history_json(json) ⇒ WorkflowHistory
Convert a JSON string to workflow history. This supports the JSON format exported by Temporal UI and CLI.
12 13 14 |
# File 'lib/temporalio/workflow_history.rb', line 12 def self.from_history_json(json) WorkflowHistory.new(Api::History::V1::History.decode_json(json).events.to_a) end |
Instance Method Details
#==(other) ⇒ Boolean
Compare history.
43 44 45 |
# File 'lib/temporalio/workflow_history.rb', line 43 def ==(other) other.is_a?(WorkflowHistory) && events == other.events end |
#to_history_json ⇒ String
Convert to history JSON.
35 36 37 |
# File 'lib/temporalio/workflow_history.rb', line 35 def to_history_json Api::History::V1::History.encode_json(Api::History::V1::History.new(events:)) end |
#workflow_id ⇒ String
Returns ID of the workflow, extracted from the first event.
25 26 27 28 29 30 |
# File 'lib/temporalio/workflow_history.rb', line 25 def workflow_id start = events.first&.workflow_execution_started_event_attributes raise 'First event not a start event' if start.nil? start.workflow_id end |