Class: ZZQ::Broker

Inherits:
Socket show all
Defined in:
lib/zzq/broker.rb

Overview

MQTT broker. Owns the session map (by client id), retained-message store, topic trie, and shared-subscription groups.

M3 stub: constructor + #build_routing. CONNECT handling, subscription matching, and retained store come in M7.

Instance Attribute Summary

Attributes inherited from Socket

#options

Instance Method Summary collapse

Methods inherited from Socket

#all_peers_gone, bind, #bind, #close, #coerce_binary, connect, #connect, #connection_count, #initialize, #last_endpoint, #monitor, #peer_connected

Constructor Details

This class inherits a constructor from ZZQ::Socket

Instance Method Details

#build_routing(engine) ⇒ Object



12
13
14
# File 'lib/zzq/broker.rb', line 12

def build_routing(engine)
  Routing::Broker.new(engine)
end

#ingest(message) ⇒ Object Also known as: <<

Inject a Message into the broker’s delivery path as if it had arrived via a PUBLISH packet. Fans out to every matching subscriber. Use this to bridge non-MQTT inputs (NNQ, OMQ, a file) into broker topics.

Raises:



25
26
27
28
29
# File 'lib/zzq/broker.rb', line 25

def ingest(message)
  raise NotInAsyncContext unless Async::Task.current?
  @engine.routing.dispatch_message(message)
  nil
end

#session_countObject

Number of currently-connected MQTT sessions.



18
# File 'lib/zzq/broker.rb', line 18

def session_count = @engine.routing.session_count