sqlite

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 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 HandleSQLError added in v1.6.2

func HandleSQLError(err error, args ...interface{}) error

HandleSQLError processes an SQL error and converts it into a more specific error type based on the nature of the SQL error.

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 Datastore added in v1.6.2

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

Datastore provides a SQLite based implementation of storage.OpenFGADatastore.

func New

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

New creates a new Datastore storage.

func (*Datastore) Close added in v1.6.2

func (s *Datastore) Close()

Close see storage.OpenFGADatastore.Close.

func (*Datastore) CreateStore added in v1.6.2

func (s *Datastore) CreateStore(ctx context.Context, store *openfgav1.Store) (*openfgav1.Store, error)

CreateStore adds a new store to storage.

func (*Datastore) DeleteStore added in v1.6.2

func (s *Datastore) DeleteStore(ctx context.Context, id string) error

DeleteStore removes a store from storage.

func (*Datastore) FindLatestAuthorizationModel added in v1.6.2

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

FindLatestAuthorizationModel see storage.AuthorizationModelReadBackend.FindLatestAuthorizationModel.

func (*Datastore) GetStore added in v1.6.2

func (s *Datastore) GetStore(ctx context.Context, id string) (*openfgav1.Store, error)

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

func (*Datastore) IsReady added in v1.6.2

IsReady see sqlcommon.IsReady.

func (*Datastore) ListStores added in v1.6.2

func (s *Datastore) ListStores(ctx context.Context, options storage.ListStoresOptions) ([]*openfgav1.Store, string, error)

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

func (*Datastore) MaxTuplesPerWrite added in v1.6.2

func (s *Datastore) MaxTuplesPerWrite() int

MaxTuplesPerWrite see storage.RelationshipTupleWriter.MaxTuplesPerWrite.

func (*Datastore) MaxTypesPerAuthorizationModel added in v1.6.2

func (s *Datastore) MaxTypesPerAuthorizationModel() int

MaxTypesPerAuthorizationModel see storage.TypeDefinitionWriteBackend.MaxTypesPerAuthorizationModel.

func (*Datastore) Read added in v1.6.2

Read see storage.RelationshipTupleReader.Read.

func (*Datastore) ReadAssertions added in v1.6.2

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

ReadAssertions see storage.AssertionsBackend.ReadAssertions.

func (*Datastore) ReadAuthorizationModel added in v1.6.2

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

ReadAuthorizationModel see storage.AuthorizationModelReadBackend.ReadAuthorizationModel.

func (*Datastore) ReadAuthorizationModels added in v1.6.2

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

ReadAuthorizationModels see storage.AuthorizationModelReadBackend.ReadAuthorizationModels.

func (*Datastore) ReadChanges added in v1.6.2

ReadChanges see storage.ChangelogBackend.ReadChanges.

func (*Datastore) ReadPage added in v1.6.2

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

ReadPage see storage.RelationshipTupleReader.ReadPage.

func (*Datastore) ReadStartingWithUser added in v1.6.2

ReadStartingWithUser see storage.RelationshipTupleReader.ReadStartingWithUser.

func (*Datastore) ReadUserTuple added in v1.6.2

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

ReadUserTuple see storage.RelationshipTupleReader.ReadUserTuple.

func (*Datastore) ReadUsersetTuples added in v1.6.2

ReadUsersetTuples see storage.RelationshipTupleReader.ReadUsersetTuples.

func (*Datastore) Write added in v1.6.2

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

Write see storage.RelationshipTupleWriter.Write.

func (*Datastore) WriteAssertions added in v1.6.2

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

WriteAssertions see storage.AssertionsBackend.WriteAssertions.

func (*Datastore) WriteAuthorizationModel added in v1.6.2

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

WriteAuthorizationModel see storage.TypeDefinitionWriteBackend.WriteAuthorizationModel.

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

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.

Jump to

Keyboard shortcuts

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