Sha256: 2f73d0e0157366bc94ab15d1a69a9c8e34ca99b6fd6ba38345285a26a39a642d
Contents?: true
Size: 1015 Bytes
Versions: 22
Compression:
Stored size: 1015 Bytes
Contents
module SplitIoClient module LocalhostUtils # # method to set localhost mode features by reading the given .splits # # @param splits_file [File] the .split file that contains the splits # @param reload_rate [Integer] the number of seconds to reload splits_file # @return nil def load_localhost_mode_features(splits_file, reload_rate = nil) return @localhost_mode_features unless File.exists?(splits_file) store_features(splits_file) return unless reload_rate Thread.new do loop do @localhost_mode_features = [] store_features(splits_file) sleep(::Utilities.randomize_interval(reload_rate)) end end end def store_features(splits_file) File.open(splits_file).each do |line| feature, treatment = line.strip.split(' ') next if line.start_with?('#') || line.strip.empty? @localhost_mode_features << { feature: feature, treatment: treatment } end end end end
Version data entries
22 entries across 22 versions & 1 rubygems