lib/prometheus/client/helper/mmaped_file.rb in prometheus-client-mmap-0.7.0.beta41 vs lib/prometheus/client/helper/mmaped_file.rb in prometheus-client-mmap-0.7.0.beta42

- old
+ new

@@ -1,28 +1,26 @@ require 'prometheus/client/helper/entry_parser' require 'prometheus/client/helper/file_locker' require 'fast_mmaped_file' -require 'mmap' module Prometheus module Client module Helper - class MmapedFile < Mmap + class MmapedFile < FastMmapedFile include EntryParser - include FastMmapedFile attr_reader :filepath, :size - def initialize(filepath, mode = 'r', protection = Mmap::MAP_SHARED, options = {}) + def initialize(filepath) @filepath = filepath File.open(filepath, 'a+b') do |file| file.truncate(initial_mmap_file_size) if file.size < MINIMUM_SIZE @size = file.size end - super(filepath, mode, protection, options) + super(filepath) end def close munmap end @@ -35,10 +33,10 @@ public class << self def open(filepath) - MmapedFile.new(filepath, 'rw', Mmap::MAP_SHARED) + MmapedFile.new(filepath) end def ensure_exclusive_file(file_prefix = 'mmaped_file') (0..Float::INFINITY).lazy .map { |f_num| "#{file_prefix}_#{Prometheus::Client.pid}-#{f_num}.db" }