Sha256: 1e1402d5b0c6d7bf64ad8048bcf822a2ffb12a2eceb0a0407774feaee6335d19
Contents?: true
Size: 758 Bytes
Versions: 162
Compression:
Stored size: 758 Bytes
Contents
# frozen_string_literal: true module Motor module Configs module WriteToFile THREAD_POOL = Concurrent::FixedThreadPool.new(1) module_function def call return if Rails.env.test? return if THREAD_POOL.queue_length.positive? THREAD_POOL.post do ActiveRecord::Base.logger.silence do write_with_lock end rescue StandardError => e Rails.logger.error(e) end end def write_with_lock File.open(Motor::Configs.file_path, 'w') do |file| file.flock(File::LOCK_EX) YAML.dump(Motor::Configs::BuildConfigsHash.call, file) file.flock(File::LOCK_UN) file end.close end end end end
Version data entries
162 entries across 162 versions & 7 rubygems