example/basic_extensions.rb in rflow-1.0.0a2 vs example/basic_extensions.rb in rflow-1.0.0a3
- old
+ new
@@ -12,24 +12,23 @@
def my_method; end
end
RFlow::Configuration.add_available_data_extension('RFlow::Message::Data::Integer', SimpleDataExtension)
class RFlow::Components::FileOutput < RFlow::Component
- attr_accessor :output_file_path, :output_file
+ attr_accessor :output_file_path
input_port :in
def configure!(config)
self.output_file_path = config['output_file_path']
- self.output_file = File.new output_file_path, 'w+'
end
def process_message(input_port, input_port_key, connection, message)
- output_file.puts message.data.data_object.inspect
- output_file.flush
- end
-
- def cleanup
- output_file.close
+ File.open(output_file_path, 'a') do |f|
+ f.flock(File::LOCK_EX)
+ f.puts message.data.data_object.inspect
+ f.flush
+ f.flock(File::LOCK_UN)
+ end
end
end
class SimpleComponent < RFlow::Component
input_port :in