class EventStore::HTTP::ReadStream::Substitute::ReadStream
Attributes
body_embed_enabled[RW]
body_embed_enabled?[RW]
long_poll_duration[RW]
rich_embed_enabled[RW]
rich_embed_enabled?[RW]
Public Class Methods
build()
click to toggle source
# File lib/event_store/http/read_stream/substitute.rb, line 18 def self.build telemetry_sink = Telemetry::Sink.new instance = new telemetry_sink telemetry = ::Telemetry.configure instance telemetry.register telemetry_sink instance end
Public Instance Methods
call(stream, position: nil, direction: nil, batch_size: nil)
click to toggle source
# File lib/event_store/http/read_stream/substitute.rb, line 29 def call(stream, position: nil, direction: nil, batch_size: nil) unless direction.nil? unless EventStore::HTTP::ReadStream.directions.include? direction raise ArgumentError end end page = streams.fetch stream do raise EventStore::HTTP::ReadStream::StreamNotFoundError end telemetry.record :read, Telemetry::Read.new(stream, position, direction, batch_size) page end
embed_body()
click to toggle source
# File lib/event_store/http/read_stream/substitute.rb, line 70 def embed_body self.body_embed_enabled = true end
embed_rich()
click to toggle source
# File lib/event_store/http/read_stream/substitute.rb, line 66 def embed_rich self.rich_embed_enabled = true end
enable_long_poll(duration=nil)
click to toggle source
# File lib/event_store/http/read_stream/substitute.rb, line 53 def enable_long_poll(duration=nil) duration ||= HTTP::ReadStream::Defaults.long_poll_duration self.long_poll_duration = duration end
long_poll_enabled?(duration=nil)
click to toggle source
# File lib/event_store/http/read_stream/substitute.rb, line 59 def long_poll_enabled?(duration=nil) return false if long_poll_duration.nil? return true if duration.nil? long_poll_duration == duration end
read?(&block)
click to toggle source
# File lib/event_store/http/read_stream/substitute.rb, line 45 def read?(&block) block ||= proc { true } telemetry_sink.recorded? do |record| block.(*record.data.to_a) end end
set_response(stream, page, position: nil)
click to toggle source
# File lib/event_store/http/read_stream/substitute.rb, line 74 def set_response(stream, page, position: nil) streams[stream] = page end
streams()
click to toggle source
# File lib/event_store/http/read_stream/substitute.rb, line 78 def streams @streams ||= {} end