Class: LogStashLogger::Device::Balancer
- Defined in:
- lib/logstash-logger/device/balancer.rb
Instance Attribute Summary collapse
-
#devices ⇒ Object
readonly
Returns the value of attribute devices.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Balancer
constructor
A new instance of Balancer.
Methods inherited from Base
#close, #close!, #flush, #reset, #to_io, #unrecoverable_error?, #write, #write_batch, #write_one
Constructor Details
#initialize(opts) ⇒ Balancer
Returns a new instance of Balancer.
6 7 8 9 10 11 |
# File 'lib/logstash-logger/device/balancer.rb', line 6 def initialize(opts) @io = self @devices = create_devices(opts[:outputs]) self.class.delegate_to_all(:close, :close!, :flush) self.class.delegate_to_one(:write) end |
Instance Attribute Details
#devices ⇒ Object (readonly)
Returns the value of attribute devices.
4 5 6 |
# File 'lib/logstash-logger/device/balancer.rb', line 4 def devices @devices end |
Class Method Details
.delegate_to_all(*methods) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/logstash-logger/device/balancer.rb', line 19 def self.delegate_to_all(*methods) methods.each do |m| define_method(m) do |*args| devices.each { |device| device.send(m, *args) } end end end |
.delegate_to_one(*methods) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/logstash-logger/device/balancer.rb', line 27 def self.delegate_to_one(*methods) methods.each do |m| define_method(m) do |*args| select_device.send(m, *args) end end end |