Skip to content

Commit b3239dc

Browse files
committed
fix: Fixed go doc
1 parent a8093a1 commit b3239dc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

throttle.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ import (
77
)
88

99
// Throttle is an object that will perform exactly one action per duration.
10+
// Do call the function f if a specified duration has passed
11+
// since the last function f was called for this instance of Throttle.
12+
// In other words, given
13+
// var throttle = Throttle.New(time.Minute)
14+
// if throttle.Do(f) is called multiple times within a minute, only the first call will invoke f,
15+
// even if f has a different value in each invocation.
16+
// Waiting for a minute or a new instance of Throttle is required for each function to execute.
1017
type Throttler interface {
11-
// Do call the function f if a specified duration has passed
12-
// since the last function f was called for this instance of Throttle.
13-
// In other words, given
14-
// var throttle = Throttle.New(time.Minute)
15-
// if throttle.Do(f) is called multiple times within a minute, only the first call will invoke f,
16-
// even if f has a different value in each invocation.
17-
// Waiting for a minute or a new instance of Throttle is required for each function to execute.
1818
Do(f func())
1919
}
2020

21-
// New is create Throttler instance
21+
// New create a new Throttler. The duration variable sets the
22+
// duration to restrict Do function argument function f.
2223
func New(duration time.Duration) Throttler {
2324
return &throttle{
2425
duration: duration,

0 commit comments

Comments
 (0)