Class: AwsSqsMoniter::Configuration::RedrivePolicyConfiguration

Inherits:
Object
  • Object
show all
Includes:
Validatable
Defined in:
lib/aws_sqs_moniter/configuration/redrive_policy_configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validatable

#errors, #valid?

Constructor Details

#initialize(owner) ⇒ RedrivePolicyConfiguration

Returns a new instance of RedrivePolicyConfiguration.



6
7
8
9
10
# File 'lib/aws_sqs_moniter/configuration/redrive_policy_configuration.rb', line 6

def initialize owner
  @owner = owner
  @enabled = true
  @max_receive_count = 10
end

Instance Attribute Details

#dead_letter_queueObject

Returns the value of attribute dead_letter_queue.



12
13
14
# File 'lib/aws_sqs_moniter/configuration/redrive_policy_configuration.rb', line 12

def dead_letter_queue
  @dead_letter_queue
end

#enabledObject

Returns the value of attribute enabled.



12
13
14
# File 'lib/aws_sqs_moniter/configuration/redrive_policy_configuration.rb', line 12

def enabled
  @enabled
end

#max_receive_countObject

Returns the value of attribute max_receive_count.



12
13
14
# File 'lib/aws_sqs_moniter/configuration/redrive_policy_configuration.rb', line 12

def max_receive_count
  @max_receive_count
end

Instance Method Details

#copy_onto(redrive_policy) ⇒ Object



26
27
28
29
30
# File 'lib/aws_sqs_moniter/configuration/redrive_policy_configuration.rb', line 26

def copy_onto redrive_policy
  redrive_policy.enabled = enabled
  redrive_policy.max_receive_count = max_receive_count
  redrive_policy.dead_letter_queue = dead_letter_queue
end

#validateObject



16
17
18
19
20
21
22
23
24
# File 'lib/aws_sqs_moniter/configuration/redrive_policy_configuration.rb', line 16

def validate
  unless (1..1000).include? max_receive_count
    errors << "#{@owner.name}.redrive_policy.max_receive_count must be in the range 1..1000"
  end

  if enabled && dead_letter_queue.blank?
    errors << "#{@owner.name}.redrive_policy.dead_letter_queue is required"
  end
end