Skip to content

Commit

Permalink
fixup! fixup! Implement PrefetchBloomBlocks gRPC method on gateway
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <[email protected]>
  • Loading branch information
chaudum committed Nov 21, 2024
1 parent a90607d commit b141863
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/bloomgateway/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (m merger) MergeResponse(responses ...resultscache.Response) (resultscache.

type ClientCache struct {
cache *resultscache.ResultsCache
next logproto.BloomGatewayClient
limits CacheLimits
logger log.Logger
}
Expand Down Expand Up @@ -149,12 +150,19 @@ func NewBloomGatewayClientCacheMiddleware(
)

return &ClientCache{
next: next,
cache: resultsCache,
limits: limits,
logger: logger,
}
}

// PrefetchBloomBlocks implements logproto.BloomGatewayClient.
func (c *ClientCache) PrefetchBloomBlocks(ctx context.Context, in *logproto.PrefetchBloomBlocksRequest, opts ...grpc.CallOption) (*logproto.PrefetchBloomBlocksResponse, error) {
return c.next.PrefetchBloomBlocks(ctx, in, opts...)
}

// FilterChunkRefs implements logproto.BloomGatewayClient.
func (c *ClientCache) FilterChunkRefs(ctx context.Context, req *logproto.FilterChunkRefRequest, opts ...grpc.CallOption) (*logproto.FilterChunkRefResponse, error) {
cacheReq := requestWithGrpcCallOptions{
FilterChunkRefRequest: req,
Expand Down
8 changes: 8 additions & 0 deletions pkg/bloomgateway/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ type mockServer struct {
res *logproto.FilterChunkRefResponse
}

var _ logproto.BloomGatewayClient = &mockServer{}

func newMockServer(res *logproto.FilterChunkRefResponse) (*mockServer, *int) {
var calls int
return &mockServer{
Expand All @@ -480,11 +482,17 @@ func (s *mockServer) SetResponse(res *logproto.FilterChunkRefResponse) {
s.res = res
}

// FilterChunkRefs implements logproto.BloomGatewayClient.
func (s *mockServer) FilterChunkRefs(_ context.Context, _ *logproto.FilterChunkRefRequest, _ ...grpc.CallOption) (*logproto.FilterChunkRefResponse, error) {
*s.calls++
return s.res, nil
}

// PrefetchBloomBlocks implements logproto.BloomGatewayClient.
func (s *mockServer) PrefetchBloomBlocks(_ context.Context, _ *logproto.PrefetchBloomBlocksRequest, _ ...grpc.CallOption) (*logproto.PrefetchBloomBlocksResponse, error) {
panic("unimplemented")
}

type mockLimits struct {
cacheFreshness time.Duration
cacheInterval time.Duration
Expand Down

0 comments on commit b141863

Please sign in to comment.