Class: MessageStore::EventStore::Get::Last

Inherits:
Object
  • Object
show all
Includes:
Get::Last
Defined in:
lib/message_store/event_store/get/last.rb

Constant Summary collapse

Assertions =
Get::Assertions

Instance Method Summary collapse

Instance Method Details

#call(stream_name) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/message_store/event_store/get/last.rb', line 22

def call(stream_name)
  begin
    message_data, * = read_stream.(
      stream_name,
      position: :head,
      direction: :backward,
      batch_size: 1
    )
  rescue ::EventStore::HTTP::ReadStream::StreamNotFoundError
  end

  message_data
end

#configure(session: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/message_store/event_store/get/last.rb', line 10

def configure(session: nil)
  session = Session.configure(self, session: session)

  read_stream = ::EventStore::HTTP::ReadStream.configure(
    self,
    session: session
  )

  read_stream.embed_body
  read_stream.output_schema = Result
end