Class: Prometheus::Client::Helper::PlainFile
- Inherits:
-
Object
- Object
- Prometheus::Client::Helper::PlainFile
- 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
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
Instance Method Summary collapse
-
#initialize(filepath) ⇒ PlainFile
constructor
A new instance of PlainFile.
- #size ⇒ Object
- #slice(*args) ⇒ Object
- #source ⇒ Object
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
#filepath ⇒ Object (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
#size ⇒ Object
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 |
#source ⇒ Object
11 12 13 |
# File 'lib/prometheus/client/helper/plain_file.rb', line 11 def source @data ||= File.read(filepath, mode: 'rb') end |