memory

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: 15 Imported by: 0

Documentation

Overview

Package memory contains an implementation of the storage interface that lives in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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) FindLatestAuthorizationModel added in v1.5.0

func (s *MemoryBackend) FindLatestAuthorizationModel(ctx context.Context, store string) (*openfgav1.AuthorizationModel, error)

FindLatestAuthorizationModel see storage.AuthorizationModelReadBackend.FindLatestAuthorizationModel.

func (*MemoryBackend) GetStore

func (s *MemoryBackend) GetStore(ctx context.Context, storeID string) (*openfgav1.Store, error)

GetStore retrieves the details of a specific store from the MemoryBackend using its storeID.

func (*MemoryBackend) IsReady

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

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.

Jump to

Keyboard shortcuts

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