storage: add sync querier (#5570)

* storage: add fallback querier

* storage: add sync querier

* storage: add typed querier

* use synced querier
This commit is contained in:
Caleb Doxsey 2025-04-23 10:15:48 -06:00 committed by GitHub
parent e1d84a1dde
commit 8738066ce4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 569 additions and 214 deletions

View file

@ -3,6 +3,7 @@ package storage
import (
"context"
"encoding/json"
"errors"
grpc "google.golang.org/grpc"
"google.golang.org/grpc/codes"
@ -14,10 +15,14 @@ import (
"github.com/pomerium/pomerium/pkg/grpcutil"
)
// ErrUnavailable indicates that a querier is not available.
var ErrUnavailable = errors.New("unavailable")
// A Querier is a read-only subset of the client methods
type Querier interface {
InvalidateCache(ctx context.Context, in *databroker.QueryRequest)
Query(ctx context.Context, in *databroker.QueryRequest, opts ...grpc.CallOption) (*databroker.QueryResponse, error)
Stop()
}
// nilQuerier always returns NotFound.
@ -26,9 +31,11 @@ type nilQuerier struct{}
func (nilQuerier) InvalidateCache(_ context.Context, _ *databroker.QueryRequest) {}
func (nilQuerier) Query(_ context.Context, _ *databroker.QueryRequest, _ ...grpc.CallOption) (*databroker.QueryResponse, error) {
return nil, status.Error(codes.NotFound, "not found")
return nil, errors.Join(ErrUnavailable, status.Error(codes.NotFound, "not found"))
}
func (nilQuerier) Stop() {}
type querierKey struct{}
// GetQuerier gets the databroker Querier from the context.