Skip to content

Commit

Permalink
feat: add Reset to the LeakyBucketStateBackend and TokenBucketStateBa…
Browse files Browse the repository at this point in the history
…ckend
  • Loading branch information
leeym committed Oct 26, 2024
1 parent 048d5e1 commit 3ac06eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions leakybucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type LeakyBucketStateBackend interface {
State(ctx context.Context) (LeakyBucketState, error)
// SetState sets (persists) the current state of the LeakyBucket.
SetState(ctx context.Context, state LeakyBucketState) error
// Reset resets (persists) the current state of the LeakyBucket.
Reset(ctx context.Context) error
}

// LeakyBucket implements the https://en.wikipedia.org/wiki/Leaky_bucket#As_a_queue algorithm.
Expand Down
2 changes: 2 additions & 0 deletions tokenbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type TokenBucketStateBackend interface {
State(ctx context.Context) (TokenBucketState, error)
// SetState sets (persists) the current state of the TokenBucket.
SetState(ctx context.Context, state TokenBucketState) error
// Reset resets (persists) the current state of the TokenBucket.
Reset(ctx context.Context) error
}

// TokenBucket implements the https://en.wikipedia.org/wiki/Token_bucket algorithm.
Expand Down

0 comments on commit 3ac06eb

Please sign in to comment.