Class: AwsSqsMoniter::Middleware::Server::ActiveRecord::Idempotence
- Inherits:
-
Object
- Object
- AwsSqsMoniter::Middleware::Server::ActiveRecord::Idempotence
- Defined in:
- lib/aws_sqs_moniter/middleware/server/active_record/idempotence.rb
Instance Method Summary collapse
- #call(_worker, queue, sqs_msg, _body) ⇒ Object
-
#initialize(logger: Shoryuken::Logging.logger) ⇒ Idempotence
constructor
A new instance of Idempotence.
Constructor Details
#initialize(logger: Shoryuken::Logging.logger) ⇒ Idempotence
Returns a new instance of Idempotence.
6 7 8 |
# File 'lib/aws_sqs_moniter/middleware/server/active_record/idempotence.rb', line 6 def initialize logger: Shoryuken::Logging.logger @logger = logger end |
Instance Method Details
#call(_worker, queue, sqs_msg, _body) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/aws_sqs_moniter/middleware/server/active_record/idempotence.rb', line 10 def call _worker, queue, sqs_msg, _body = TypedMessage.new sqs_msg if ProcessedMessage.exists? message_id: .id, queue: queue @logger.info middleware: 'idempotence', ignored_message_id: .id else yield ProcessedMessage.log end end |