Documentation
¶
Overview ¶
Example ¶
r := New(10, time.Second) var sum int64 r.Do(context.Background(), 10, func() error { atomic.AddInt64(&sum, 1) return nil }) log.Println("sum", sum)
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner holds the methods of the interface.
func New ¶
New returns a pointer to an instance of runner, which is used to perform all operations at the given rate in requests/s.
Rate and Res can be used in conjection to give you a run frequency. For example rate = 10, res = time.Second will run something 10 times every second.
func (*Runner) Do ¶
Do executes a function a given number of times. For example, if your throttler is configured to run 10 operations per second and you pass 50 for total, this will execute the function 50 times and take 5 seconds.
Click to show internal directories.
Click to hide internal directories.