sqlite

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MPL-2.0 Imports: 33 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlite implements the SQLite codec and store of soft.go/ecore. Importing it registers the codec for the "sqlite" extension in the default codec registry.

Index

Constants

View Source
const (
	OPTION_KEEP_DEFAULTS         = "KEEP_DEFAULTS"         // keep default values
	OPTION_CODEC_VERSION         = "CODEC_VERSION"         // codec version ( int64 )
	OPTION_OBJECT_ID             = "OBJECT_ID"             // object id column name ( string )
	OPTION_CONTAINER_ID          = "CONTAINER_ID"          // container id ( boolean ) if true, encode object's container and container feature id
	OPTION_SQL_ID_MANAGER        = "SQL_ID_MANAGER"        // SQL id manager
	OPTION_IN_MEMORY_DATABASE    = "IN_MEMORY_DATABASE"    // uses a memory database
	OPTION_DECODER_WITH_FEATURES = "DECODER_WITH_FEATURES" // decoder with object features
	OPTION_DECODER_WITH_OBJECTS  = "DECODER_WITH_OBJECTS"  // decoder with objects
	OPTION_DECODER_DB_PATH       = "DECODER_DB_PATH"
	OPTION_LOGGER                = "LOGGER"
	OPTION_OPERATION_TIMEOUT     = "OPERATION_TIMEOUT" // store : duration an operation waits for the writer before failing with ErrStoreOperationTimeout ( time.Duration )
	OPTION_MAX_ALLOC_SIZE        = "MAX_ALLOC_SIZE"
	OPTION_COMMIT_MAX_OPERATIONS = "COMMIT_MAX_OPERATIONS" // store : operations after which the writer commits when its queue is never empty ( int )
	OPTION_COMMIT_MAX_DURATION   = "COMMIT_MAX_DURATION"   // store : duration after which the writer commits when its queue is never empty ( time.Duration )
)
View Source
const SQLITE_MAX_ALLOCATION_SIZE = 2147483391

Variables

View Source
var ErrStoreFailed = errors.New("sql store failed")

ErrStoreFailed is the error of the operations of a store that lost a transaction (the database aborted it or its commit failed) : the writes of the transaction, already accepted, are not in the database and the ids the store registered for their objects are wrong, so the store accepts no operation anymore. The database holds the transactions committed before.

View Source
var ErrStoreOperationTimeout = errors.New("sql store operation timeout")

ErrStoreOperationTimeout is the error of an operation not executed by the writer within the operation timeout. A read is then not executed, a write is still executed

Functions

func RequireEqualDB

func RequireEqualDB(t require.TestingT, expected, actual *sqlite.Conn)

Types

type Codec

type Codec struct {
}

func (*Codec) NewDecoder

func (d *Codec) NewDecoder(resource ecore.EResource, r io.Reader, options map[string]any) ecore.EDecoder

func (*Codec) NewEncoder

func (d *Codec) NewEncoder(resource ecore.EResource, w io.Writer, options map[string]any) ecore.EEncoder

type CodecIDManager

type CodecIDManager interface {
	SetPackageID(ecore.EPackage, int64)
	SetObjectID(ecore.EObject, int64)
	SetClassID(ecore.EClass, int64)
	SetEnumLiteralID(ecore.EEnumLiteral, int64)
}

type Decoder

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

func NewDBDecoder

func NewDBDecoder(connPool *sqlitex.Pool, resource ecore.EResource, options map[string]any) *Decoder

func NewReaderDecoder

func NewReaderDecoder(r io.Reader, resource ecore.EResource, options map[string]any) *Decoder

func (*Decoder) DecodeObject

func (d *Decoder) DecodeObject() (ecore.EObject, error)

func (*Decoder) DecodeResource

func (d *Decoder) DecodeResource()

type DecoderIDManager

type DecoderIDManager interface {
	CodecIDManager
	// Returns package with a specific id
	// Returns (package with request id otherwise nil, decoded as true if package is decoded otherwise false)
	GetPackageFromID(int64) (ecore.EPackage, bool)
	// Returns object with a specific id
	// Returns (object with request id otherwise nil, decoded as true if object is decoded otherwise false)
	GetObjectFromID(int64) (ecore.EObject, bool)
	// Returns class with a specific id
	// Returns (class with request id otherwise nil, decoded as true if class is decoded otherwise false)
	GetClassFromID(int64) (ecore.EClass, bool)
	// Returns enum literal with a specific id
	// Returns (enum literal with request id otherwise nil, decoded as true if enum literal is decoded otherwise false)
	GetEnumLiteralFromID(int64) (ecore.EEnumLiteral, bool)
}

