Class: Prometheus::Client::Helper::PlainFile

Inherits:
Object
  • Object
show all
Includes:
EntryParser
Defined in:
lib/prometheus/client/helper/plain_file.rb

Overview

Parses DB files without using mmap

Constant Summary

Constants included from EntryParser

EntryParser::ENCODED_LENGTH_BYTES, EntryParser::MINIMUM_SIZE, EntryParser::START_POSITION, EntryParser::VALUE_BYTES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EntryParser

#empty?, #entries, #multiprocess_mode, #parsed_entries, #parts, #pid, #to_metrics, #type, #used

Constructor Details

#initialize(filepath) ⇒ PlainFile

Returns a new instance of PlainFile.



15
16
17
# File 'lib/prometheus/client/helper/plain_file.rb', line 15

def initialize(filepath)
  @filepath = filepath
end

Instance Attribute Details

#filepathObject (readonly)

Returns the value of attribute filepath.



9
10
11
# File 'lib/prometheus/client/helper/plain_file.rb', line 9

def filepath
  @filepath
end

Instance Method Details

#sizeObject



23
24
25
# File 'lib/prometheus/client/helper/plain_file.rb', line 23

def size
  source.length
end

#slice(*args) ⇒ Object



19
20
21
# File 'lib/prometheus/client/helper/plain_file.rb', line 19

def slice(*args)
  source.slice(*args)
end

#sourceObject



11
12
13
# File 'lib/prometheus/client/helper/plain_file.rb', line 11

def source
  @data ||= File.read(filepath, mode: 'rb')
end