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, Defaults, 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
18
19
20
21
22
23
24
25
26
|
# File 'lib/event_source/event_store/http/get.rb', line 18
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
28
29
30
31
|
# File 'lib/event_source/event_store/http/get.rb', line 28
def self.call(stream_name, position: nil, **build_arguments)
instance = build **build_arguments
instance.(stream_name, position: position)
end
|
Instance Method Details
#batch_size ⇒ Object
11
12
13
|
# File 'lib/event_source/event_store/http/get.rb', line 11
def batch_size
@batch_size ||= Defaults.batch_size
end
|
#call(stream_name, position: nil) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/event_source/event_store/http/get.rb', line 42
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
|
33
34
35
36
37
38
39
40
|
# File 'lib/event_source/event_store/http/get.rb', line 33
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
|