class DirtyPipeline::Event
Constants
- ABORT
- FAILURE
- NEW
- RETRY
- START
- SUCCESS
Attributes
data[R]
error[R]
id[R]
tx_id[R]
Public Class Methods
create(transition, *args, tx_id:, **kwargs)
click to toggle source
# File lib/dirty_pipeline/event.rb, line 13 def self.create(transition, *args, tx_id:, **kwargs) args << kwargs unless kwargs.empty? new( data: { # FIXME: SecureRandom "uuid" => SecureRandom.uuid, "transaction_uuid" => tx_id, "transition" => transition, "args" => args, } ) end
new(options = {}, data: nil, error: nil)
click to toggle source
# File lib/dirty_pipeline/event.rb, line 36 def initialize(options = {}, data: nil, error: nil) unless options.empty? options_hash = options.to_h data ||= options_hash["data"] error ||= options_hash["error"] end data_hash = data.to_h @tx_id = data_hash.fetch("transaction_uuid") @id = data_hash.fetch("uuid") transition = data_hash.fetch("transition") args = data_hash.fetch("args").to_a @data = { "uuid" => @id, "transaction_uuid" => @tx_id, "transition" => transition, "args" => args, "created_at" => Time.now.utc.iso8601, "cache" => {}, "attempts_count" => 1, "status" => NEW, }.merge(data_hash) @error = error end
Public Instance Methods
assign_changes(changes)
click to toggle source
# File lib/dirty_pipeline/event.rb, line 114 def assign_changes(changes) @data["changes"] = changes end
attempt_retry!()
click to toggle source
# File lib/dirty_pipeline/event.rb, line 109 def attempt_retry! @data["updated_at"] = Time.now.utc.iso8601 @data["attempts_count"] = attempts_count + 1 end
attempts_count()
click to toggle source
# File lib/dirty_pipeline/event.rb, line 105 def attempts_count @data["attempts_count"].to_i end
complete()
click to toggle source
# File lib/dirty_pipeline/event.rb, line 118 def complete @data.merge!( "updated_at" => Time.now.utc.iso8601, "status" => SUCCESS, ) end
destination()
click to toggle source
# File lib/dirty_pipeline/event.rb, line 74 def destination data["destination"] end
destination=(value)
click to toggle source
# File lib/dirty_pipeline/event.rb, line 78 def destination=(value) data["destination"] = value end
dup()
click to toggle source
# File lib/dirty_pipeline/event.rb, line 26 def dup self.class.new( data: data.merge( "uuid" => SecureRandom.uuid, "status" => NEW, ) ) end
link_exception(exception)
click to toggle source
# File lib/dirty_pipeline/event.rb, line 96 def link_exception(exception) @error = { "exception" => exception.class.to_s, "exception_message" => exception.message, "created_at" => Time.now.utc.iso8601, } failure! end
source()
click to toggle source
# File lib/dirty_pipeline/event.rb, line 66 def source data["source"] end
source=(value)
click to toggle source
# File lib/dirty_pipeline/event.rb, line 70 def source=(value) data["source"] = value end
to_h()
click to toggle source
# File lib/dirty_pipeline/event.rb, line 62 def to_h {data: @data, error: @error} end