Class: NulogyMessageBusConsumer::Steps::DeduplicateMessages

Inherits:
Object
  • Object
show all
Defined in:
lib/nulogy_message_bus_consumer/steps/deduplicate_messages.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ DeduplicateMessages

Returns a new instance of DeduplicateMessages.



4
5
6
# File 'lib/nulogy_message_bus_consumer/steps/deduplicate_messages.rb', line 4

def initialize(logger)
  @logger = logger
end

Instance Method Details

#call(message:, **_) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nulogy_message_bus_consumer/steps/deduplicate_messages.rb', line 8

def call(message:, **_)
  return :success if duplicate_exists?(message)

  result = :unknown
  ProcessedMessage.transaction(joinable: false) do
    result = yield

    record_processed_message(message) if result == :success
  end

  result
end