type Encoder

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

func NewDBEncoder

func NewDBEncoder(connPool *sqlitex.Pool, resource ecore.EResource, options map[string]any) *Encoder

func NewWriterEncoder

func NewWriterEncoder(w io.Writer, resource ecore.EResource, options map[string]any) *Encoder

func (*Encoder) EncodeObject

func (e *Encoder) EncodeObject(object ecore.EObject) error

func (*Encoder) EncodeResource

func (e *Encoder) EncodeResource()

type EncoderIDManager

type EncoderIDManager interface {
	CodecIDManager
	// Returns package id , decoded as true if package is already encoded otherwise false
	GetPackageID(ecore.EPackage) (int64, bool)
	// Returns object id , decoded as true if package is already encoded otherwise false
	GetObjectID(ecore.EObject) (int64, bool)
	// Returns class id , decoded as true if package is already encoded otherwise false
	GetClassID(ecore.EClass) (int64, bool)
	// Returns enum literal id , decoded as true if package is already encoded otherwise false
	GetEnumLiteralID(ecore.EEnumLiteral) (int64, bool)
}

type MockObject

type MockObject struct {
	MockObject_Prototype
	mock.Mock
}

MockObject_Prototype_Methods is an autogenerated mock type for the Object type

func NewMockObject

func NewMockObject(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockObject

NewMockObject creates a new instance of MockObject_Prototype_Methods. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

type MockObject_Expecter

type MockObject_Expecter struct {
	ecore.MockEObject_Expecter
	MockObject_Expecter_Methods
}

func (*MockObject_Expecter) SetMock

func (_mp *MockObject_Expecter) SetMock(mock *mock.Mock)

type MockObject_Expecter_Methods

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

func (*MockObject_Expecter_Methods) GetSQLID

GetSQLID is a helper method to define mock.On call

func (*MockObject_Expecter_Methods) SetMock

func (_mde *MockObject_Expecter_Methods) SetMock(mock *mock.Mock)

func (*MockObject_Expecter_Methods) SetSQLID

SetSQLID is a helper method to define mock.On call

  • _a0 int64

type MockObject_GetSQLID_Call

type MockObject_GetSQLID_Call struct {
	*mock.Call
}

MockObject_GetSQLID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSQLID'

func (*MockObject_GetSQLID_Call) Return

func (*MockObject_GetSQLID_Call) Run

func (*MockObject_GetSQLID_Call) RunAndReturn

func (_c *MockObject_GetSQLID_Call) RunAndReturn(run func() int64) *MockObject_GetSQLID_Call

type MockObject_Prototype

type MockObject_Prototype struct {
	ecore.MockEObject_Prototype
	MockObject_Prototype_Methods
	// contains filtered or unexported fields
}

func (*MockObject_Prototype) EXPECT

func (*MockObject_Prototype) SetMock

func (_mp *MockObject_Prototype) SetMock(mock *mock.Mock)

type MockObject_Prototype_Methods

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

func (*MockObject_Prototype_Methods) GetSQLID

func (_m *MockObject_Prototype_Methods) GetSQLID() int64

GetSQLID provides a mock function with given fields:

func (*MockObject_Prototype_Methods) SetMock

func (_mdp *MockObject_Prototype_Methods) SetMock(mock *mock.Mock)

func (*MockObject_Prototype_Methods) SetSQLID

func (_m *MockObject_Prototype_Methods) SetSQLID(_a0 int64)

SetSQLID provides a mock function with given fields: _a0

type MockObject_SetSQLID_Call

type MockObject_SetSQLID_Call struct {
	*mock.Call
}

MockObject_SetSQLID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetSQLID'

func (*MockObject_SetSQLID_Call) Return

func (*MockObject_SetSQLID_Call) Run

func (*MockObject_SetSQLID_Call) RunAndReturn

func (_c *MockObject_SetSQLID_Call) RunAndReturn(run func(int64)) *MockObject_SetSQLID_Call

type Object

type Object interface {
	ecore.EObject
	SetSQLID(int64)
	GetSQLID() int64
}

type Store

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

func NewStore

func NewStore(
	databasePath string,
	resourceURI *ecore.URI,
	idManager ecore.EObjectIDManager,
	packageRegistry ecore.EPackageRegistry,
	options map[string]any) (store *Store, err error)

func (*Store) Add

func (s *Store) Add(object ecore.EObject, feature ecore.EStructuralFeature, index int, value any)

func (*Store) AddAll

func (s *Store) AddAll(object ecore.EObject, feature ecore.EStructuralFeature, index int, c ecore.Collection)

func (*Store) AddRoot

func (s *Store) AddRoot(object ecore.EObject)

AddRoot add object as store root

func (*Store) All

func (s *Store) All(object ecore.EObject, feature ecore.EStructuralFeature) iter.Seq[any]

func (*Store) Clear

func (s *Store) Clear(object ecore.EObject, feature ecore.EStructuralFeature)

func (*Store) Close

func (s *Store) Close() error

Close executes and commits the pending operations, and closes the connections. It returns the errors of the operations since the last flush, ErrStoreFailed if the store has failed, and the errors of closing the connections

func (*Store) Contains

func (s *Store) Contains(object ecore.EObject, feature ecore.EStructuralFeature, value any) bool

func (*Store) Err

func (s *Store) Err() error

Err returns ErrStoreFailed, wrapping its cause, once the store has lost a transaction

func (*Store) ExecuteQuery

func (s *Store) ExecuteQuery(ctx context.Context, query string, opts *sqlitex.ExecOptions) error

func (*Store) Flush

func (s *Store) Flush(ctx context.Context) error

Flush waits for all the pending operations to be executed and committed, and returns the errors of the operations since the last flush. Once the store has failed, it returns ErrStoreFailed

func (*Store) Get

func (s *Store) Get(object ecore.EObject, feature ecore.EStructuralFeature, index int) any

func (*Store) GetContainer

func (s *Store) GetContainer(object ecore.EObject) (ecore.EObject, ecore.EStructuralFeature)

func (*Store) GetRoots

func (s *Store) GetRoots() []ecore.EObject

GetRoot return root objects

func (*Store) IndexOf

func (s *Store) IndexOf(object ecore.EObject, feature ecore.EStructuralFeature, value any) int

func (*Store) IsEmpty

func (s *Store) IsEmpty(object ecore.EObject, feature ecore.EStructuralFeature) bool

func (*Store) IsSet

func (s *Store) IsSet(object ecore.EObject, feature ecore.EStructuralFeature) bool

func (*Store) LastIndexOf

func (s *Store) LastIndexOf(object ecore.EObject, feature ecore.EStructuralFeature, value any) int

func (*Store) Move

func (s *Store) Move(object ecore.EObject, feature ecore.EStructuralFeature, sourceIndex int, targetIndex int, needResult bool) any

func (*Store) Remove

func (s *Store) Remove(object ecore.EObject, feature ecore.EStructuralFeature, index int, needResult bool) any

func (*Store) RemoveRoot

func (s *Store) RemoveRoot(object ecore.EObject)

RemoveRoot implements EStore.

func (*Store) Serialize

func (s *Store) Serialize(ctx context.Context) *promise.Promise[[]byte]

Serialize returns the content of the database, with the pending operations committed

func (*Store) Set

func (s *Store) Set(object ecore.EObject, feature ecore.EStructuralFeature, index int, value any, needResult bool) (oldValue any)

func (*Store) SetContainer

func (s *Store) SetContainer(object ecore.EObject, container ecore.EObject, feature ecore.EStructuralFeature)

func (*Store) Size

func (s *Store) Size(object ecore.EObject, feature ecore.EStructuralFeature) int

func (*Store) ToArray

func (s *Store) ToArray(object ecore.EObject, feature ecore.EStructuralFeature) []any

func (*Store) UnRegister

func (s *Store) UnRegister(object ecore.EObject, withContents bool) *promise.Promise[any]

UnRegister forgets the ids of object, and of its contents if withContents, once the operations before it are executed : the objects are encoded again when written again

func (*Store) UnSet

func (s *Store) UnSet(object ecore.EObject, feature ecore.EStructuralFeature)

func (*Store) WaitOperations

func (s *Store) WaitOperations(ctx context.Context, object any) error

WaitOperations waits for all the pending operations to be executed and committed. object is ignored : the operations are executed in order, so waiting for the operations of one object is waiting for all the operations before them. It returns the errors of the operations since the last wait.

type StoreIDManager

type StoreIDManager interface {
	DecoderIDManager
	EncoderIDManager
	ClearObjectID(eObject ecore.EObject)
}

Jump to

Keyboard shortcuts

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