Sha256: e77f67f89eb6557a077cad78c03d59c3aed61d172154597011550fb9ba8b2a67

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

module Prometheus
  module Client
    module Helper
      module EntryParser
        def used
          slice(4..7).unpack('l')[0]
        end

        def entries
          return Enumerator.new {} if used.zero?

          Enumerator.new do |yielder|
            used_ = used # cache used to avoid unnecessary unpack operations

            pos = 12 # pid + used + padding offset
            while pos < used_
              data = slice(pos..-1)
              encoded_len, = data.unpack('l')
              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

1 entries across 1 versions & 1 rubygems

Version Path
prometheus-client-mmap-0.7.0.beta19 lib/prometheus/client/helper/entry_parser.rb