Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apps/to_nsq: add --rate to throttle message creation #788

Merged
merged 1 commit into from
Aug 24, 2016

Conversation

jehiah
Copy link
Member

@jehiah jehiah commented Aug 18, 2016

This adds a --rate=int option to to_nsq which will throttle the message creation to that rate per second:

  -rate int
        Throttle messages to n/second. 0 to disable

This is helpful when you want to load a large dataset into a message driven pipeline w/o causing a backlog of messages to process on the NSQ side.

@jehiah jehiah added the feature label Aug 18, 2016
var throttleEnabled bool
if *rate >= 1 {
throttleEnabled = true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throttleEnabled := *rate >= 1

@mreiferson
Copy link
Member

I feel like there are some not-so-important race conditions, so otherwise LGTM

@jehiah
Copy link
Member Author

jehiah commented Aug 24, 2016

comments addressed. 🔨 'd and RFM

@mreiferson
Copy link
Member

❤️

@mreiferson mreiferson merged commit cc29d72 into nsqio:master Aug 24, 2016
@mreiferson mreiferson deleted the to_nsq_rate_788 branch August 24, 2016 20:27
@judwhite
Copy link
Contributor

Have you looked at golang.org/x/time/rate? It supports rates less than 1/s, saves a goroutine and a few lines of code at the cost of an added dependency.

@jehiah
Copy link
Member Author

jehiah commented Sep 18, 2016

@judwhite interesting. Nope never seen/noticed that package before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants