Class: OMQ::PUB

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

Overview

PUB socket — publish messages to all matching subscribers.

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 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, on_mute: :drop_newest, conflate: false, backend: nil) ⇒ PUB

Returns a new instance of PUB.

Parameters:

  • endpoints (String, nil) (defaults to: nil)

    endpoint to bind/connect

  • linger (Integer) (defaults to: 0)

    linger period in seconds

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

    mute strategy for slow subscribers

  • conflate (Boolean) (defaults to: false)

    keep only latest message per topic

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

    :ruby (default) or :ffi



15
16
17
18
# File 'lib/omq/pub_sub.rb', line 15

def initialize(endpoints = nil, linger: 0, on_mute: :drop_newest, conflate: false, backend: nil)
  init_engine(:PUB, linger: linger, on_mute: on_mute, conflate: conflate, backend: backend)
  attach_endpoints(endpoints, default: :bind)
end