Class: JetstreamBridge::TestHelpers::MockNats::MockStream

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, config) ⇒ MockStream



440
441
442
443
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 440

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



438
439
440
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 438

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



438
439
440
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 438

def name
  @name
end

Instance Method Details

#infoObject



445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 445

def info
  OpenStruct.new(
    config: OpenStruct.new(
      name: @name,
      subjects: @config[:subjects] || [@name],
      retention: @config[:retention] || 'limits',
      max_consumers: @config[:max_consumers] || -1,
      max_msgs: @config[:max_msgs] || -1,
      max_bytes: @config[:max_bytes] || -1,
      discard: @config[:discard] || 'old',
      max_age: @config[:max_age] || 0,
      max_msgs_per_subject: @config[:max_msgs_per_subject] || -1,
      max_msg_size: @config[:max_msg_size] || -1,
      storage: @config[:storage] || 'file',
      num_replicas: @config[:num_replicas] || 1
    ),
    state: OpenStruct.new(
      messages: 0,
      bytes: 0,
      first_seq: 1,
      last_seq: 0,
      consumer_count: 0
    )
  )
end