Class: RailwayIpc::SingletonPublisher
- Inherits:
-
Sneakers::Publisher
- Object
- Sneakers::Publisher
- RailwayIpc::SingletonPublisher
- Includes:
- Singleton
- Defined in:
- lib/railway_ipc/publisher.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ SingletonPublisher
constructor
A new instance of SingletonPublisher.
- #publish(message, published_message_store = RailwayIpc::PublishedMessage) ⇒ Object
Constructor Details
#initialize ⇒ SingletonPublisher
Returns a new instance of SingletonPublisher.
17 18 19 |
# File 'lib/railway_ipc/publisher.rb', line 17 def initialize super(exchange: self.class.exchange_name, exchange_type: :fanout) end |
Class Method Details
.exchange(exchange) ⇒ Object
7 8 9 |
# File 'lib/railway_ipc/publisher.rb', line 7 def self.exchange(exchange) @exchange_name = exchange end |
.exchange_name ⇒ Object
11 12 13 14 15 |
# File 'lib/railway_ipc/publisher.rb', line 11 def self.exchange_name raise 'Subclass must set the exchange' unless @exchange_name @exchange_name end |
Instance Method Details
#publish(message, published_message_store = RailwayIpc::PublishedMessage) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/railway_ipc/publisher.rb', line 21 def publish(, =RailwayIpc::PublishedMessage) RailwayIpc.logger.warn('DEPRECATED: Use new PublisherInstance class', ) () ensure_correlation_id() RailwayIpc.logger.info('Publishing message', ()) result = super(RailwayIpc::Rabbitmq::Payload.encode()) .(self.class.exchange_name, ) result rescue RailwayIpc::InvalidProtobuf => e RailwayIpc.logger.error('Invalid protobuf', ()) raise e end |