Class: AWS::SimpleWorkflow::HistoryEvent

Inherits:
Object
  • Object
show all
Includes:
Core::Model
Defined in:
lib/aws/simple_workflow/history_event.rb

Overview

Getting History Events

History events belong to workflow executions. You can get them from an execution two ways:

1) By enumerating events from the execution

workflow_execution.events.each do |event|
  # ...
end

2) By enumerating events from the context of a DecisionTask:

workflow_execution.decision_tasks.poll do |decision_task|
  decision_task.events.each do |event|
  end
end

History Event Attributes

All history events respond to the following 4 methods:

For a complete list of event types and a complete list of attributes returned with each event type, see the service API documentation.

Because the service returns attributes with camelCase name the structure returned by #attributes allows you to access attributes by their snake_case name or their camelCase name:

event.attributes.workflow_type
event.attributes['workflowType']

See Attributes for more information about working with the returned attributes.

Defined Under Namespace

Classes: Attributes

Instance Attribute Summary collapse

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods included from Core::Model

#client, #config_prefix

Constructor Details

#initialize(workflow_execution, details) ⇒ HistoryEvent

Returns a new instance of HistoryEvent.

Parameters:

  • workflow_execution (WorkflowExecution)
  • details (Hash, String)

    A hash or JSON string describing the history event.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/aws/simple_workflow/history_event.rb', line 68

def initialize workflow_execution, details

  @workflow_execution = workflow_execution
  @details = details.is_a?(String) ? JSON.parse(details) : details
  @event_type = @details['eventType']
  @event_id = @details['eventId']
  @created_at = Time.at(@details['eventTimestamp'])

  attributes_key = "#{event_type}EventAttributes"
  attributes_key[0] = attributes_key[0,1].downcase
  attribute_data = @details[attributes_key] || {}
  @attributes = Attributes.new(workflow_execution, attribute_data)

  super

end

Instance Attribute Details

#attributesAttributes (readonly)

Returns an object that provides hash-like access to the history event attributes.

Returns:

  • (Attributes)

    Returns an object that provides hash-like access to the history event attributes.



101
102
103
# File 'lib/aws/simple_workflow/history_event.rb', line 101

def attributes
  @attributes
end

#created_atTime (readonly)

Returns When the event history was created.

Returns:

  • (Time)

    When the event history was created.



97
98
99
# File 'lib/aws/simple_workflow/history_event.rb', line 97

def created_at
  @created_at
end

#event_idInteger (readonly) Also known as: id

Returns the event id.

Returns:

  • (Integer)

    Returns the event id.



93
94
95
# File 'lib/aws/simple_workflow/history_event.rb', line 93

def event_id
  @event_id
end

#event_typeString (readonly)

Returns the name of the history event type.

Returns:

  • (String)

    Returns the name of the history event type.



90
91
92
# File 'lib/aws/simple_workflow/history_event.rb', line 90

def event_type
  @event_type
end

#workflow_executionWorkflowExecution (readonly)

Returns The workflow execution this history event belongs to.

Returns:



87
88
89
# File 'lib/aws/simple_workflow/history_event.rb', line 87

def workflow_execution
  @workflow_execution
end

Instance Method Details

#inspectObject



120
121
122
# File 'lib/aws/simple_workflow/history_event.rb', line 120

def inspect
  "<#{self.class.name} #{to_h.inspect}>"
end

#to_hHash

Returns a hash representation of the event.

Returns:

  • (Hash)

    Returns a hash representation of the event.



104
105
106
107
108
109
110
111
# File 'lib/aws/simple_workflow/history_event.rb', line 104

def to_h
  {
    :event_type => event_type,
    :event_id => event_id,
    :created_at => created_at,
    :attributes => attributes.to_h,
  }
end

#to_jsonString

Returns a JSON representation of this workflow execution.

Returns:

  • (String)

    Returns a JSON representation of this workflow execution.



115
116
117
# File 'lib/aws/simple_workflow/history_event.rb', line 115

def to_json
  @details.to_json
end