Skip to content

Commit

Permalink
fix: Fixed go doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yudppp committed Aug 23, 2021
1 parent a8093a1 commit b3239dc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions throttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import (
)

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

// New is create Throttler instance
// New create a new Throttler. The duration variable sets the
// duration to restrict Do function argument function f.
func New(duration time.Duration) Throttler {
return &throttle{
duration: duration,
Expand Down

0 comments on commit b3239dc

Please sign in to comment.