Class: EventSource::EventStore::HTTP::Get
- Inherits:
-
Object
- Object
- EventSource::EventStore::HTTP::Get
show all
- Includes:
- Log::Dependency
- Defined in:
- lib/event_source/event_store/http/get.rb,
lib/event_source/event_store/http/get/last.rb,
lib/event_source/event_store/http/get/result.rb,
lib/event_source/event_store/http/get/assertions.rb
Defined Under Namespace
Modules: Assertions, Result
Classes: Last
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.build(batch_size: nil, long_poll_duration: nil, session: nil) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/event_source/event_store/http/get.rb', line 14
def self.build(batch_size: nil, long_poll_duration: nil, session: nil)
instance = new batch_size, long_poll_duration
session = Session.configure instance, session: session
::EventStore::HTTP::ReadStream.configure instance, session: session
instance.configure
instance
end
|
.call(stream_name, position: nil, **build_arguments) ⇒ Object
24
25
26
27
|
# File 'lib/event_source/event_store/http/get.rb', line 24
def self.call(stream_name, position: nil, **build_arguments)
instance = build **build_arguments
instance.(stream_name, position: position)
end
|
Instance Method Details
#call(stream_name, position: nil) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/event_source/event_store/http/get.rb', line 38
def call(stream_name, position: nil)
logger.trace { "Reading stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, BatchSize: #{batch_size})" }
begin
events = read_stream.(
stream_name,
position: position,
batch_size: batch_size
)
rescue ::EventStore::HTTP::ReadStream::StreamNotFoundError
events = []
end
logger.debug { "Done reading stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, BatchSize: #{batch_size}, Events: #{events.count})" }
events
end
|
29
30
31
32
33
34
35
36
|
# File 'lib/event_source/event_store/http/get.rb', line 29
def configure
read_stream.embed_body
read_stream.output_schema = Result
unless long_poll_duration.nil?
read_stream.enable_long_poll long_poll_duration
end
end
|