wolfstudy commented on a change in pull request #156: [ISSUE #152][consumer] 
add consumer timeout
URL: https://github.com/apache/pulsar-client-go/pull/156#discussion_r362395265
 
 

 ##########
 File path: pulsar/consumer.go
 ##########
 @@ -135,6 +135,10 @@ type Consumer interface {
        // This calls blocks until a message is available.
        Receive(context.Context) (Message, error)
 
+       // Receive a single message.
+       // This calls blocks until a message is available or timeout.
+       ReceiveBlock(context.Context, time.Duration) (Message, error)
 
 Review comment:
   > The user can wrap a context with a timeout in the Receive method.
   
   @cckellogg Agree with you, In here, we can use `context.WithTimeout()`, as 
you provide:
   
   ```
   ctx, cancel := context.WithTimeout(context.Background(), 
500*time.Millisecond)
   defer cancel()
   ```
   
   But I think a more user-friendly way is as follows:
   
   - add `Timeout` filed in `ConsumerOptions` struct
   - provide a new receive method as @xujianhai666 did
   
   Anyway, these forms are ok with me.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to