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
- Variables
- func RequireEqualDB(t require.TestingT, expected, actual *sqlite.Conn)
- type Codec
- type CodecIDManager
- type Decoder
- type DecoderIDManager
- type Encoder
- type EncoderIDManager
- type MockObject
- type MockObject_Expecter
- type MockObject_Expecter_Methods
- type MockObject_GetSQLID_Call
- type MockObject_Prototype
- type MockObject_Prototype_Methods
- type MockObject_SetSQLID_Call
- type Object
- type Store
- func (s *Store) Add(object ecore.EObject, feature ecore.EStructuralFeature, index int, value any)
- func (s *Store) AddAll(object ecore.EObject, feature ecore.EStructuralFeature, index int, ...)
- func (s *Store) AddRoot(object ecore.EObject)
- func (s *Store) All(object ecore.EObject, feature ecore.EStructuralFeature) iter.Seq[any]
- func (s *Store) Clear(object ecore.EObject, feature ecore.EStructuralFeature)
- func (s *Store) Close() error
- func (s *Store) Contains(object ecore.EObject, feature ecore.EStructuralFeature, value any) bool
- func (s *Store) Err() error
- func (s *Store) ExecuteQuery(ctx context.Context, query string, opts *sqlitex.ExecOptions) error
- func (s *Store) Flush(ctx context.Context) error
- func (s *Store) Get(object ecore.EObject, feature ecore.EStructuralFeature, index int) any
- func (s *Store) GetContainer(object ecore.EObject) (ecore.EObject, ecore.EStructuralFeature)
- func (s *Store) GetRoots() []ecore.EObject
- func (s *Store) IndexOf(object ecore.EObject, feature ecore.EStructuralFeature, value any) int
- func (s *Store) IsEmpty(object ecore.EObject, feature ecore.EStructuralFeature) bool
- func (s *Store) IsSet(object ecore.EObject, feature ecore.EStructuralFeature) bool
- func (s *Store) LastIndexOf(object ecore.EObject, feature ecore.EStructuralFeature, value any) int
- func (s *Store) Move(object ecore.EObject, feature ecore.EStructuralFeature, sourceIndex int, ...) any
- func (s *Store) Remove(object ecore.EObject, feature ecore.EStructuralFeature, index int, ...) any
- func (s *Store) RemoveRoot(object ecore.EObject)
- func (s *Store) Serialize(ctx context.Context) *promise.Promise[[]byte]
- func (s *Store) Set(object ecore.EObject, feature ecore.EStructuralFeature, index int, value any, ...) (oldValue any)
- func (s *Store) SetContainer(object ecore.EObject, container ecore.EObject, ...)
- func (s *Store) Size(object ecore.EObject, feature ecore.EStructuralFeature) int
- func (s *Store) ToArray(object ecore.EObject, feature ecore.EStructuralFeature) []any
- func (s *Store) UnRegister(object ecore.EObject, withContents bool) *promise.Promise[any]
- func (s *Store) UnSet(object ecore.EObject, feature ecore.EStructuralFeature)
- func (s *Store) WaitOperations(ctx context.Context, object any) error
- type StoreIDManager
Constants ¶
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 ) )
const SQLITE_MAX_ALLOCATION_SIZE = 2147483391
Variables ¶
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.
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 ¶
Types ¶
type CodecIDManager ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDBDecoder ¶
func NewReaderDecoder ¶
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 NewWriterEncoder ¶
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 ¶
func (_e *MockObject_Expecter_Methods) GetSQLID() *MockObject_GetSQLID_Call
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 ¶
func (_e *MockObject_Expecter_Methods) SetSQLID(_a0 any) *MockObject_SetSQLID_Call
SetSQLID is a helper method to define mock.On call
- _a0 int64
type MockObject_GetSQLID_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 (_c *MockObject_GetSQLID_Call) Return(_a0 int64) *MockObject_GetSQLID_Call
func (*MockObject_GetSQLID_Call) Run ¶
func (_c *MockObject_GetSQLID_Call) Run(run func()) *MockObject_GetSQLID_Call
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 (_m *MockObject_Prototype) EXPECT() *MockObject_Expecter
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 ¶
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 (_c *MockObject_SetSQLID_Call) Return() *MockObject_SetSQLID_Call
func (*MockObject_SetSQLID_Call) Run ¶
func (_c *MockObject_SetSQLID_Call) Run(run func(_a0 int64)) *MockObject_SetSQLID_Call
func (*MockObject_SetSQLID_Call) RunAndReturn ¶
func (_c *MockObject_SetSQLID_Call) RunAndReturn(run func(int64)) *MockObject_SetSQLID_Call
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AddAll ¶
func (s *Store) AddAll(object ecore.EObject, feature ecore.EStructuralFeature, index int, c ecore.Collection)
func (*Store) Close ¶
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) Err ¶
Err returns ErrStoreFailed, wrapping its cause, once the store has lost a transaction
func (*Store) ExecuteQuery ¶
func (*Store) Flush ¶
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) GetContainer ¶
func (*Store) LastIndexOf ¶
func (*Store) RemoveRoot ¶
RemoveRoot implements EStore.
func (*Store) Serialize ¶
Serialize returns the content of the database, with the pending operations committed
func (*Store) SetContainer ¶
func (*Store) UnRegister ¶
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) WaitOperations ¶
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)
}