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
All history events respond to the following 4 methods:
{#event_type}
{#event_id}
{#created_at}
{#attributes}
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 {HistoryEvent::Attributes} for more information about working with the returned attributes.
@return [Attributes] Returns an object that provides hash-like
access to the history event attributes.
@return [Time] When the event history was created.
@return [Integer] Returns the event id.
@return [String] Returns the name of the history event type.
@return [Integer] Returns the event id.
@return [WorkflowExecution] The workflow execution this history
event belongs to.
@param [WorkflowExecution] #workflow_execution
@param [Hash,String] details A hash or JSON string describing
the history event.
# 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
@private
# File lib/aws/simple_workflow/history_event.rb, line 120 def inspect "<#{self.class.name} #{to_h.inspect}>" end
@return [Hash] Returns a hash representation of the event.
# 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
@return [String] Returns a JSON representation of this workflow
execution.
# File lib/aws/simple_workflow/history_event.rb, line 115 def to_json @details.to_json end