Class: Proletariat::Publisher

Inherits:
PoolableActor
  • Object
show all
Includes:
Concerns::Logging
Defined in:
lib/proletariat/publisher.rb

Overview

Public: Receives messages and publishes them to a RabbitMQ topic exchange.

Instance Method Summary collapse

Methods included from Concerns::Logging

#log_info

Methods inherited from PoolableActor

#on_message, pool

Methods included from ActorCommon

included, #on_event

Instance Method Details

#cleanupObject

Public: Closes the Bunny::Channel if open.

Returns nil.



11
12
13
14
15
# File 'lib/proletariat/publisher.rb', line 11

def cleanup
  @channel.close if @channel

  nil
end

#work(message) ⇒ Object

Public: Push a Message to a RabbitMQ topic exchange.

message - A Message to send.

Returns nil.



22
23
24
25
26
27
28
# File 'lib/proletariat/publisher.rb', line 22

def work(message)
  if message.is_a?(Message)
    exchange.publish(message.body, routing_key: message.to,
                                   persistent: !Proletariat.test_mode?,
                                   headers: message.headers)
  end
end