Class: JetstreamBridge::TestHelpers::MockNats::MockMessage

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(subject:, data:, header:, sequence:, stream:, consumer:, num_delivered:, storage:, message_ref:) ⇒ MockMessage

Returns a new instance of MockMessage.



375
376
377
378
379
380
381
382
383
384
385
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 375

def initialize(subject:, data:, header:, sequence:, stream:, consumer:, num_delivered:, storage:, message_ref:)
  @subject = subject
  @data = data
  @header = header
  @sequence = sequence
  @stream = stream
  @consumer = consumer
  @num_delivered = num_delivered
  @storage = storage
  @message_ref = message_ref
end

Instance Attribute Details

#consumerObject (readonly)

Returns the value of attribute consumer.



373
374
375
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 373

def consumer
  @consumer
end

#dataObject (readonly)

Returns the value of attribute data.



373
374
375
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 373

def data
  @data
end

#headerObject (readonly)

Returns the value of attribute header.



373
374
375
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 373

def header
  @header
end

#num_deliveredObject (readonly)

Returns the value of attribute num_delivered.



373
374
375
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 373

def num_delivered
  @num_delivered
end

#sequenceObject (readonly)

Returns the value of attribute sequence.



373
374
375
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 373

def sequence
  @sequence
end

#streamObject (readonly)

Returns the value of attribute stream.



373
374
375
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 373

def stream
  @stream
end

#subjectObject (readonly)

Returns the value of attribute subject.



373
374
375
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 373

def subject
  @subject
end

Instance Method Details

#ackObject



397
398
399
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 397

def ack
  @storage.ack_message(@message_ref)
end

#metadataObject



387
388
389
390
391
392
393
394
395
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 387

def 
  OpenStruct.new(
    sequence: OpenStruct.new(stream: @sequence, consumer: @sequence),
    num_delivered: @num_delivered,
    stream: @stream,
    consumer: @consumer,
    timestamp: Time.now
  )
end

#nak(in_progress_duration: nil) ⇒ Object



401
402
403
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 401

def nak(in_progress_duration: nil)
  @storage.nak_message(@message_ref, delay: in_progress_duration)
end

#termObject



405
406
407
# File 'lib/jetstream_bridge/test_helpers/mock_nats.rb', line 405

def term
  @storage.term_message(@message_ref)
end