Module: Legion::API::SyncDispatch
- Defined in:
- lib/legion/api/sync_dispatch.rb
Class Method Summary collapse
-
.dispatch(exchange_name, routing_key, payload, envelope, timeout: 30) ⇒ Hash
Dispatch a message synchronously via AMQP using a temporary reply_to queue.
Class Method Details
.dispatch(exchange_name, routing_key, payload, envelope, timeout: 30) ⇒ Hash
Dispatch a message synchronously via AMQP using a temporary reply_to queue. Blocks until a response arrives or the timeout expires.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/legion/api/sync_dispatch.rb', line 17 def self.dispatch(exchange_name, routing_key, payload, envelope, timeout: 30) unless defined?(Legion::Transport) && Legion::Transport.respond_to?(:connected?) && Legion::Transport.connected? return envelope.merge( status: 'failed', error: { code: 503, message: 'Transport not available for sync dispatch' } ) end perform_dispatch(exchange_name, routing_key, payload, envelope, timeout) rescue StandardError => e Legion::Logging.error "[SyncDispatch] #{e.class}: #{e.}" if defined?(Legion::Logging) envelope.merge( status: 'failed', error: { code: 500, message: e. } ) end |