Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Add optional pause time the limiter will wait for attempting an Acquire #281
Conversation
jameinel
changed the title from
Add optional puase time the limiter will wait for attempting an Acquire
to
Add optional pause time the limiter will wait for attempting an Acquire
Jun 7, 2017
jameinel
approved these changes
Jun 7, 2017
There are a few ways we could specify pause time:
- min, max (2 parameters)
- max, and assume max/2 as min
- average + stddev (2 params)
- average + assumed stddev (sqrt(avg) is pretty common)
I'm fine with any of them min = max/2 might be a quick and easy way. I don't think its going to be something we tweak a lot.
| + if l.maxPause <= 0 { | ||
| + return | ||
| + } | ||
| + pauseTime := rand.Intn(int(l.maxPause / time.Millisecond)) |
jameinel
Jun 7, 2017
Owner
I wonder if we want to have some way to have a minimum pause time that isn't 0. but this is better than nothing.
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils |
|
Build failed: Tests failed |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils |
|
Build failed: Tests failed |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils |
|
Build failed: Tests failed |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils |
|
Build failed: Tests failed |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils |
wallyworld commentedJun 7, 2017
A Limiter can be created such that it pauses a random time, up to a set maximum, before attempting an Acquire operation.