zzzming opened a new pull request, #799:
URL: https://github.com/apache/pulsar-client-go/pull/799

   Fixes #752 
   
   ### Motivation
   
   The go rate limiter library, beefsack/go-rate, is an MIT license. We have to 
updated the license header. The PR removes this dependency.
   
   ### Modifications
   
   In Go, it is rather simple to implement a rate limiter directly. A buffered 
channel is used to store a request timestamp as message. The channel receiver 
check each timestamp (in the message) to sleep on the remaining time duration. 
   
   The per second rate is the size of channel buffer. If the buffer is full, 
the main producing go routine blocks on producing Pulsar message, until the 
sleep expires and move to on the next message in the channel thus free up a 
slot in the channel.
   
   It resembles leaky bucket rate limiting implementation. Because of 
leveraging go channel, it uses 10 lines of code and remove the dependency 
entirely.
   
   ### Verifying this change
   
   Since the change only affects the perf utility, I built the tool and verify 
the producing rate is accurate.
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (yes)
         Removes beefsak/go-rate dependency
     - The public API: ( no)
     - The schema: (no)
     - The default values of configurations: (no)
     - The wire protocol: (no)
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable / docs / GoDocs / 
not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup 
issue for adding the documentation
   


-- 
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]

Reply via email to