Add optional pause time the limiter will wait for attempting an Acquire #281

Merged
merged 2 commits into from Jun 7, 2017

Conversation

Projects
None yet
3 participants
Owner

wallyworld commented Jun 7, 2017

A Limiter can be created such that it pauses a random time, up to a set maximum, before attempting an Acquire operation.

@jameinel 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

There are a few ways we could specify pause time:

  1. min, max (2 parameters)
  2. max, and assume max/2 as min
  3. average + stddev (2 params)
  4. 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.

limiter.go
+ if l.maxPause <= 0 {
+ return
+ }
+ pauseTime := rand.Intn(int(l.maxPause / time.Millisecond))
@jameinel

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.

@wallyworld

wallyworld Jun 7, 2017

Owner

Yup, added minPause

Owner

wallyworld commented Jun 7, 2017

$$merge$$

Contributor

jujubot commented Jun 7, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

Contributor

jujubot commented Jun 7, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

Contributor

jujubot commented Jun 7, 2017

Owner

wallyworld commented Jun 7, 2017

$$merge$$

Contributor

jujubot commented Jun 7, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

Contributor

jujubot commented Jun 7, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

Contributor

jujubot commented Jun 7, 2017

Owner

wallyworld commented Jun 7, 2017

$$merge$$

Contributor

jujubot commented Jun 7, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

Contributor

jujubot commented Jun 7, 2017

Owner

wallyworld commented Jun 7, 2017

$$merge$$

Contributor

jujubot commented Jun 7, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

Contributor

jujubot commented Jun 7, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

Contributor

jujubot commented Jun 7, 2017

Owner

wallyworld commented Jun 7, 2017

$$merge$$

Contributor

jujubot commented Jun 7, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju-utils

@jujubot jujubot merged commit 61a75f1 into juju:master Jun 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment