Documentation ¶
Overview ¶
Package memory contains an implementation of the storage interface that lives in memory.
Index ¶
- func New(opts ...StorageOption) storage.OpenFGADatastore
- type AuthorizationModelEntry
- type MemoryBackend
- func (s *MemoryBackend) Close()
- func (s *MemoryBackend) CreateStore(ctx context.Context, newStore *openfgav1.Store) (*openfgav1.Store, error)
- func (s *MemoryBackend) DeleteStore(ctx context.Context, id string) error
- func (s *MemoryBackend) FindLatestAuthorizationModelID(ctx context.Context, store string) (string, error)
- func (s *MemoryBackend) GetStore(ctx context.Context, storeID string) (*openfgav1.Store, error)
- func (s *MemoryBackend) IsReady(context.Context) (storage.ReadinessStatus, error)
- func (s *MemoryBackend) ListStores(ctx context.Context, paginationOptions storage.PaginationOptions) ([]*openfgav1.Store, []byte, error)
- func (s *MemoryBackend) MaxTuplesPerWrite() int
- func (s *MemoryBackend) MaxTypesPerAuthorizationModel() int
- func (s *MemoryBackend) Read(ctx context.Context, store string, key *openfgav1.TupleKey) (storage.TupleIterator, error)
- func (s *MemoryBackend) ReadAssertions(ctx context.Context, store, modelID string) ([]*openfgav1.Assertion, error)
- func (s *MemoryBackend) ReadAuthorizationModel(ctx context.Context, store string, id string) (*openfgav1.AuthorizationModel, error)
- func (s *MemoryBackend) ReadAuthorizationModels(ctx context.Context, store string, options storage.PaginationOptions) ([]*openfgav1.AuthorizationModel, []byte, error)
- func (s *MemoryBackend) ReadChanges(ctx context.Context, store, objectType string, ...) ([]*openfgav1.TupleChange, []byte, error)
- func (s *MemoryBackend) ReadPage(ctx context.Context, store string, key *openfgav1.TupleKey, ...) ([]*openfgav1.Tuple, []byte, error)
- func (s *MemoryBackend) ReadStartingWithUser(ctx context.Context, store string, filter storage.ReadStartingWithUserFilter) (storage.TupleIterator, error)
- func (s *MemoryBackend) ReadUserTuple(ctx context.Context, store string, key *openfgav1.TupleKey) (*openfgav1.Tuple, error)
- func (s *MemoryBackend) ReadUsersetTuples(ctx context.Context, store string, filter storage.ReadUsersetTuplesFilter) (storage.TupleIterator, error)
- func (s *MemoryBackend) Write(ctx context.Context, store string, deletes storage.Deletes, ...) error
- func (s *MemoryBackend) WriteAssertions(ctx context.Context, store, modelID string, assertions []*openfgav1.Assertion) error
- func (s *MemoryBackend) WriteAuthorizationModel(ctx context.Context, store string, model *openfgav1.AuthorizationModel) error
- type StorageOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(opts ...StorageOption) storage.OpenFGADatastore
New creates a new MemoryBackend given the options.
Types ¶
type AuthorizationModelEntry ¶
type AuthorizationModelEntry struct {
// contains filtered or unexported fields
}
AuthorizationModelEntry represents an entry in a storage system that holds information about an authorization model.
type MemoryBackend ¶
type MemoryBackend struct {
// contains filtered or unexported fields
}
MemoryBackend provides an ephemeral memory-backed implementation of storage.OpenFGADatastore. These instances may be safely shared by multiple go-routines.
func (*MemoryBackend) Close ¶
func (s *MemoryBackend) Close()
Close does not do anything for MemoryBackend.
func (*MemoryBackend) CreateStore ¶
func (s *MemoryBackend) CreateStore(ctx context.Context, newStore *openfgav1.Store) (*openfgav1.Store, error)
CreateStore adds a new store to the MemoryBackend.
func (*MemoryBackend) DeleteStore ¶
func (s *MemoryBackend) DeleteStore(ctx context.Context, id string) error
DeleteStore removes a store from the MemoryBackend.
func (*MemoryBackend) FindLatestAuthorizationModelID ¶
func (s *MemoryBackend) FindLatestAuthorizationModelID(ctx context.Context, store string) (string, error)
FindLatestAuthorizationModelID see storage.AuthorizationModelReadBackend.FindLatestAuthorizationModelID.
func (*MemoryBackend) GetStore ¶
GetStore retrieves the details of a specific store from the MemoryBackend using its storeID.
func (*MemoryBackend) IsReady ¶
func (s *MemoryBackend) IsReady(context.Context) (storage.ReadinessStatus, error)
IsReady see storage.OpenFGADatastore.IsReady.
func (*MemoryBackend) ListStores ¶
func (s *MemoryBackend) ListStores(ctx context.Context, paginationOptions storage.PaginationOptions) ([]*openfgav1.Store, []byte, error)
ListStores provides a paginated list of all stores present in the MemoryBackend.
func (*MemoryBackend) MaxTuplesPerWrite ¶
func (s *MemoryBackend) MaxTuplesPerWrite() int
MaxTuplesPerWrite see storage.RelationshipTupleWriter.MaxTuplesPerWrite.
func (*MemoryBackend) MaxTypesPerAuthorizationModel ¶
func (s *MemoryBackend) MaxTypesPerAuthorizationModel() int
MaxTypesPerAuthorizationModel see storage.TypeDefinitionWriteBackend.MaxTypesPerAuthorizationModel.
func (*MemoryBackend) Read ¶
func (s *MemoryBackend) Read(ctx context.Context, store string, key *openfgav1.TupleKey) (storage.TupleIterator, error)
Read see storage.RelationshipTupleReader.Read.
func (*MemoryBackend) ReadAssertions ¶
func (s *MemoryBackend) ReadAssertions(ctx context.Context, store, modelID string) ([]*openfgav1.Assertion, error)
ReadAssertions see storage.AssertionsBackend.ReadAssertions.
func (*MemoryBackend) ReadAuthorizationModel ¶
func (s *MemoryBackend) ReadAuthorizationModel( ctx context.Context, store string, id string, ) (*openfgav1.AuthorizationModel, error)
ReadAuthorizationModel see storage.AuthorizationModelReadBackend.ReadAuthorizationModel.
func (*MemoryBackend) ReadAuthorizationModels ¶
func (s *MemoryBackend) ReadAuthorizationModels( ctx context.Context, store string, options storage.PaginationOptions, ) ([]*openfgav1.AuthorizationModel, []byte, error)
ReadAuthorizationModels see storage.AuthorizationModelReadBackend.ReadAuthorizationModels.
func (*MemoryBackend) ReadChanges ¶
func (s *MemoryBackend) ReadChanges( ctx context.Context, store, objectType string, paginationOptions storage.PaginationOptions, horizonOffset time.Duration, ) ([]*openfgav1.TupleChange, []byte, error)
ReadChanges see storage.ChangelogBackend.ReadChanges.
func (*MemoryBackend) ReadPage ¶
func (s *MemoryBackend) ReadPage( ctx context.Context, store string, key *openfgav1.TupleKey, paginationOptions storage.PaginationOptions, ) ([]*openfgav1.Tuple, []byte, error)
ReadPage see storage.RelationshipTupleReader.ReadPage.
func (*MemoryBackend) ReadStartingWithUser ¶
func (s *MemoryBackend) ReadStartingWithUser( ctx context.Context, store string, filter storage.ReadStartingWithUserFilter, ) (storage.TupleIterator, error)
ReadStartingWithUser see storage.RelationshipTupleReader.ReadStartingWithUser.
func (*MemoryBackend) ReadUserTuple ¶
func (s *MemoryBackend) ReadUserTuple(ctx context.Context, store string, key *openfgav1.TupleKey) (*openfgav1.Tuple, error)
ReadUserTuple see storage.RelationshipTupleReader.ReadUserTuple.
func (*MemoryBackend) ReadUsersetTuples ¶
func (s *MemoryBackend) ReadUsersetTuples( ctx context.Context, store string, filter storage.ReadUsersetTuplesFilter, ) (storage.TupleIterator, error)
ReadUsersetTuples see storage.RelationshipTupleReader.ReadUsersetTuples.
func (*MemoryBackend) Write ¶
func (s *MemoryBackend) Write(ctx context.Context, store string, deletes storage.Deletes, writes storage.Writes) error
Write see storage.RelationshipTupleWriter.Write.
func (*MemoryBackend) WriteAssertions ¶
func (s *MemoryBackend) WriteAssertions(ctx context.Context, store, modelID string, assertions []*openfgav1.Assertion) error
WriteAssertions see storage.AssertionsBackend.WriteAssertions.
func (*MemoryBackend) WriteAuthorizationModel ¶
func (s *MemoryBackend) WriteAuthorizationModel(ctx context.Context, store string, model *openfgav1.AuthorizationModel) error
WriteAuthorizationModel see storage.TypeDefinitionWriteBackend.WriteAuthorizationModel.
type StorageOption ¶ added in v1.1.1
type StorageOption func(dataStore *MemoryBackend)
StorageOption defines a function type used for configuring a MemoryBackend instance.
func WithMaxTuplesPerWrite ¶ added in v1.1.1
func WithMaxTuplesPerWrite(n int) StorageOption
WithMaxTuplesPerWrite returns a StorageOption that sets the maximum number of tuples allowed in a single write operation. This option is used to configure a MemoryBackend instance, providing a limit to the number of tuples that can be written at once. This helps in managing and controlling the load and performance of the memory storage during bulk write operations.
func WithMaxTypesPerAuthorizationModel ¶ added in v1.1.1
func WithMaxTypesPerAuthorizationModel(n int) StorageOption
WithMaxTypesPerAuthorizationModel returns a StorageOption that sets the maximum number of types allowed per authorization model. This configuration is particularly useful for limiting the complexity or size of an authorization model in a MemoryBackend instance, ensuring that models remain manageable and within predefined resource constraints.