Class: NatsWork::JetStreamMessage
- Inherits:
-
Object
- Object
- NatsWork::JetStreamMessage
- Defined in:
- lib/natswork/jetstream_manager.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#reply ⇒ Object
readonly
Returns the value of attribute reply.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #ack ⇒ Object
- #acked? ⇒ Boolean
- #in_progress ⇒ Object
-
#initialize(nats_msg, js_context) ⇒ JetStreamMessage
constructor
A new instance of JetStreamMessage.
- #nak(delay: nil) ⇒ Object
- #term ⇒ Object
Constructor Details
#initialize(nats_msg, js_context) ⇒ JetStreamMessage
Returns a new instance of JetStreamMessage.
175 176 177 178 179 180 181 182 183 184 |
# File 'lib/natswork/jetstream_manager.rb', line 175 def initialize(nats_msg, js_context) @nats_msg = nats_msg @js_context = js_context @data = parse_data(nats_msg.data) @subject = nats_msg.subject @reply = nats_msg.reply @headers = nats_msg.headers if nats_msg.respond_to?(:headers) @metadata = @acked = false end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
173 174 175 |
# File 'lib/natswork/jetstream_manager.rb', line 173 def data @data end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
173 174 175 |
# File 'lib/natswork/jetstream_manager.rb', line 173 def headers @headers end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
173 174 175 |
# File 'lib/natswork/jetstream_manager.rb', line 173 def @metadata end |
#reply ⇒ Object (readonly)
Returns the value of attribute reply.
173 174 175 |
# File 'lib/natswork/jetstream_manager.rb', line 173 def reply @reply end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
173 174 175 |
# File 'lib/natswork/jetstream_manager.rb', line 173 def subject @subject end |
Instance Method Details
#ack ⇒ Object
186 187 188 189 190 191 |
# File 'lib/natswork/jetstream_manager.rb', line 186 def ack return if @acked @nats_msg.ack @acked = true end |
#acked? ⇒ Boolean
215 216 217 |
# File 'lib/natswork/jetstream_manager.rb', line 215 def acked? @acked end |
#in_progress ⇒ Object
204 205 206 |
# File 'lib/natswork/jetstream_manager.rb', line 204 def in_progress @nats_msg.in_progress end |
#nak(delay: nil) ⇒ Object
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/natswork/jetstream_manager.rb', line 193 def nak(delay: nil) return if @acked if delay @nats_msg.nak(delay: delay) else @nats_msg.nak end @acked = true end |
#term ⇒ Object
208 209 210 211 212 213 |
# File 'lib/natswork/jetstream_manager.rb', line 208 def term return if @acked @nats_msg.term @acked = true end |