class Cadence::Workflow::History::Event

Constants

CHILD_WORKFLOW_EVENTS
EVENT_TYPES

Attributes

attributes[R]
id[R]
timestamp[R]
type[R]

Public Class Methods

new(raw_event) click to toggle source
# File lib/cadence/workflow/history/event.rb, line 35
def initialize(raw_event)
  @id = raw_event.eventId
  @timestamp = Utils.time_from_nanos(raw_event.timestamp)
  @type = CadenceThrift::EventType::VALUE_MAP[raw_event.eventType]
  @attributes = extract_attributes(raw_event)

  freeze
end

Public Instance Methods

decision_id() click to toggle source

Returns the ID of the first event associated with the current event, referred to as a “decision” event. Not related to DecisionTask.

# File lib/cadence/workflow/history/event.rb, line 46
def decision_id
  case type
  when 'TimerFired'
    attributes.startedEventId
  when 'WorkflowExecutionSignaled'
    1 # fixed id for everything related to current workflow
  when *EVENT_TYPES
    attributes.scheduledEventId
  when *CHILD_WORKFLOW_EVENTS
    attributes.initiatedEventId
  else
    id
  end
end

Private Instance Methods

extract_attributes(raw_event) click to toggle source
# File lib/cadence/workflow/history/event.rb, line 63
def extract_attributes(raw_event)
  attributes_argument = "#{type}EventAttributes"
  attributes_argument[0] = attributes_argument[0].downcase
  raw_event.public_send(attributes_argument)
end