Documentation ¶
Overview ¶
Package storagewrappers contains decorators for storage implementations.
Index ¶
- func NewBoundedConcurrencyTupleReader(wrapped storage.RelationshipTupleReader, concurrency uint32) *boundedConcurrencyTupleReader
- func NewCachedOpenFGADatastore(inner storage.OpenFGADatastore, maxSize int) *cachedOpenFGADatastore
- func NewCombinedTupleReader(ds storage.RelationshipTupleReader, contextualTuples []*openfgav1.TupleKey) storage.RelationshipTupleReader
- type ContextTracerWrapper
- func (c *ContextTracerWrapper) Close()
- func (c *ContextTracerWrapper) Read(ctx context.Context, store string, tupleKey *openfgav1.TupleKey) (storage.TupleIterator, error)
- func (c *ContextTracerWrapper) ReadPage(ctx context.Context, store string, tupleKey *openfgav1.TupleKey, ...) ([]*openfgav1.Tuple, []byte, error)
- func (c *ContextTracerWrapper) ReadStartingWithUser(ctx context.Context, store string, opts storage.ReadStartingWithUserFilter) (storage.TupleIterator, error)
- func (c *ContextTracerWrapper) ReadUserTuple(ctx context.Context, store string, tupleKey *openfgav1.TupleKey) (*openfgav1.Tuple, error)
- func (c *ContextTracerWrapper) ReadUsersetTuples(ctx context.Context, store string, filter storage.ReadUsersetTuplesFilter) (storage.TupleIterator, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBoundedConcurrencyTupleReader ¶
func NewBoundedConcurrencyTupleReader(wrapped storage.RelationshipTupleReader, concurrency uint32) *boundedConcurrencyTupleReader
NewBoundedConcurrencyTupleReader returns a wrapper over a datastore that makes sure that there are, at most, "concurrency" concurrent calls to Read, ReadUserTuple and ReadUsersetTuples. Consumers can then rest assured that one client will not hoard all the database connections available.
func NewCachedOpenFGADatastore ¶
func NewCachedOpenFGADatastore(inner storage.OpenFGADatastore, maxSize int) *cachedOpenFGADatastore
NewCachedOpenFGADatastore returns a wrapper over a datastore that caches up to maxSize *openfgav1.AuthorizationModel on every call to storage.ReadAuthorizationModel. It caches with unlimited TTL because models are immutable. It uses LRU for eviction.
func NewCombinedTupleReader ¶
func NewCombinedTupleReader( ds storage.RelationshipTupleReader, contextualTuples []*openfgav1.TupleKey, ) storage.RelationshipTupleReader
NewCombinedTupleReader returns a storage.RelationshipTupleReader that reads from a persistent datastore and from the contextual tuples specified in the request.
Types ¶
type ContextTracerWrapper ¶
type ContextTracerWrapper struct {
storage.OpenFGADatastore
}
ContextTracerWrapper is a wrapper for a datastore that introduces a new context to the underlying datastore methods. Its purpose is to prevent the closure of the underlying database connection in case the original context is cancelled, such as when a client cancels the context. This ensures that ongoing queries are allowed to complete even if the original context is cancelled, helping to avoid unnecessary database connection churn.
func NewContextWrapper ¶
func NewContextWrapper(inner storage.OpenFGADatastore) *ContextTracerWrapper
NewContextWrapper creates a new instance of ContextTracerWrapper, wrapping the specified datastore. It is crucial for ContextTracerWrapper to be the first wrapper around the datastore for traces to function correctly.
func (*ContextTracerWrapper) Close ¶
func (c *ContextTracerWrapper) Close()
Close ensures proper cleanup and closure of resources associated with the OpenFGADatastore.
func (*ContextTracerWrapper) Read ¶
func (c *ContextTracerWrapper) Read(ctx context.Context, store string, tupleKey *openfgav1.TupleKey) (storage.TupleIterator, error)
func (*ContextTracerWrapper) ReadPage ¶
func (c *ContextTracerWrapper) ReadPage(ctx context.Context, store string, tupleKey *openfgav1.TupleKey, opts storage.PaginationOptions) ([]*openfgav1.Tuple, []byte, error)
ReadPage see storage.RelationshipTupleReader.ReadPage.
func (*ContextTracerWrapper) ReadStartingWithUser ¶
func (c *ContextTracerWrapper) ReadStartingWithUser(ctx context.Context, store string, opts storage.ReadStartingWithUserFilter) (storage.TupleIterator, error)
ReadStartingWithUser see storage.RelationshipTupleReader.ReadStartingWithUser.
func (*ContextTracerWrapper) ReadUserTuple ¶
func (c *ContextTracerWrapper) ReadUserTuple(ctx context.Context, store string, tupleKey *openfgav1.TupleKey) (*openfgav1.Tuple, error)
ReadUserTuple see storage.RelationshipTupleReader.ReadUserTuple.
func (*ContextTracerWrapper) ReadUsersetTuples ¶
func (c *ContextTracerWrapper) ReadUsersetTuples(ctx context.Context, store string, filter storage.ReadUsersetTuplesFilter) (storage.TupleIterator, error)
ReadUsersetTuples see storage.RelationshipTupleReader.ReadUsersetTuples.