Class: Hutils::Ltap::LvatDrainer
- Inherits:
-
Object
- Object
- Hutils::Ltap::LvatDrainer
- Defined in:
- lib/hutils/ltap/lvat_drainer.rb
Instance Method Summary collapse
-
#initialize(earliest:, key:, timeout:, query:, timestamps:, url:, verbose:) ⇒ LvatDrainer
constructor
A new instance of LvatDrainer.
- #run ⇒ Object
Constructor Details
#initialize(earliest:, key:, timeout:, query:, timestamps:, url:, verbose:) ⇒ LvatDrainer
Returns a new instance of LvatDrainer.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hutils/ltap/lvat_drainer.rb', line 6 def initialize(earliest:, key:, timeout:, query:, timestamps:, url:, verbose:) @query = query if raise ArgumentError, "lvat does not supported `timestamps` option" end @api = Excon.new(url, headers: { "Accept-Encoding" => "gzip" }, read_timeout: timeout ) end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hutils/ltap/lvat_drainer.rb', line 21 def run resp = @api.get( path: "/messages", expects: [200, 404], query: { query: @query }) return [] if resp.status == 404 encoding = resp.headers["Content-Encoding"] str = if encoding && encoding.include?("gzip") reader = Zlib::GzipReader.new(StringIO.new(resp.body)) reader.read else resp.body end str.split("\n") end |