Class: OMQ::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/omq/options.rb

Overview

Pure Ruby socket options.

All timeouts are in seconds (Numeric) or nil (no timeout). HWM values are integers.

Constant Summary collapse

DEFAULT_HWM =
1000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(linger: Float::INFINITY) ⇒ Options

Returns a new instance of Options.

Parameters:

  • linger (Numeric) (defaults to: Float::INFINITY)

    linger period in seconds on close (default Float::INFINITY = wait forever, matching libzmq). Pass 0 for immediate drop-on-close.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/omq/options.rb', line 17

def initialize(linger: Float::INFINITY)
  @send_hwm              = DEFAULT_HWM
  @recv_hwm              = DEFAULT_HWM
  @linger                = linger
  @identity              = "".b
  @router_mandatory      = false
  @read_timeout          = nil   # seconds, nil = no timeout
  @write_timeout         = nil
  @reconnect_interval    = 0.1   # seconds; Range sets backoff min..max
  @heartbeat_interval    = nil   # seconds, nil = disabled
  @heartbeat_ttl         = nil   # seconds, nil = use heartbeat_interval
  @heartbeat_timeout     = nil   # seconds, nil = use heartbeat_interval
  @max_message_size      = nil      # bytes, nil = unlimited
  @conflate              = false
  @sndbuf                = nil   # bytes, nil = OS default
  @rcvbuf                = nil   # bytes, nil = OS default
  @on_mute               = :block   # :block, :drop_newest, :drop_oldest
  @mechanism             = Protocol::ZMTP::Mechanism::Null.new
  @qos                   = 0       # 0 = fire-and-forget, 1 = at-least-once (see omq-qos gem)
end

Instance Attribute Details

#conflateBoolean

Returns keep only the latest message per topic (default false).

Returns:

  • (Boolean)

    keep only the latest message per topic (default false)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#heartbeat_intervalNumeric?

Returns PING interval in seconds (nil = disabled).

Returns:

  • (Numeric, nil)

    PING interval in seconds (nil = disabled)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#heartbeat_timeoutNumeric?

Returns time without traffic before closing (nil = use heartbeat_interval).

Returns:

  • (Numeric, nil)

    time without traffic before closing (nil = use heartbeat_interval)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#heartbeat_ttlNumeric?

Returns TTL advertised in PING (nil = use heartbeat_interval).

Returns:

  • (Numeric, nil)

    TTL advertised in PING (nil = use heartbeat_interval)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#identityString

Returns socket identity for ROUTER addressing (default “”).

Returns:

  • (String)

    socket identity for ROUTER addressing (default “”)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#lingerNumeric

Returns linger period in seconds on close (Float::INFINITY = wait forever, 0 = immediate drop).

Returns:

  • (Numeric)

    linger period in seconds on close (Float::INFINITY = wait forever, 0 = immediate drop)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#max_message_sizeInteger?

Returns maximum message size in bytes.

Returns:

  • (Integer, nil)

    maximum message size in bytes



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#mechanismProtocol::ZMTP::Mechanism::Null, Protocol::ZMTP::Mechanism::Curve

Returns security mechanism.

Returns:

  • (Protocol::ZMTP::Mechanism::Null, Protocol::ZMTP::Mechanism::Curve)

    security mechanism



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#on_muteSymbol

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

Returns:

  • (Symbol)

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



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#qosInteger

Returns quality of service level (0 = fire-and-forget).

Returns:

  • (Integer)

    quality of service level (0 = fire-and-forget)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#rcvbufInteger?

Returns SO_RCVBUF size in bytes (nil = OS default).

Returns:

  • (Integer, nil)

    SO_RCVBUF size in bytes (nil = OS default)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#read_timeoutNumeric? Also known as: recv_timeout

Returns read timeout in seconds (nil = no timeout).

Returns:

  • (Numeric, nil)

    read timeout in seconds (nil = no timeout)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#reconnect_intervalNumeric, Range

Returns reconnect interval in seconds, or Range for exponential backoff.

Returns:

  • (Numeric, Range)

    reconnect interval in seconds, or Range for exponential backoff



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#recv_hwmInteger

Returns receive high water mark (default 1000, 0 = unbounded).

Returns:

  • (Integer)

    receive high water mark (default 1000, 0 = unbounded)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#router_mandatoryBoolean Also known as: router_mandatory?

Returns raise on unroutable messages (default false).

Returns:

  • (Boolean)

    raise on unroutable messages (default false)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#send_hwmInteger

Returns send high water mark (default 1000, 0 = unbounded).

Returns:

  • (Integer)

    send high water mark (default 1000, 0 = unbounded)



77
78
79
# File 'lib/omq/options.rb', line 77

def send_hwm
  @send_hwm
end

#sndbufInteger?

Returns SO_SNDBUF size in bytes (nil = OS default).

Returns:

  • (Integer, nil)

    SO_SNDBUF size in bytes (nil = OS default)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos

#write_timeoutNumeric? Also known as: send_timeout

Returns write timeout in seconds (nil = no timeout).

Returns:

  • (Numeric, nil)

    write timeout in seconds (nil = no timeout)



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/omq/options.rb', line 77

attr_accessor :send_hwm,  :recv_hwm,
:linger,    :identity,
:router_mandatory,  :conflate,
:read_timeout,          :write_timeout,
:reconnect_interval,
:heartbeat_interval,    :heartbeat_ttl,    :heartbeat_timeout,
:max_message_size,
:sndbuf,    :rcvbuf,
:on_mute,
:mechanism,
:qos