Skip to content

Commit

Permalink
Dynamically get default queue name from Reactor module
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriosLisenko committed Dec 5, 2023
1 parent bb4939a commit 5a29fa0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions lib/reactor/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def publish(name, data = {})
Reactor.validator.call(message)
message_data = message.__data__.to_hash
if message.at
perform_at message.at, name, message_data
event_queue.perform_at(message.at, name, message_data)
else
perform_async name, message_data
event_queue.perform_async(name, message_data)
end
end

Expand All @@ -99,6 +99,14 @@ def reschedule(name, data = {})

publish(name, data.except([:was, :if])) if data[:at].try(:future?)
end

private

def event_queue
queue_override = ENV['REACTOR_QUEUE']
queue_override ||= ::Reactor.default_queue
queue_override.present? ? set(queue: queue_override) : self
end
end

private
Expand Down
3 changes: 2 additions & 1 deletion lib/reactor/workers/concerns/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def perform_where_needed(data)

def event_queue
queue_override = ENV['REACTOR_QUEUE']
queue_override ||= ::Reactor.default_queue
queue_override.present? ? set(queue: queue_override) : self
end
end
Expand Down Expand Up @@ -62,4 +63,4 @@ def raise_unconfigured!
end
end
end
end
end

0 comments on commit 5a29fa0

Please sign in to comment.