mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 00:40:25 +02:00
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:
parent
e1d84a1dde
commit
8738066ce4
19 changed files with 569 additions and 214 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue