@@ -4,17 +4,20 @@ import (
44 "context"
55 "encoding/json"
66 "errors"
7+ "strconv"
78 "strings"
89 "sync/atomic"
910 "time"
1011
1112 "go.opencensus.io/trace"
1213 "go.uber.org/zap"
1314 "google.golang.org/grpc/codes"
15+ "google.golang.org/grpc/metadata"
1416 "google.golang.org/grpc/status"
1517 "google.golang.org/protobuf/types/known/durationpb"
1618 "google.golang.org/protobuf/types/known/timestamppb"
1719
20+ "github.com/ozontech/seq-db/config"
1821 "github.com/ozontech/seq-db/consts"
1922 "github.com/ozontech/seq-db/logger"
2023 "github.com/ozontech/seq-db/metric"
@@ -66,14 +69,14 @@ type grpcV1 struct {
6669}
6770
6871func newGrpcV1 (
69- config APIConfig ,
72+ apiConfig APIConfig ,
7073 si SearchIngestor ,
7174 mappingProvider MappingProvider ,
7275 rl RateLimiter ,
7376 mirror seqproxyapi.SeqProxyApiClient ,
7477) * grpcV1 {
7578 return & grpcV1 {
76- config : config ,
79+ config : apiConfig ,
7780 searchIngestor : si ,
7881 mappingProvider : mappingProvider ,
7982 rateLimiter : rl ,
@@ -434,6 +437,18 @@ func parseProxyError(e error) (*seqproxyapi.Error, bool) {
434437 return nil , false
435438}
436439
440+ func shouldFailPartialResponse (ctx context.Context ) bool {
441+ md , _ := metadata .FromIncomingContext (ctx )
442+ failPartialResponseValues := md .Get ("fail-partial-response" )
443+ if len (failPartialResponseValues ) == 0 {
444+ // Header isn't set, so use value from config
445+ return config .FailPartialResponse
446+ }
447+ val := failPartialResponseValues [0 ]
448+ failPartialResponse , _ := strconv .ParseBool (val )
449+ return failPartialResponse
450+ }
451+
437452func shouldHaveResponse (code seqproxyapi.ErrorCode ) bool {
438453 return code == seqproxyapi .ErrorCode_ERROR_CODE_NO || code == seqproxyapi .ErrorCode_ERROR_CODE_PARTIAL_RESPONSE
439454}
0 commit comments