Class: Moleculer::Transporters::Base

Inherits:
Object
  • Object
show all
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.

Direct Known Subclasses

Fake, Redis

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.

Parameters:



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.

Parameters:

  • packet (Moleculer::Packet::Base)

    the packet to publish to the network.

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/moleculer/transporters/base.rb', line 27

def publish(_packet)
  raise NotImplementedError
end

#startObject

Starts the transporter, and activates all of the subscriptions. The subscriptions should not start consuming until the start method has been called.

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/moleculer/transporters/base.rb', line 34

def start
  raise NotImplementedError
end

#stopObject

Stops the transporter, and stops all subscriptions from consuming

Raises:

  • (NotImplementedError)


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

Parameters:

  • channel (String)

    the channel to which to subscribe

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/moleculer/transporters/base.rb', line 19

def subscribe(_channel, &_block)
  raise NotImplementedError
end