Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vortegatorres committed Jun 27, 2023
1 parent 381e85a commit 0b470fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
8 changes: 5 additions & 3 deletions cloudapi/insights/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ func retryInterceptor(retryConfig RetryConfig) ([]grpc.UnaryClientInterceptor, e

backoffConfig := retryConfig.BackoffConfig
if backoffConfig.Enabled {
backoff := grpcRetry.WithBackoff(grpcRetry.BackoffExponentialWithJitter(backoffConfig.WaitBetween, backoffConfig.JitterFraction))
backoff := grpcRetry.WithBackoff(
grpcRetry.BackoffExponentialWithJitter(backoffConfig.WaitBetween, backoffConfig.JitterFraction))
unaryInterceptor := grpcRetry.UnaryClientInterceptor(withCodes, withMax, withPerRetryTimeout, backoff)
return []grpc.UnaryClientInterceptor{unaryInterceptor}, nil
}
Expand Down Expand Up @@ -252,8 +253,9 @@ func retryableStatusCodes(retryableStatusCodes string) ([]codes.Code, error) {
return nil, fmt.Errorf("no retryable status codes provided")
}

var errorCodes []codes.Code
for _, code := range strings.Split(retryableStatusCodes, ",") {
statusCodes := strings.Split(retryableStatusCodes, ",")
errorCodes := make([]codes.Code, 0, len(statusCodes))
for _, code := range statusCodes {
errorCode, ok := statusCodeMap[code]
if !ok {
return nil, fmt.Errorf("invalid status code %s provided", code)
Expand Down
26 changes: 4 additions & 22 deletions cloudapi/insights/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,6 @@ func (m *mockFailingIngesterServer) BatchCreateRequestMetadatas(_ context.Contex
return nil, m.err
}

type mockRetryFailingIngesterServer struct {
ingester.UnimplementedIngesterServiceServer
maxAttempts uint
attempts uint
err string
}

func (m *mockRetryFailingIngesterServer) BatchCreateRequestMetadatas(_ context.Context, _ *ingester.BatchCreateRequestMetadatasRequest) (*ingester.BatchCreateRequestMetadatasResponse, error) {
return nil, nil
}

func (m *mockRetryFailingIngesterServer) BatchCreateSpans(_ context.Context, _ *ingester.BatchCreateSpansRequest) (*ingester.BatchCreateSpansResponse, error) {
if m.attempts >= m.maxAttempts {
return &ingester.BatchCreateSpansResponse{}, nil
}

m.attempts++
return nil, status.Error(codes.Unavailable, m.err)
}

type fatalError struct{}

func (*fatalError) Error() string { return "context dialer error" }
Expand Down Expand Up @@ -387,7 +367,8 @@ func TestClient_IngestRequestMetadatasBatch_ReturnsErrorWithNoErrorAfterRetrySev
TLSConfig: ClientTLSConfig{Insecure: true},
RetryConfig: RetryConfig{
MaxAttempts: 20,
RetryableStatusCodes: "INTERNAL,UNAVAILABLE"},
RetryableStatusCodes: "INTERNAL,UNAVAILABLE",
},
}
cli := NewClient(cfg)
require.NoError(t, cli.Dial(context.Background()))
Expand Down Expand Up @@ -434,7 +415,8 @@ func TestClient_IngestRequestMetadatasBatch_ReturnsErrorWithErrorAfterRetrySever
JitterFraction: 0.1,
},
MaxAttempts: 5,
RetryableStatusCodes: "INTERNAL,UNAVAILABLE"},
RetryableStatusCodes: "INTERNAL,UNAVAILABLE",
},
}
cli := NewClient(cfg)
require.NoError(t, cli.Dial(context.Background()))
Expand Down

0 comments on commit 0b470fe

Please sign in to comment.