Class: Fluent::RoundRobinOutput
- Inherits:
-
MultiOutput
- Object
- Output
- MultiOutput
- Fluent::RoundRobinOutput
- Defined in:
- lib/fluent/plugin/out_roundrobin.rb
Constant Summary
Constants included from Configurable
Configurable::CONFIG_TYPE_REGISTRY
Instance Attribute Summary collapse
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#rand_seed ⇒ Object
Returns the value of attribute rand_seed.
-
#weights ⇒ Object
readonly
Returns the value of attribute weights.
Attributes inherited from Output
Attributes included from PluginLoggerMixin
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ RoundRobinOutput
constructor
A new instance of RoundRobinOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
Methods inherited from Output
Methods included from PluginLoggerMixin
Methods included from PluginId
Methods included from Configurable
#config, included, lookup_type, register_type
Constructor Details
#initialize ⇒ RoundRobinOutput
Returns a new instance of RoundRobinOutput.
24 25 26 27 28 29 |
# File 'lib/fluent/plugin/out_roundrobin.rb', line 24 def initialize super @outputs = [] @weights = [] end |
Instance Attribute Details
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
31 32 33 |
# File 'lib/fluent/plugin/out_roundrobin.rb', line 31 def outputs @outputs end |
#rand_seed ⇒ Object
Returns the value of attribute rand_seed.
32 33 34 |
# File 'lib/fluent/plugin/out_roundrobin.rb', line 32 def rand_seed @rand_seed end |
#weights ⇒ Object (readonly)
Returns the value of attribute weights.
31 32 33 |
# File 'lib/fluent/plugin/out_roundrobin.rb', line 31 def weights @weights end |
Instance Method Details
#configure(conf) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fluent/plugin/out_roundrobin.rb', line 34 def configure(conf) super conf.elements.select {|e| e.name == 'store' }.each {|e| type = e['@type'] || e['type'] unless type raise ConfigError, "Missing 'type' parameter on <store> directive" end weight = e['weight'] weight = weight ? weight.to_i : 1 log.debug "adding store type=#{type.dump}, weight=#{weight}" output = Plugin.new_output(type) output.router = router output.configure(e) @outputs << output @weights << weight } @rr = -1 # starts from @output[0] @rand_seed = Random.new.seed end |
#emit(tag, es, chain) ⇒ Object
73 74 75 |
# File 'lib/fluent/plugin/out_roundrobin.rb', line 73 def emit(tag, es, chain) next_output.emit(tag, es, chain) end |
#shutdown ⇒ Object
67 68 69 70 71 |
# File 'lib/fluent/plugin/out_roundrobin.rb', line 67 def shutdown @outputs.each {|o| o.shutdown } end |
#start ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/fluent/plugin/out_roundrobin.rb', line 59 def start rebuild_weight_array @outputs.each {|o| o.start } end |