Sha256: 279ed3cd3ab4a057c5a5e5dc32540a0667c47cf568e9f3182f192f6ecd0da4f3
Contents?: true
Size: 1.08 KB
Versions: 8
Compression:
Stored size: 1.08 KB
Contents
module Prometheus module Client module Helper module EntryParser MINIMUM_SIZE = 8 START_POSITION = 8 def used slice(0..3).unpack('l')[0] end def empty? size < MINIMUM_SIZE || used.zero? end def entries return Enumerator.new {} if empty? Enumerator.new do |yielder| used_ = used # cache used to avoid unnecessary unpack operations pos = START_POSITION # used + padding offset while pos < used_ data = slice(pos..-1) encoded_len, first_encoded_bytes = data.unpack('ll') if encoded_len.zero? || first_encoded_bytes.zero? # do not parse empty data pos += 8 next end padding_len = 8 - (encoded_len + 4) % 8 value_offset = 4 + encoded_len + padding_len pos += value_offset yielder.yield data, encoded_len, value_offset, pos pos += 8 end end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems