Class: JetstreamBridge::TestHelpers::MockNats::MockSubscription
- Inherits:
-
Object
- Object
- JetstreamBridge::TestHelpers::MockNats::MockSubscription
- Defined in:
- lib/jetstream_bridge/test_helpers/mock_nats.rb
Instance Attribute Summary collapse
-
#durable_name ⇒ Object
readonly
Returns the value of attribute durable_name.
-
#stream_name ⇒ Object
readonly
Returns the value of attribute stream_name.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #fetch(batch_size, timeout: 5) ⇒ Object
-
#initialize(subject:, durable_name:, storage:, stream_name:, options:) ⇒ MockSubscription
constructor
A new instance of MockSubscription.
- #unsubscribe ⇒ Object
Constructor Details
#initialize(subject:, durable_name:, storage:, stream_name:, options:) ⇒ MockSubscription
413 414 415 416 417 418 419 420 |
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 413 def initialize(subject:, durable_name:, storage:, stream_name:, options:) @subject = subject @durable_name = durable_name @storage = storage @stream_name = stream_name = @unsubscribed = false end |
Instance Attribute Details
#durable_name ⇒ Object (readonly)
Returns the value of attribute durable_name.
411 412 413 |
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 411 def durable_name @durable_name end |
#stream_name ⇒ Object (readonly)
Returns the value of attribute stream_name.
411 412 413 |
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 411 def stream_name @stream_name end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
411 412 413 |
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 411 def subject @subject end |
Instance Method Details
#fetch(batch_size, timeout: 5) ⇒ Object
422 423 424 425 426 427 428 429 430 |
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 422 def fetch(batch_size, timeout: 5) raise NATS::JetStream::Error, 'consumer not found' if @unsubscribed @storage.(@subject, @durable_name, batch_size, timeout) rescue StandardError => e raise NATS::IO::Timeout if timeout && e.is_a?(Timeout::Error) raise end |
#unsubscribe ⇒ Object
432 433 434 |
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 432 def unsubscribe @unsubscribed = true end |