Sha256: b51c945ef9bfad3b1f7bc1fc1b61169781aea4e127862ec6bc609288b0dc7d3c
Contents?: true
Size: 621 Bytes
Versions: 4
Compression:
Stored size: 621 Bytes
Contents
require_relative './event' require_relative './page' module EsHttpClient class CaughtUpStream def initialize(ref, connection) @ref = ref @connection = connection end def subscribe(&block) loop do sleep 1 @ref = fetch(@ref, &block) end end def fetch(ref, &block) response = @connection.get(ref.uri, ref.etag) page = Page.new(response.body) next_uri = ref.uri if page.has_entries? page.each_event(&block) next_uri = page.previous end return Ref.new(next_uri, response.headers['etag']) end end end
Version data entries
4 entries across 4 versions & 1 rubygems