Class: JetstreamBridge::TestHelpers::MockNats::MockConsumer

Inherits:
Object
  • Object
show all
Defined in:
lib/jetstream_bridge/test_helpers/mock_nats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, stream:, config:) ⇒ MockConsumer



475
476
477
478
479
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 475

def initialize(name:, stream:, config:)
  @name = name
  @stream = stream
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



473
474
475
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 473

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



473
474
475
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 473

def name
  @name
end

#streamObject (readonly)

Returns the value of attribute stream.



473
474
475
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 473

def stream
  @stream
end

Instance Method Details

#infoObject



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 481

def info
  OpenStruct.new(
    name: @name,
    stream_name: @stream,
    config: OpenStruct.new(
      durable_name: @name,
      ack_policy: @config[:ack_policy] || 'explicit',
      max_deliver: @config[:max_deliver] || 5,
      ack_wait: @config[:ack_wait] || 30_000_000_000,
      filter_subject: @config[:filter_subject] || '',
      replay_policy: @config[:replay_policy] || 'instant'
    ),
    num_pending: 0,
    num_delivered: 0
  )
end