Class: AwsSqsMoniter::DeadLetters::Retrier

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_sqs_moniter/dead_letters/retrier.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger = nil) ⇒ Retrier

Returns a new instance of Retrier.



4
5
6
7
# File 'lib/aws_sqs_moniter/dead_letters/retrier.rb', line 4

def initialize logger = nil
  @publisher = AwsSqsMoniter::MessagePublisher.new
  @logger = logger || Shoryuken::Logging.logger
end

Instance Method Details

#retry(scope) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/aws_sqs_moniter/dead_letters/retrier.rb', line 9

def retry scope
  return if scope.count == 0

  count = 0
  scope.each do |message|
    count += 1
    @publisher.publish message.message
    message.delete
  end

  @logger.info "Retried #{count} dead letter(s)."
end