Class: Asynk::Publisher
- Inherits:
-
Object
- Object
- Asynk::Publisher
- Defined in:
- lib/asynk/publisher.rb
Defined Under Namespace
Classes: PublisherError
Class Method Summary collapse
- .generate_message_id(legnth = 8) ⇒ Object
- .publish(routing_key, params = {}) ⇒ Object
- .sync_publish(routing_key, params = {}) ⇒ Object
Class Method Details
.generate_message_id(legnth = 8) ⇒ Object
23 24 25 |
# File 'lib/asynk/publisher.rb', line 23 def (legnth = 8) SecureRandom.hex(legnth) end |
.publish(routing_key, params = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/asynk/publisher.rb', line 6 def publish(routing_key, params = {}) global_start_time = Asynk::Benchmark.start if Asynk.config[:publisher_execution_time] = params.delete(:message_id) || Asynk.broker.pool.with do |channel, exchange, reply_queue| exchange.publish(params.to_json, message_id: , routing_key: routing_key) end if Asynk.config[:publisher_execution_time] Asynk.logger.info "Sending async message #{routing_key}:#{} with params: #{params}. Completed In: #{Asynk::Benchmark.end(global_start_time)} ms." end end |
.sync_publish(routing_key, params = {}) ⇒ Object
19 20 21 |
# File 'lib/asynk/publisher.rb', line 19 def sync_publish(routing_key, params = {}) Asynk::SyncPublisher.new(routing_key, params).send end |