-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CCOL-2441: Allow custom publishing batch size per producer #216
Changes from all commits
ac779b1
dd2b1fa
3bc9228
c6dc831
d0cb06f
79baa2b
50e67b0
3d495d3
115cbbb
e698220
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,16 +59,14 @@ def producers_disabled?(producer_class=nil) | |
class Producer | ||
include SharedConfig | ||
|
||
# @return [Integer] | ||
MAX_BATCH_SIZE = 500 | ||
|
||
class << self | ||
|
||
# @return [Hash] | ||
def config | ||
@config ||= { | ||
encode_key: true, | ||
namespace: Deimos.config.producers.schema_namespace | ||
namespace: Deimos.config.producers.schema_namespace, | ||
max_batch_size: Deimos.config.producers.max_batch_size | ||
} | ||
end | ||
|
||
|
@@ -92,6 +90,12 @@ def partition_key(_payload) | |
nil | ||
end | ||
|
||
# @param size [Integer] Override the default batch size for publishing. | ||
# @return [void] | ||
def max_batch_size(size) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably don't need an actual method here, we can just assign it directly to the config inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100% sure what's going on but it seems like producer specs are not working as intended in general. As you suggested I added a line in if kafka_config.respond_to?(:bulk_import_id_column) # consumer
...
else # new code here for producer
klass.config[:max_batch_size] = kafka_config.max_batch_size || Deimos.config.producers.max_batch_size
end I tried setting Also, now that I removed
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you push your branch? I can take a look. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pushed! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah... we're going to change this entirely in V2 🙃 I forgot that the stubbed producers don't go through the normal process. OK - you can put it back the way it was! |
||
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 | ||
|
@@ -126,7 +130,7 @@ def publish_list(payloads, sync: nil, force_send: false, topic: self.topic, head | |
) do | ||
messages = Array(payloads).map { |p| Deimos::Message.new(p.to_h, self, headers: headers) } | ||
messages.each { |m| _process_message(m, topic) } | ||
messages.in_groups_of(MAX_BATCH_SIZE, false) do |batch| | ||
messages.in_groups_of(self.config[:max_batch_size], false) do |batch| | ||
self.produce_batch(backend_class, batch) | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing the doc for the new per-producer setting?