Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pkg/queue/breaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
)

var (
// ErrRelease indicates that release was called more often than acquire.
ErrRelease = errors.New("semaphore release error: returned tokens must be <= acquired tokens")
// ErrRequestQueueFull indicates the breaker queue depth was exceeded.
ErrRequestQueueFull = errors.New("pending request queue full")
)
Expand Down Expand Up @@ -135,7 +133,7 @@ func (b *Breaker) Reserve(ctx context.Context) (func(), bool) {
// Maybe conditionally executes thunk based on the Breaker concurrency
// and queue parameters. If the concurrency limit and queue capacity are
// already consumed, Maybe returns immediately without calling thunk. If
// the thunk was executed, Maybe returns true, else false.
// the thunk was executed, Maybe returns nil, else error.
func (b *Breaker) Maybe(ctx context.Context, thunk func()) error {
if !b.tryAcquirePending() {
return ErrRequestQueueFull
Expand Down
4 changes: 2 additions & 2 deletions pkg/queue/breaker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ func TestBreakerOverload(t *testing.T) {
reqs.request()
reqs.expectFailure(t)

// The remainer should succeed.
// The remainder should succeed.
reqs.processSuccessfully(t)
reqs.processSuccessfully(t)
}

func TestBreakerQueueing(t *testing.T) {
params := BreakerParams{QueueDepth: 2, MaxConcurrency: 1, InitialCapacity: 0}
params := BreakerParams{QueueDepth: 1, MaxConcurrency: 1, InitialCapacity: 0}
b := NewBreaker(params) // Breaker capacity = 2
Comment thread
novahe marked this conversation as resolved.
reqs := newRequestor(b)

Expand Down