class Chef::Deployment::Monitor::HistoryFileSink
Attributes
file[R]
Public Class Methods
new(outfile)
click to toggle source
# File lib/chef_deployment_monitor/sinks.rb, line 32 def initialize(outfile) @file = outfile @history = if File.exist?(file) JSON.parse(File.read(file)) rescue [] # rubocop:disable Lint/RescueWithoutErrorClass else [] end end
Public Instance Methods
receive(data)
click to toggle source
will append data to the history file within 5 seconds of last deployment the array is a FIFO
# File lib/chef_deployment_monitor/sinks.rb, line 44 def receive(data) @history = [data] + @history.take(Monitor::Config[:history_file_size] - 1) File.write(file, @history.to_json) end