Skip to content

Commit

Permalink
style: apply formatter
Browse files Browse the repository at this point in the history
Signed-off-by: Florentin Dubois <florentin.dubois@clever-cloud.com>
  • Loading branch information
FlorentinDUBOIS committed Dec 19, 2024
1 parent ef7c063 commit 1bc4ec3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
16 changes: 10 additions & 6 deletions src/consumer/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,17 @@ impl<Exe: Executor> ConsumerEngine<Exe> {
})?;
}

// In the casual workflow, we use the `batch_size` as a maximum number that we could send using a send
// flow command message to ask the broker to send us messages, which is why we have a subtraction below (`batch_size` - `remaining_messages`).
// In the casual workflow, we use the `batch_size` as a maximum number that we could
// send using a send flow command message to ask the broker to send us
// messages, which is why we have a subtraction below (`batch_size` -
// `remaining_messages`).
//
// In the special case of batch messages (which is defined by clients), the number of messages could be
// greater than the given batch size and the remaining messages goes negative, which is why we use an
// `i64` as we want to keep track of the number of negative messages as the next send flow will be
// the batch_size - minus remaining messages which allow us to retrieve the casual workflow of flow command messages.
// In the special case of batch messages (which is defined by clients), the number of
// messages could be greater than the given batch size and the remaining
// messages goes negative, which is why we use an `i64` as we want to keep
// track of the number of negative messages as the next send flow will be
// the batch_size - minus remaining messages which allow us to retrieve the casual
// workflow of flow command messages.
//
// Here is the example of it works for a batch_size at 1000 and the error case:
//
Expand Down
17 changes: 9 additions & 8 deletions src/service_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,15 @@ impl<Exe: Executor> ServiceDiscovery<Exe> {
) -> Result<u32, ServiceDiscoveryError> {
let topic = topic.into();

// This is a fast path to reduce the number of lookup requests for topic partition metadata and as a side effect
// reduce amplification on zookeeper.
// For example, for a topic with 12 partitions, before this patch we did 13 lookup requests and now, we only did
// once.
// There are some cases where we ask if a partition of a topic is partitioned which could not be the case.
// We are able to detect those requests as the topic name is ending with '...-partition-<number>'.
// So, to be effective and avoid a regex here, we use the `contains` method to detect the pattern '-partition-'.
// if it matches the pattern as there is no partition in a partitioned topic, we could safely return that the
// This is a fast path to reduce the number of lookup requests for topic partition metadata
// and as a side effect reduce amplification on zookeeper.
// For example, for a topic with 12 partitions, before this patch we did 13 lookup requests
// and now, we only did once.
// There are some cases where we ask if a partition of a topic is partitioned which could
// not be the case. We are able to detect those requests as the topic name is ending
// with '...-partition-<number>'. So, to be effective and avoid a regex here, we use
// the `contains` method to detect the pattern '-partition-'. if it matches the
// pattern as there is no partition in a partitioned topic, we could safely return that the
// partition number is 0, that implicitly say that there is only 1 topic and the index is 0.
if topic.contains("-partition-") {
return Ok(0);
Expand Down

0 comments on commit 1bc4ec3

Please sign in to comment.