Class: Orchestrated::MessageDelivery

Inherits:
Object
  • Object
show all
Defined in:
lib/orchestrated/message_delivery.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(orchestrated, method_name, args, orchestration_id) ⇒ MessageDelivery

Returns a new instance of MessageDelivery.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
# File 'lib/orchestrated/message_delivery.rb', line 5

def initialize(orchestrated, method_name, args, orchestration_id)
  raise ArgumentError.new('all arguments to MessageDelivery constructor are required') unless
    orchestrated and method_name and args and orchestration_id
  self.orchestrated = orchestrated
  self.method_name  = method_name
  self.args         = args
  self.orchestration_id = orchestration_id
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



3
4
5
# File 'lib/orchestrated/message_delivery.rb', line 3

def args
  @args
end

#method_nameObject

Returns the value of attribute method_name.



3
4
5
# File 'lib/orchestrated/message_delivery.rb', line 3

def method_name
  @method_name
end

#orchestratedObject

Returns the value of attribute orchestrated.



3
4
5
# File 'lib/orchestrated/message_delivery.rb', line 3

def orchestrated
  @orchestrated
end

#orchestration_idObject

Returns the value of attribute orchestration_id.



3
4
5
# File 'lib/orchestrated/message_delivery.rb', line 3

def orchestration_id
  @orchestration_id
end

Instance Method Details

#failureObject

delayed_job hands us this message after max_attempts are exhausted



25
26
27
28
# File 'lib/orchestrated/message_delivery.rb', line 25

def failure
  orchestration = Orchestration.find(self.orchestration_id)
  orchestration.message_delivery_failed
end

#performObject



14
15
16
17
18
19
20
21
22
# File 'lib/orchestrated/message_delivery.rb', line 14

def perform
  orchestration = Orchestration.find(self.orchestration_id)

  orchestrated.orchestration = orchestration
  orchestrated.send(method_name, *args)
  orchestrated.orchestration = nil

  orchestration.message_delivery_succeeded
end