Class: Moleculer::Transporters::Base
- Inherits:
-
Object
- Object
- Moleculer::Transporters::Base
- Defined in:
- lib/moleculer/transporters/base.rb
Overview
All transporters inherit from this class. The Base class simply defines an interface that transporters should adhere to.
Instance Method Summary collapse
-
#initialize(config) ⇒ Base
constructor
A new instance of Base.
-
#publish(_packet) ⇒ Object
Publishes the provided packet to the transporter's message bus.
-
#start ⇒ Object
Starts the transporter, and activates all of the subscriptions.
-
#stop ⇒ Object
Stops the transporter, and stops all subscriptions from consuming.
-
#subscribe(_channel, &_block) ⇒ Object
Subscribes to the given channel on the transporter's message bus.
Constructor Details
#initialize(config) ⇒ Base
Returns a new instance of Base.
12 13 14 |
# File 'lib/moleculer/transporters/base.rb', line 12 def initialize(config) @config = config end |
Instance Method Details
#publish(_packet) ⇒ Object
Publishes the provided packet to the transporter's message bus. The publish method is expected to implement the method of translating the packet data into the channel information on which to publish.
27 28 29 |
# File 'lib/moleculer/transporters/base.rb', line 27 def publish(_packet) raise NotImplementedError end |
#start ⇒ Object
Starts the transporter, and activates all of the subscriptions. The subscriptions should not start consuming until the start method has been called.
34 35 36 |
# File 'lib/moleculer/transporters/base.rb', line 34 def start raise NotImplementedError end |
#stop ⇒ Object
Stops the transporter, and stops all subscriptions from consuming
40 41 42 |
# File 'lib/moleculer/transporters/base.rb', line 40 def stop raise NotImplementedError end |
#subscribe(_channel, &_block) ⇒ Object
Subscribes to the given channel on the transporter's message bus
19 20 21 |
# File 'lib/moleculer/transporters/base.rb', line 19 def subscribe(_channel, &_block) raise NotImplementedError end |