Class: ROM::Kafka::Dataset Private
- Inherits:
-
Object
- Object
- ROM::Kafka::Dataset
- Extended by:
- AttributesDSL
- Includes:
- Enumerable
- Defined in:
- lib/rom/kafka/dataset.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The dataset describes Kafka topic
Instance Attribute Summary collapse
-
#consumer ⇒ ROM::Kafka::Connection::Consumer
readonly
private
The consumer connection to Kafka brokers, used to fetch messages via [#each] method call.
-
#gateway ⇒ ROM::Kafka::Gateway
readonly
private
The back reference to the gateway, that provided the dataset.
-
#producer ⇒ ROM::Kafka::Connection::Producer
readonly
private
The producer connection to Kafka brokers, defined by a gateway.
-
#topic ⇒ String
readonly
private
The name of the topic, described by the dataset.
Instance Method Summary collapse
-
#each(&block) {|tuple| ... } ⇒ Enumerator<Hash{Symbol => String, Integer}>
private
Returns the enumerator to iterate via tuples, fetched from a [#consumer].
-
#initialize(gateway, topic, options = {}) ⇒ Dataset
constructor
private
Initializes the dataset with a gateway and topic name.
-
#using(options) ⇒ ROM::Kafka::Dataset
private
Returns a new dataset with updated consumer attributes.
Constructor Details
#initialize(gateway, topic, options = {}) ⇒ Dataset
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the dataset with a gateway and topic name
Attributes are set by default from a gateway. Later you can create new dataset for the same gateway and topic, but with attributes, updated via [#using] method.
70 71 72 73 74 75 76 |
# File 'lib/rom/kafka/dataset.rb', line 70 def initialize(gateway, topic, = {}) super gateway.attributes.merge() @topic = topic.to_s @gateway = gateway @producer = gateway.producer @consumer = prepare_consumer # @todo: refactor using a factory end |
Instance Attribute Details
#consumer ⇒ ROM::Kafka::Connection::Consumer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The consumer connection to Kafka brokers, used to fetch messages via [#each] method call.
46 47 48 |
# File 'lib/rom/kafka/dataset.rb', line 46 def consumer @consumer end |
#gateway ⇒ ROM::Kafka::Gateway (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The back reference to the gateway, that provided the dataset.
24 25 26 |
# File 'lib/rom/kafka/dataset.rb', line 24 def gateway @gateway end |
#producer ⇒ ROM::Kafka::Connection::Producer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The producer connection to Kafka brokers, defined by a gateway. It is stored for being used by a ‘Create` command.
38 39 40 |
# File 'lib/rom/kafka/dataset.rb', line 38 def producer @producer end |
#topic ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The name of the topic, described by the dataset.
30 31 32 |
# File 'lib/rom/kafka/dataset.rb', line 30 def topic @topic end |
Instance Method Details
#each(&block) {|tuple| ... } ⇒ Enumerator<Hash{Symbol => String, Integer}>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the enumerator to iterate via tuples, fetched from a [#consumer].
If a ‘limit` of messages is set, iterator stops after achieving it.
98 99 100 101 |
# File 'lib/rom/kafka/dataset.rb', line 98 def each(&block) return to_enum unless block_given? limit.equal?(0) ? unlimited_each(&block) : limited_each(&block) end |
#using(options) ⇒ ROM::Kafka::Dataset
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new dataset with updated consumer attributes
84 85 86 |
# File 'lib/rom/kafka/dataset.rb', line 84 def using() self.class.new(gateway, topic, attributes.merge()) end |