Class: OMQ::XSUB

Inherits:
Socket show all
Includes:
Readable, Writable
Defined in:
lib/omq/pub_sub.rb

Overview

XSUB socket — like SUB but subscriptions are sent as data frames.

Constant Summary

Constants included from Writable

Writable::EMPTY_PART

Instance Attribute Summary

Attributes inherited from Socket

#engine, #last_tcp_port, #options

Instance Method Summary collapse

Methods included from Writable

#<<, #send, #wait_writable

Methods included from QueueWritable

#enqueue

Methods included from Readable

#receive, #wait_readable

Methods included from QueueReadable

#dequeue, #each, #wait

Methods inherited from Socket

#all_peers_gone, #attach_endpoints, bind, #bind, #close, #close_read, connect, #connect, #connection_count, #disconnect, #init_engine, #inspect, #last_endpoint, #monitor, #peer_connected, #reconnect_enabled=, #set_unbounded, #stop, #subscriber_joined, #unbind

Constructor Details

#initialize(endpoints = nil, linger: 0, subscribe: nil, on_mute: :block, backend: nil) ⇒ XSUB

Returns a new instance of XSUB.

Parameters:

  • endpoints (String, nil) (defaults to: nil)
  • linger (Integer) (defaults to: 0)
  • subscribe (String, nil) (defaults to: nil)

    subscription prefix; nil (default) means no subscription — send a subscribe frame explicitly.

  • on_mute (Symbol) (defaults to: :block)

    mute strategy (:block, :drop_newest, :drop_oldest)

  • backend (Symbol, nil) (defaults to: nil)

    :ruby (default) or :ffi



97
98
99
100
101
# File 'lib/omq/pub_sub.rb', line 97

def initialize(endpoints = nil, linger: 0, subscribe: nil, on_mute: :block, backend: nil)
  init_engine(:XSUB, linger: linger, on_mute: on_mute, backend: backend)
  attach_endpoints(endpoints, default: :connect)
  send("\x01#{subscribe}".b) unless subscribe.nil?
end