Skip to content

Commit

Permalink
use single instance of typed error and use errors.Is() for comparison (
Browse files Browse the repository at this point in the history
…thanos-io#6719)

Signed-off-by: Jake Keeys <[email protected]>
  • Loading branch information
jakekeeys authored and coleenquadros committed Sep 18, 2023
1 parent 807d563 commit 1c6bdb8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions pkg/cacheutil/async_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ package cacheutil

import (
"sync"

"github.com/pkg/errors"
)

type asyncOperationProcessor struct {
Expand Down Expand Up @@ -54,13 +52,11 @@ func (p *asyncOperationProcessor) asyncQueueProcessLoop() {
}
}

var errAsyncBufferFull = errors.New("the async buffer is full")

func (p *asyncOperationProcessor) enqueueAsync(op func()) error {
select {
case p.asyncQueue <- op:
return nil
default:
return errAsyncBufferFull
return errMemcachedAsyncBufferFull
}
}
2 changes: 1 addition & 1 deletion pkg/cacheutil/memcached_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func (c *memcachedClient) SetAsync(key string, value []byte, ttl time.Duration)
c.duration.WithLabelValues(opSet).Observe(time.Since(start).Seconds())
})

if err == errMemcachedAsyncBufferFull {
if errors.Is(err, errMemcachedAsyncBufferFull) {
c.skipped.WithLabelValues(opSet, reasonAsyncBufferFull).Inc()
level.Debug(c.logger).Log("msg", "failed to store item to memcached because the async buffer is full", "err", err, "size", len(c.p.asyncQueue))
return nil
Expand Down

0 comments on commit 1c6bdb8

Please sign in to comment.