Package files

Internal call graph ▹

Internal call graph ▾

In the call graph viewer below, each node
is a function belonging to this package
and its children are the functions it
calls—perhaps dynamically.

The root nodes are the entry points of the
package: functions that may be called from
outside the package.
There may be non-exported or anonymous
functions among them if they are called
dynamically from another package.

Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring func
token.

Functions may be omitted if they were
determined to be unreachable in the
particular programs or tests that were
analyzed.

NewBucketWithRate returns a token bucket that fills the bucket
at the rate of rate tokens per second up to the given
maximum capacity. Because of limited clock resolution,
at high rates, the actual rate may be up to 1% different from the
specified rate.

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.

TakeMaxDuration is like Take, except that
it will only take tokens from the bucket if the wait
time for the tokens is no greater than maxWait.

If it would take longer than maxWait for the tokens
to become available, it does nothing and reports false,
otherwise it returns the time that the caller should
wait until the tokens are actually available, and reports
true.

WaitMaxDuration is like Wait except that it will
only take tokens from the bucket if it needs to wait
for no greater than maxWait. It reports whether
any tokens have been removed from the bucket
If no tokens have been removed, it returns immediately.