shibd commented on code in PR #958:
URL: https://github.com/apache/pulsar-client-go/pull/958#discussion_r1111378142
##########
pulsar/internal/rpc_client.go:
##########
@@ -129,14 +129,24 @@ func (c *rpcClient) Request(logicalAddr *url.URL,
physicalAddr *url.URL, request
Cnx: cnx,
Response: response,
}, err}
- close(ch)
})
- select {
- case res := <-ch:
- return res.RPCResult, res.error
- case <-time.After(c.requestTimeout):
- return nil, ErrRequestTimeOut
+ timeoutCh := time.After(c.requestTimeout)
+ for {
+ select {
+ case res := <-ch:
+ // Ignoring producer not ready response.
+ // Continue to wait for the producer to create
successfully
+ if res.error == nil && *res.RPCResult.Response.Type ==
pb.BaseCommand_PRODUCER_SUCCESS {
+ if
!*res.RPCResult.Response.ProducerSuccess.ProducerReady {
+ timeoutCh = nil
Review Comment:
No, when receiving a broker response after, the client needs to wait away
permanently.
##########
pulsar/producer_test.go:
##########
@@ -1737,3 +1737,46 @@ func TestExclusiveProducer(t *testing.T) {
assert.Error(t, err, "Producer should be failed")
assert.True(t, strings.Contains(err.Error(), "ProducerBusy"))
}
+
+func TestWaitForExclusiveProducer(t *testing.T) {
+ client, err := NewClient(ClientOptions{
+ URL: serviceURL,
+ // Set the request timeout is 200ms
+ OperationTimeout: 200 * time.Millisecond,
+ })
+ assert.NoError(t, err)
+ defer client.Close()
+
+ topicName := newTopicName()
+ producer1, err := client.CreateProducer(ProducerOptions{
+ Topic: topicName,
+ ProducerAccessMode: ProducerAccessModeExclusive,
+ })
+ assert.NoError(t, err)
+ assert.NotNil(t, producer1)
+ defer producer1.Close()
Review Comment:
Where need change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]