Class: Cadence::Workflow::History::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/cadence/workflow/history/event.rb

Constant Summary collapse

EVENT_TYPES =
%w[
  ActivityTaskStarted
  ActivityTaskCompleted
  ActivityTaskFailed
  ActivityTaskTimedOut
  ActivityTaskCanceled
  TimerFired
  RequestCancelExternalWorkflowExecutionFailed
  WorkflowExecutionSignaled
  WorkflowExecutionTerminated
  SignalExternalWorkflowExecutionFailed
  ExternalWorkflowExecutionCancelRequested
  ExternalWorkflowExecutionSignaled
  UpsertWorkflowSearchAttributes
].freeze
CHILD_WORKFLOW_EVENTS =
%w[
  StartChildWorkflowExecutionFailed
  ChildWorkflowExecutionStarted
  ChildWorkflowExecutionCompleted
  ChildWorkflowExecutionFailed
  ChildWorkflowExecutionCanceled
  ChildWorkflowExecutionTimedOut
  ChildWorkflowExecutionTerminated
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_event) ⇒ Event

Returns a new instance of Event.



35
36
37
38
39
40
41
42
# 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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



33
34
35
# File 'lib/cadence/workflow/history/event.rb', line 33

def attributes
  @attributes
end

#idObject (readonly)

Returns the value of attribute id.



33
34
35
# File 'lib/cadence/workflow/history/event.rb', line 33

def id
  @id
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



33
34
35
# File 'lib/cadence/workflow/history/event.rb', line 33

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type.



33
34
35
# File 'lib/cadence/workflow/history/event.rb', line 33

def type
  @type
end

Instance Method Details

#decision_idObject

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



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 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