storagewrappers

package
v1.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package storagewrappers contains decorators for storage implementations.

Index

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

Read see storage.RelationshipTupleReader.ReadUserTuple.

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

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

ReadUsersetTuples see storage.RelationshipTupleReader.ReadUsersetTuples.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL