Class: NNQ::SUB0

Inherits:
Socket show all
Defined in:
lib/nnq/pub_sub.rb

Overview

SUB side of the pub/sub pattern (nng sub0). Applies local byte-prefix filtering. Empty subscription set means no messages are delivered — matching nng (unlike pre-4.x ZeroMQ). Defaults to dialing.

Instance Attribute Summary

Attributes inherited from Socket

#options

Instance Method Summary collapse

Methods inherited from Socket

#all_peers_gone, bind, #bind, #close, #close_read, connect, #connect, #connection_count, #frozen_binary, #initialize, #last_endpoint, #monitor, #peer_connected, #raw?, #reconnect_enabled, #reconnect_enabled=

Constructor Details

This class inherits a constructor from NNQ::Socket

Instance Method Details

#receiveString?

Returns:

  • (String, nil)


58
59
60
# File 'lib/nnq/pub_sub.rb', line 58

def receive
  Reactor.run { @engine.routing.receive }
end

#subscribe(prefix) ⇒ Object

Subscribes to prefix. Bytes-level match. The empty string matches everything.

Parameters:

  • prefix (String)


44
45
46
# File 'lib/nnq/pub_sub.rb', line 44

def subscribe(prefix)
  Reactor.run { @engine.routing.subscribe(prefix) }
end

#unsubscribe(prefix) ⇒ Object

Removes a previously-added subscription. No-op if not present.

Parameters:

  • prefix (String)


52
53
54
# File 'lib/nnq/pub_sub.rb', line 52

def unsubscribe(prefix)
  Reactor.run { @engine.routing.unsubscribe(prefix) }
end