diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index ec3d997..5235dd3 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -46,6 +46,7 @@ schema|nil|Name of the schema to use to encode data before producing. namespace|nil|Namespace of the schema to use when finding it locally. key_config|nil|Configuration hash for message keys. See [Kafka Message Keys](../README.md#installation) use_schema_classes|nil|Set to true or false to enable or disable using the producers schema classes. See [Generated Schema Classes](../README.md#generated-schema-classes) +max_batch_size|500|Maximum publishing batch size. Defaults to top-level configuration of 500. ## Defining Consumers diff --git a/lib/deimos/config/configuration.rb b/lib/deimos/config/configuration.rb index f95b857..919747f 100644 --- a/lib/deimos/config/configuration.rb +++ b/lib/deimos/config/configuration.rb @@ -99,6 +99,8 @@ def self.configure_producer_or_consumer(kafka_config) bulk_import_id_generator: kafka_config.bulk_import_id_generator || Deimos.config.consumers.bulk_import_id_generator ) + else # producer + klass.config[:max_batch_size] = kafka_config.max_batch_size || Deimos.config.producers.max_batch_size end end end diff --git a/lib/deimos/producer.rb b/lib/deimos/producer.rb index 646fb33..ebdca27 100644 --- a/lib/deimos/producer.rb +++ b/lib/deimos/producer.rb @@ -65,8 +65,7 @@ class << self def config @config ||= { encode_key: true, - namespace: Deimos.config.producers.schema_namespace, - max_batch_size: Deimos.config.producers.max_batch_size + namespace: Deimos.config.producers.schema_namespace } end @@ -90,12 +89,6 @@ def partition_key(_payload) nil end - # @param size [Integer] Override the default batch size for publishing. - # @return [void] - def max_batch_size(size) - config[:max_batch_size] = size - end - # Publish the payload to the topic. # @param payload [Hash, SchemaClass::Record] with an optional payload_key hash key. # @param topic [String] if specifying the topic