Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Štibraný <[email protected]>
Signed-off-by: Vladimir Varankin <[email protected]>
  • Loading branch information
narqo and pstibrany committed Mar 12, 2024
1 parent f4e24c5 commit 52bcfd7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions pkg/ingester/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import (
const (
integerUnavailableMsgFormat = "ingester is unavailable (current state: %s)"
ingesterTooBusyMsg = "ingester is currently too busy to process queries, try again later"
ingesterPushAPIDisabledMsg = "ingester is configured with Push API disabled"
ingesterPushGrpcDisabledMsg = "ingester is configured with Push gRPC method disabled"
)

var (
errTooBusy = ingesterTooBusyError{}
errPushAPIDisabled = newErrorWithStatus(ingesterPushAPIDisabledError{}, codes.Unimplemented)
errTooBusy = ingesterTooBusyError{}
errPushGrpcDisabled = newErrorWithStatus(ingesterPushGrpcDisabledError{}, codes.Unimplemented)
)

// errorWithStatus is used for wrapping errors returned by ingester.
Expand Down Expand Up @@ -527,18 +527,18 @@ func (e ingesterTooBusyError) errorCause() mimirpb.ErrorCause {
// Ensure that ingesterTooBusyError is an ingesterError.
var _ ingesterError = ingesterTooBusyError{}

type ingesterPushAPIDisabledError struct{}
type ingesterPushGrpcDisabledError struct{}

func (e ingesterPushAPIDisabledError) Error() string {
return ingesterPushAPIDisabledMsg
func (e ingesterPushGrpcDisabledError) Error() string {
return ingesterPushGrpcDisabledMsg
}

func (e ingesterPushAPIDisabledError) errorCause() mimirpb.ErrorCause {
func (e ingesterPushGrpcDisabledError) errorCause() mimirpb.ErrorCause {
return mimirpb.METHOD_NOT_ALLOWED
}

// Ensure that ingesterPushAPIDisabledError is an ingesterError.
var _ ingesterError = ingesterPushAPIDisabledError{}
// Ensure that ingesterPushGrpcDisabledError is an ingesterError.
var _ ingesterError = ingesterPushGrpcDisabledError{}

type ingesterErrSamplers struct {
sampleTimestampTooOld *log.Sampler
Expand Down
6 changes: 3 additions & 3 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -3490,7 +3490,7 @@ func (i *Ingester) checkAvailable() error {
return newUnavailableError(s)
}

// PushToStorage is a low-level implementation of Push() for block storage.
// PushToStorage implements ingest.Pusher interface for ingestion via ingest-storage.
func (i *Ingester) PushToStorage(ctx context.Context, req *mimirpb.WriteRequest) error {
err := i.PushWithCleanup(ctx, req, func() { mimirpb.ReuseSlice(req.Timeseries) })
if err != nil {
Expand All @@ -3499,10 +3499,10 @@ func (i *Ingester) PushToStorage(ctx context.Context, req *mimirpb.WriteRequest)
return nil
}

// Push implements client.IngesterServer
// Push implements client.IngesterServer, which is registered into gRPC server.
func (i *Ingester) Push(ctx context.Context, req *mimirpb.WriteRequest) (*mimirpb.WriteResponse, error) {
if !i.cfg.PushGrpcMethodEnabled {
return nil, errPushAPIDisabled
return nil, errPushGrpcDisabled
}

err := i.PushToStorage(ctx, req)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingester/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6770,7 +6770,7 @@ func TestIngester_PushGrpcMethod_Disabled(t *testing.T) {
[]mimirpb.Sample{{TimestampMs: 1_000, Value: 1}},
)
_, err = i.Push(ctx, req)
require.ErrorIs(t, err, errPushAPIDisabled)
require.ErrorIs(t, err, errPushGrpcDisabled)
}

func TestIngester_instanceLimitsMetrics(t *testing.T) {
Expand Down

0 comments on commit 52bcfd7

Please sign in to comment.