sqlite

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Overview

Package sqlite contains an implementation of the storage interface that works with SQLite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareDSN

func PrepareDSN(uri string) (string, error)

Prepare a raw DSN from config for use with SQLite, specifying defaults for journal mode and busy timeout.

Types

type SQLTupleIterator

type SQLTupleIterator struct {
	// contains filtered or unexported fields
}

SQLTupleIterator is a struct that implements the storage.TupleIterator interface for iterating over tuples fetched from a SQL database.

func NewSQLTupleIterator

func NewSQLTupleIterator(rows *sql.Rows) *SQLTupleIterator

NewSQLTupleIterator returns a SQL tuple iterator.

func (*SQLTupleIterator) Head

Head will return the first available item.

func (*SQLTupleIterator) Next

Next will return the next available item.

func (*SQLTupleIterator) Stop

func (t *SQLTupleIterator) Stop()

Stop terminates iteration.

func (*SQLTupleIterator) ToArray

func (t *SQLTupleIterator) ToArray(
	opts storage.PaginationOptions,
) ([]*openfgav1.Tuple, []byte, error)

ToArray converts the tupleIterator to an []*openfgav1.Tuple and a possibly empty continuation token. If the continuation token exists it is the ulid of the last element of the returned array.

type SQLite

type SQLite struct {
	// contains filtered or unexported fields
}

SQLite provides a SQLite based implementation of storage.OpenFGADatastore.

func New

func New(uri string, cfg *sqlcommon.Config) (*SQLite, error)

New creates a new SQLite storage.

func (*SQLite) Close

func (m *SQLite) Close()

Close see storage.OpenFGADatastore.Close.

func (*SQLite) CreateStore

func (m *SQLite) CreateStore(ctx context.Context, store *openfgav1.Store) (*openfgav1.Store, error)

CreateStore adds a new store to the SQLite storage.

func (*SQLite) DeleteStore

func (m *SQLite) DeleteStore(ctx context.Context, id string) error

DeleteStore removes a store from the SQLite storage.

func (*SQLite) FindLatestAuthorizationModel

func (m *SQLite) FindLatestAuthorizationModel(ctx context.Context, store string) (*openfgav1.AuthorizationModel, error)

FindLatestAuthorizationModel see storage.AuthorizationModelReadBackend.FindLatestAuthorizationModel.

func (*SQLite) GetStore

func (m *SQLite) GetStore(ctx context.Context, id string) (*openfgav1.Store, error)

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

func (*SQLite) IsReady

func (m *SQLite) IsReady(ctx context.Context) (storage.ReadinessStatus, error)

IsReady see sqlcommon.IsReady.

func (*SQLite) ListStores

func (m *SQLite) ListStores(ctx context.Context, options storage.ListStoresOptions) ([]*openfgav1.Store, []byte, error)

ListStores provides a paginated list of all stores present in the SQLite storage.

func (*SQLite) MaxTuplesPerWrite

func (m *SQLite) MaxTuplesPerWrite() int

MaxTuplesPerWrite see storage.RelationshipTupleWriter.MaxTuplesPerWrite.

func (*SQLite) MaxTypesPerAuthorizationModel

func (m *SQLite) MaxTypesPerAuthorizationModel() int

MaxTypesPerAuthorizationModel see storage.TypeDefinitionWriteBackend.MaxTypesPerAuthorizationModel.

func (*SQLite) Read

Read see storage.RelationshipTupleReader.Read.

func (*SQLite) ReadAssertions

func (m *SQLite) ReadAssertions(ctx context.Context, store, modelID string) ([]*openfgav1.Assertion, error)

ReadAssertions see storage.AssertionsBackend.ReadAssertions.

func (*SQLite) ReadAuthorizationModel

func (m *SQLite) ReadAuthorizationModel(ctx context.Context, store string, modelID string) (*openfgav1.AuthorizationModel, error)

ReadAuthorizationModel see storage.AuthorizationModelReadBackend.ReadAuthorizationModel.

func (*SQLite) ReadAuthorizationModels

func (m *SQLite) ReadAuthorizationModels(
	ctx context.Context,
	store string,
	options storage.ReadAuthorizationModelsOptions,
) ([]*openfgav1.AuthorizationModel, []byte, error)

ReadAuthorizationModels see storage.AuthorizationModelReadBackend.ReadAuthorizationModels.

func (*SQLite) ReadChanges

func (m *SQLite) ReadChanges(
	ctx context.Context,
	store, objectTypeFilter string,
	options storage.ReadChangesOptions,
	horizonOffset time.Duration,
) ([]*openfgav1.TupleChange, []byte, error)

ReadChanges see storage.ChangelogBackend.ReadChanges.

func (*SQLite) ReadPage

func (m *SQLite) ReadPage(
	ctx context.Context,
	store string,
	tupleKey *openfgav1.TupleKey,
	options storage.ReadPageOptions,
) ([]*openfgav1.Tuple, []byte, error)

ReadPage see storage.RelationshipTupleReader.ReadPage.

func (*SQLite) ReadStartingWithUser

ReadStartingWithUser see storage.RelationshipTupleReader.ReadStartingWithUser.

func (*SQLite) ReadUserTuple

func (m *SQLite) ReadUserTuple(ctx context.Context, store string, tupleKey *openfgav1.TupleKey, _ storage.ReadUserTupleOptions) (*openfgav1.Tuple, error)

ReadUserTuple see storage.RelationshipTupleReader.ReadUserTuple.

func (*SQLite) ReadUsersetTuples

ReadUsersetTuples see storage.RelationshipTupleReader.ReadUsersetTuples.

func (*SQLite) Write

func (m *SQLite) Write(ctx context.Context, store string, deletes storage.Deletes, writes storage.Writes) error

Write see storage.RelationshipTupleWriter.Write.

func (*SQLite) WriteAssertions

func (m *SQLite) WriteAssertions(ctx context.Context, store, modelID string, assertions []*openfgav1.Assertion) error

WriteAssertions see storage.AssertionsBackend.WriteAssertions.

func (*SQLite) WriteAuthorizationModel

func (m *SQLite) WriteAuthorizationModel(ctx context.Context, store string, model *openfgav1.AuthorizationModel) error

WriteAuthorizationModel see storage.TypeDefinitionWriteBackend.WriteAuthorizationModel.

Jump to

Keyboard shortcuts

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