This repository was archived by the owner on Jun 10, 2022. It is now read-only.
Choose partition by key for several brokers#208
Closed
demyanovs wants to merge 11 commits intoweiboad:v0.3.0-devfrom
Closed
Choose partition by key for several brokers#208demyanovs wants to merge 11 commits intoweiboad:v0.3.0-devfrom
demyanovs wants to merge 11 commits intoweiboad:v0.3.0-devfrom
Conversation
lcobucci
suggested changes
May 10, 2018
src/Producer/SyncProcess.php
Outdated
| $partId = crc32($value['key']) % count($partNums); | ||
| } else { | ||
| $partId = $value['partId']; | ||
| shuffle($partNums); |
Contributor
There was a problem hiding this comment.
Isn't the shuffle needed only for when you're using $partsNum?
src/Producer/SyncProcess.php
Outdated
| $partId = 0; | ||
| if (! isset($value['partId']) || ! isset($topicMeta[$value['partId']])) { | ||
| $partId = $partNums[0]; | ||
| if (isset($value['key']) && trim($value['key'])) { |
Contributor
There was a problem hiding this comment.
Extracting this logic to a method and using early returns will make things way easier to understand, could you please do that?
added 8 commits
May 10, 2018 14:57
Author
|
I moved the logic of the choice of partitions to the broker method and add a test. |
Contributor
|
@demyanovs awesome, thanks! Can you please address the issues pointed out by phpstan? I'll take a look at your code when the build is green 👍 |
Contributor
|
Also, please use |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
I have three brokers and when I, for example, write 5 messages in a cycle, they come in random order.
Before choosing a broker we need to select partition by key, so that the messages were written consistently in correct order.