Class: Druid::Writer
- Inherits:
-
Object
- Object
- Druid::Writer
- Defined in:
- lib/druid/writer.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#producer ⇒ Object
readonly
Returns the value of attribute producer.
-
#zk ⇒ Object
readonly
Returns the value of attribute zk.
Instance Method Summary collapse
-
#initialize(config, zk) ⇒ Writer
constructor
A new instance of Writer.
- #write_point(datasource, datapoint) ⇒ Object
Constructor Details
#initialize(config, zk) ⇒ Writer
Returns a new instance of Writer.
5 6 7 8 9 10 |
# File 'lib/druid/writer.rb', line 5 def initialize(config, zk) @config = config @zk = zk init_producer zk.register_listener(self, :handle_kafka_state_change) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/druid/writer.rb', line 4 def config @config end |
#producer ⇒ Object (readonly)
Returns the value of attribute producer.
4 5 6 |
# File 'lib/druid/writer.rb', line 4 def producer @producer end |
#zk ⇒ Object (readonly)
Returns the value of attribute zk.
4 5 6 |
# File 'lib/druid/writer.rb', line 4 def zk @zk end |
Instance Method Details
#write_point(datasource, datapoint) ⇒ Object
12 13 14 15 |
# File 'lib/druid/writer.rb', line 12 def write_point(datasource, datapoint) raise Druid::ConnectionError, 'no kafka brokers available' if producer.nil? producer.produce(datapoint, topic: datasource) end |