Expose GetHashingFunction() method on producer#507
Conversation
|
In the pulsar-client-go/pulsar/producer.go Line 57 in f17deac Wouldn't this already solve the problem? |
IIUC, the TopicMetadata gives us the number of partitions at the time the MessageRouter is invoked. For our use case, we need to keep recording the number of partitions when a new partition key is defined. I probably shouldn't paste the link here but DSP-28866 is the jira ticket that this change is made for. |
d21a85b to
8cc3b92
Compare
|
I have updated the pull request to also expose the The idea about how we plan to make use of the changes can be found at https://cd.splunkdev.com/data-availability/s2s-svc/-/merge_requests/937/diffs |
| } | ||
|
|
||
| // GetHashingFunction return the corresponding hashing function for the hashing scheme | ||
| func GetHashingFunction(s HashingScheme) func(string) uint32 { |
There was a problem hiding this comment.
Why do we need to expose this publicly? An application is free to use a custom message router function, at that point it can use any hashing function.
There was a problem hiding this comment.
We would like to mimic what the default router does including the hash function. The only difference would be to use a snapshotted numPartitions instead of a latest one that is from TopicMetadata:
pulsar-client-go/pulsar/producer_impl.go
Line 103 in 6ab17dc
I'm not convinced exposing In any case, there's already a way to get the partitions for a topic, by using |
Signed-off-by: Chen Liu <cliu@splunk.com>
8cc3b92 to
769e561
Compare
ACK, I didn't realize there is a method already. That should work. I removed changes related to |
|
The point is wrong, can MessageRouter not meet our functions? e.g: |
wolfstudy
left a comment
There was a problem hiding this comment.
Thanks @hunter2046 work for this, just a little comment, please check.
Thanks for taking a look. MessageRouter is what we need. We'd like to set the MessageRouter to a function that works similar to the defaultRouter with a customized number of partitions, e.g. The problem is that |
Sorry for the late reply. @hunter2046 Regarding all the options in NewDefaultRouter, we expose them in the form of parameters. You can set these options in producerOptions, and NewDefaultRouter is also the specific value obtained from these options. |
Thanks. I understand that those options including MessageRouter are in producerOptions. My use case (as mentioned in #507 (comment)) is that I need to set the MessageRouter in a customized way that is close to what the internalRouter does except using a different number of partitions to avoid causing producers to send messages to a different paritition when the number of partitions is being increased. In order to do that, I need to initialize the internalRouter by my own by calling |
Motivation
Expose GetHashingFunction() so that the user could construct the hashFunc to call
NewDefaultRouter.Modifications
Expose
GetHashingFunction()and added unit tests.Verifying this change
(Please pick either of the following options)
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation