Class: DruidDB::Writer
- Inherits:
-
Object
- Object
- DruidDB::Writer
- Defined in:
- lib/druiddb/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.
4 5 6 7 8 9 |
# File 'lib/druiddb/writer.rb', line 4 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.
3 4 5 |
# File 'lib/druiddb/writer.rb', line 3 def config @config end |
#producer ⇒ Object (readonly)
Returns the value of attribute producer.
3 4 5 |
# File 'lib/druiddb/writer.rb', line 3 def producer @producer end |
#zk ⇒ Object (readonly)
Returns the value of attribute zk.
3 4 5 |
# File 'lib/druiddb/writer.rb', line 3 def zk @zk end |
Instance Method Details
#write_point(datasource, datapoint) ⇒ Object
11 12 13 14 |
# File 'lib/druiddb/writer.rb', line 11 def write_point(datasource, datapoint) raise DruidDB::ConnectionError, 'no kafka brokers available' if producer.nil? producer.produce(datapoint.to_json, topic: datasource) end |