Class: TransactionalOutbox::Relay::WorkerSet::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/transactional_outbox/relay/worker_set/processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(worker_set) ⇒ Processor

Returns a new instance of Processor.



7
8
9
10
# File 'lib/transactional_outbox/relay/worker_set/processor.rb', line 7

def initialize(worker_set)
  @worker_set = worker_set
  @db = TransactionalOutbox::Database.new
end

Instance Method Details

#callObject

rubocop:disable Metrics/MethodLength



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/transactional_outbox/relay/worker_set/processor.rb', line 12

def call # rubocop:disable Metrics/MethodLength
  @retry_counter = 0

  loop do
    queues = db.fetch_queues

    process_queues(queues)

    break if config.test_environment

    @retry_counter = 0
  rescue StandardError => e
    config.logger&.error("Exception: #{e}, trying to retry...")

    raise e if @retry_counter >= config.relay.max_runner_retries_count

    @retry_counter += 1

    sleep(calculate_retry_delay)

    retry
  end
end