mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-03 18:08:13 +02:00
wip
This commit is contained in:
parent
676c00ac97
commit
44f776a223
6 changed files with 356 additions and 6 deletions
|
@ -23,6 +23,7 @@ import (
|
|||
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.
|
||||
|
@ -34,6 +35,8 @@ func (nilQuerier) Query(_ context.Context, _ *databroker.QueryRequest, _ ...grpc
|
|||
return nil, status.Error(codes.NotFound, "not found")
|
||||
}
|
||||
|
||||
func (nilQuerier) Stop() {}
|
||||
|
||||
type querierKey struct{}
|
||||
|
||||
// GetQuerier gets the databroker Querier from the context.
|
||||
|
@ -117,6 +120,8 @@ func (q *staticQuerier) Query(_ context.Context, req *databroker.QueryRequest, _
|
|||
return QueryRecordCollections(q.records, req)
|
||||
}
|
||||
|
||||
func (q *staticQuerier) Stop() {}
|
||||
|
||||
type clientQuerier struct {
|
||||
client databroker.DataBrokerServiceClient
|
||||
}
|
||||
|
@ -133,6 +138,8 @@ func (q *clientQuerier) Query(ctx context.Context, in *databroker.QueryRequest,
|
|||
return q.client.Query(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (q *clientQuerier) Stop() {}
|
||||
|
||||
type cachingQuerier struct {
|
||||
q Querier
|
||||
cache Cache
|
||||
|
@ -182,6 +189,10 @@ func (q *cachingQuerier) Query(ctx context.Context, in *databroker.QueryRequest,
|
|||
return &res, nil
|
||||
}
|
||||
|
||||
func (q *cachingQuerier) Stop() {
|
||||
q.cache.InvalidateAll()
|
||||
}
|
||||
|
||||
// MarshalQueryRequest marshales the query request.
|
||||
func MarshalQueryRequest(req *databroker.QueryRequest) ([]byte, error) {
|
||||
return (&proto.MarshalOptions{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue