Class: AwsSqsMoniter::Configuration::QueueConfiguration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validatable

#errors, #valid?

Constructor Details

#initialize(name) ⇒ QueueConfiguration

Returns a new instance of QueueConfiguration.



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

def initialize name
  @name = name
  @delay_seconds = 0
  @message_retention_period = 1_209_600
  @visibility_timeout = 30
end

Instance Attribute Details

#delay_secondsObject

Returns the value of attribute delay_seconds.



13
14
15
# File 'lib/aws_sqs_moniter/configuration/queue_configuration.rb', line 13

def delay_seconds
  @delay_seconds
end

#message_retention_periodObject

Returns the value of attribute message_retention_period.



13
14
15
# File 'lib/aws_sqs_moniter/configuration/queue_configuration.rb', line 13

def message_retention_period
  @message_retention_period
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/aws_sqs_moniter/configuration/queue_configuration.rb', line 17

def name
  @name
end

#visibility_timeoutObject

Returns the value of attribute visibility_timeout.



13
14
15
# File 'lib/aws_sqs_moniter/configuration/queue_configuration.rb', line 13

def visibility_timeout
  @visibility_timeout
end

Instance Method Details

#copy_onto(queue) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/aws_sqs_moniter/configuration/queue_configuration.rb', line 40

def copy_onto queue
  queue.delay_seconds = delay_seconds
  queue.message_retention_period = message_retention_period
  queue.visibility_timeout = visibility_timeout

  redrive_policy.copy_onto queue.redrive_policy if queue.respond_to? :redrive_policy
end

#redrive_policyObject



19
20
21
# File 'lib/aws_sqs_moniter/configuration/queue_configuration.rb', line 19

def redrive_policy
  @redrive_policy ||= RedrivePolicyConfiguration.new self
end

#validateObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aws_sqs_moniter/configuration/queue_configuration.rb', line 23

def validate
  unless (0..900).include? delay_seconds
    errors << "#{name}.delay_seconds must be in the range 0..900"
  end

  unless (60..1_209_600).include? message_retention_period
    errors << "#{name}.message_retention_period must be in the range 60..1209600"
  end

  unless (0..43_200).include? visibility_timeout
    errors << "#{name}.visibility_timeout must be in the range 0..43200"
  end

  redrive_policy.valid?
  errors.push *(redrive_policy.errors)
end