Class: ZZQ::Options

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

Overview

Per-socket configuration. Holds both infrastructure options (linger, HWMs, reconnect) lifted from NNQ::Options, and MQTT-specific ones (keepalive, session_expiry, receive_maximum, etc.) that shape the wire behaviour.

Clients and brokers share this class; role-irrelevant fields are simply ignored by the other side.

Constant Summary collapse

DEFAULT_HWM =
1000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(linger: Float::INFINITY, send_hwm: DEFAULT_HWM, recv_hwm: DEFAULT_HWM, version: 5, client_id: nil, clean_start: true, keep_alive: 60, session_expiry_interval: 0, receive_maximum: 65_535, max_packet_size: nil, topic_alias_maximum: 0, username: nil, password: nil, will: nil, persistence: nil) ⇒ Options

Returns a new instance of Options.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/zzq/options.rb', line 66

def initialize(
  linger: Float::INFINITY, send_hwm: DEFAULT_HWM, recv_hwm: DEFAULT_HWM,
  version: 5, client_id: nil, clean_start: true, keep_alive: 60,
  session_expiry_interval: 0, receive_maximum: 65_535,
  max_packet_size: nil, topic_alias_maximum: 0,
  username: nil, password: nil, will: nil,
  persistence: nil
)
  @linger                  = linger
  @read_timeout            = nil
  @write_timeout           = nil
  @reconnect_interval      = 0.1
  @send_hwm                = send_hwm
  @recv_hwm                = recv_hwm
  @version                 = version
  @client_id               = client_id
  @clean_start             = clean_start
  @keep_alive              = keep_alive
  @session_expiry_interval = session_expiry_interval
  @receive_maximum         = receive_maximum
  @max_packet_size         = max_packet_size
  @topic_alias_maximum     = topic_alias_maximum
  @username                = username
  @password                = password
  @will                    = will
  @persistence             = persistence
end

Instance Attribute Details

#clean_startObject

Clean Start (v5) / Clean Session (v3.1.1). When true, any prior session state for this client id is discarded on CONNECT.



32
33
34
# File 'lib/zzq/options.rb', line 32

def clean_start
  @clean_start
end

#client_idObject

Client identifier. Client-only; required unless empty-id + v5 is used (server assigns it).



28
29
30
# File 'lib/zzq/options.rb', line 28

def client_id
  @client_id
end

#keep_aliveObject

Keep-alive interval in seconds. The broker will close the connection after 1.5× this period with no traffic. 0 disables.



36
37
38
# File 'lib/zzq/options.rb', line 36

def keep_alive
  @keep_alive
end

#lingerObject

— infrastructure ————————————————-



15
16
17
# File 'lib/zzq/options.rb', line 15

def linger
  @linger
end

#max_packet_sizeObject

Maximum packet size this peer is willing to accept (v5). nil = unlimited.



47
48
49
# File 'lib/zzq/options.rb', line 47

def max_packet_size
  @max_packet_size
end

#passwordObject

Returns the value of attribute password.



54
55
56
# File 'lib/zzq/options.rb', line 54

def password
  @password
end

#persistenceObject

Broker-side persistence backend. Nil = ephemeral (no durability). Pass an instance of a Persistence::Interface subclass (e.g. Persistence::PStore) to survive process restarts.



63
64
65
# File 'lib/zzq/options.rb', line 63

def persistence
  @persistence
end

#read_timeoutObject

Returns the value of attribute read_timeout.



16
17
18
# File 'lib/zzq/options.rb', line 16

def read_timeout
  @read_timeout
end

#receive_maximumObject

Maximum outstanding unacknowledged QoS 1/2 messages (v5).



43
44
45
# File 'lib/zzq/options.rb', line 43

def receive_maximum
  @receive_maximum
end

#reconnect_intervalObject

Returns the value of attribute reconnect_interval.



18
19
20
# File 'lib/zzq/options.rb', line 18

def reconnect_interval
  @reconnect_interval
end

#recv_hwmObject

Returns the value of attribute recv_hwm.



20
21
22
# File 'lib/zzq/options.rb', line 20

def recv_hwm
  @recv_hwm
end

#send_hwmObject

Returns the value of attribute send_hwm.



19
20
21
# File 'lib/zzq/options.rb', line 19

def send_hwm
  @send_hwm
end

#session_expiry_intervalObject

Session expiry interval (v5 only), in seconds. Only meaningful when clean_start is false.



40
41
42
# File 'lib/zzq/options.rb', line 40

def session_expiry_interval
  @session_expiry_interval
end

#topic_alias_maximumObject

Topic Alias Maximum we advertise (v5).



50
51
52
# File 'lib/zzq/options.rb', line 50

def topic_alias_maximum
  @topic_alias_maximum
end

#usernameObject

MQTT username / password (both optional).



53
54
55
# File 'lib/zzq/options.rb', line 53

def username
  @username
end

#versionObject

— MQTT wire —————————————————— 3 = MQTT v3.1.1, 5 = MQTT v5.0



24
25
26
# File 'lib/zzq/options.rb', line 24

def version
  @version
end

#willObject

Last Will and Testament, client-side. Nil or a Hash of { topic:, payload:, qos:, retain:, properties: }.



58
59
60
# File 'lib/zzq/options.rb', line 58

def will
  @will
end

#write_timeoutObject

Returns the value of attribute write_timeout.



17
18
19
# File 'lib/zzq/options.rb', line 17

def write_timeout
  @write_timeout
end