Class: FFWD::Plugin::Kafka::AttributePartitioner
- Inherits:
-
Object
- Object
- FFWD::Plugin::Kafka::AttributePartitioner
- Defined in:
- lib/ffwd/plugin/kafka/partitioners.rb
Overview
Use a custom attribute for partitioning.
Constant Summary collapse
- DEFAULT_ATTRIBUTE =
:site
- OPTIONS =
[ FFWD::Plugin.option( :attribute, :default => DEFAULT_ATTRIBUTE, :help => [ "Attribute to use when the partitioner is set to :attribute." ] ), ]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config) ⇒ AttributePartitioner
constructor
A new instance of AttributePartitioner.
-
#partition(d) ⇒ Object
currently there is an issue where you can store both symbols and string as attribute keys, we need to take that into account.
Constructor Details
#initialize(config) ⇒ AttributePartitioner
Returns a new instance of AttributePartitioner.
49 50 51 52 |
# File 'lib/ffwd/plugin/kafka/partitioners.rb', line 49 def initialize config @attr = config[:attribute].to_sym @attr_s = config[:attribute].to_s end |
Class Method Details
.prepare(config) ⇒ Object
44 45 46 47 |
# File 'lib/ffwd/plugin/kafka/partitioners.rb', line 44 def self.prepare config config[:attribute] ||= DEFAULT_ATTRIBUTE config end |
Instance Method Details
#partition(d) ⇒ Object
currently there is an issue where you can store both symbols and string as attribute keys, we need to take that into account.
56 57 58 59 60 61 62 |
# File 'lib/ffwd/plugin/kafka/partitioners.rb', line 56 def partition d if v = d.attributes[@attr] return v end d.attributes[@attr_s] end |