Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2edcd3ab
Commit
2edcd3ab
authored
Nov 30, 2015
by
Hongchao Deng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
godep: bump up juju/ratelimit
parent
f9715c64
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
Godeps.json
Godeps/Godeps.json
+1
-1
ratelimit.go
Godeps/_workspace/src/github.com/juju/ratelimit/ratelimit.go
+25
-1
No files found.
Godeps/Godeps.json
View file @
2edcd3ab
...
...
@@ -549,7 +549,7 @@
},
{
"ImportPath"
:
"github.com/juju/ratelimit"
,
"Rev"
:
"77
2f5c38e468398c4511514f4f6aa9a4185bc0a0
"
"Rev"
:
"77
ed1c8a01217656d2080ad51981f6e99adaa177
"
},
{
"ImportPath"
:
"github.com/kardianos/osext"
,
...
...
Godeps/_workspace/src/github.com/juju/ratelimit/ratelimit.go
View file @
2edcd3ab
...
...
@@ -8,10 +8,10 @@
package
ratelimit
import
(
"math"
"strconv"
"sync"
"time"
"math"
)
// Bucket represents a token bucket that fills at a predetermined rate.
...
...
@@ -171,6 +171,30 @@ func (tb *Bucket) takeAvailable(now time.Time, count int64) int64 {
return
count
}
// Available returns the number of available tokens. It will be negative
// when there are consumers waiting for tokens. Note that if this
// returns greater than zero, it does not guarantee that calls that take
// tokens from the buffer will succeed, as the number of available
// tokens could have changed in the meantime. This method is intended
// primarily for metrics reporting and debugging.
func
(
tb
*
Bucket
)
Available
()
int64
{
return
tb
.
available
(
time
.
Now
())
}
// available is the internal version of available - it takes the current time as
// an argument to enable easy testing.
func
(
tb
*
Bucket
)
available
(
now
time
.
Time
)
int64
{
tb
.
mu
.
Lock
()
defer
tb
.
mu
.
Unlock
()
tb
.
adjust
(
now
)
return
tb
.
avail
}
// Capacity returns the capacity that the bucket was created with.
func
(
tb
*
Bucket
)
Capacity
()
int64
{
return
tb
.
capacity
}
// Rate returns the fill rate of the bucket, in tokens per second.
func
(
tb
*
Bucket
)
Rate
()
float64
{
return
1e9
*
float64
(
tb
.
quantum
)
/
float64
(
tb
.
fillInterval
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment