Documentation ¶
Index ¶
- type MemoryConnection
- type MemoryConnectionInterface
- type MemoryDatabase
- type MemoryDatastore
- func (m *MemoryDatastore) Abort(hasCommitted bool) error
- func (m *MemoryDatastore) Commit() error
- func (m *MemoryDatastore) Copy() txn.Datastorer
- func (m *MemoryDatastore) Delete(key string) error
- func (m *MemoryDatastore) DeleteTSR(txnId string) error
- func (m *MemoryDatastore) GetName() string
- func (m *MemoryDatastore) OnePhaseCommit() error
- func (m *MemoryDatastore) Prepare() error
- func (m *MemoryDatastore) Prev(key string, record string)
- func (m *MemoryDatastore) Read(key string, value any) error
- func (m *MemoryDatastore) ReadTSR(txnId string) (config.State, error)
- func (m *MemoryDatastore) Recover(key string)
- func (m *MemoryDatastore) SetTxn(txn *txn.Transaction)
- func (m *MemoryDatastore) Start() error
- func (m *MemoryDatastore) Write(key string, value any) error
- func (m *MemoryDatastore) WriteTSR(txnId string, txnState config.State) error
- type MockMemoryConnection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryConnection ¶
func NewMemoryConnection ¶
func NewMemoryConnection(address string, port int) *MemoryConnection
func (*MemoryConnection) Connect ¶
func (m *MemoryConnection) Connect() error
func (*MemoryConnection) Delete ¶
func (m *MemoryConnection) Delete(key string) error
type MemoryConnectionInterface ¶
type MemoryConnectionInterface interface { // Connect establishes a connection to the memory database. Connect() error // Get retrieves the value associated with the given key from the memory database. // The value is stored in the 'value' parameter. Get(key string, value any) error // Put stores the given value in the memory database with the specified key. Put(key string, value any) error // Delete removes the value associated with the given key from the memory database. Delete(key string) error }
MemoryConnectionInterface represents an interface for a memory connection.
type MemoryDatabase ¶
type MemoryDatabase struct { Address string Port int MsgChan chan string // contains filtered or unexported fields }
func NewMemoryDatabase ¶
func NewMemoryDatabase(address string, port int) *MemoryDatabase
func (*MemoryDatabase) Start ¶
func (m *MemoryDatabase) Start() error
func (*MemoryDatabase) Stop ¶
func (m *MemoryDatabase) Stop()
type MemoryDatastore ¶
type MemoryDatastore struct { Name string Txn *txn.Transaction // contains filtered or unexported fields }
func NewMemoryDatastore ¶
func NewMemoryDatastore(name string, conn MemoryConnectionInterface) *MemoryDatastore
func (*MemoryDatastore) Abort ¶
func (m *MemoryDatastore) Abort(hasCommitted bool) error
Abort discards the changes made in the current transaction. If hasCommitted is false, it clears the write cache. If hasCommitted is true, it rolls back the changes made by the current transaction. It returns an error if there is any issue during the rollback process.
func (*MemoryDatastore) Commit ¶
func (m *MemoryDatastore) Commit() error
Commit updates the state of records in the data store to COMMITTED. It iterates over the write cache and updates each record's state to COMMITTED. After updating the records, it clears the write cache. Returns an error if there is any issue updating the records or clearing the cache.
func (*MemoryDatastore) Copy ¶
func (m *MemoryDatastore) Copy() txn.Datastorer
Copy returns a new instance of MemoryDatastore that is a copy of the current datastore. The copy shares the same name and connection as the original datastore.
func (*MemoryDatastore) Delete ¶
func (m *MemoryDatastore) Delete(key string) error
func (*MemoryDatastore) DeleteTSR ¶
func (m *MemoryDatastore) DeleteTSR(txnId string) error
DeleteTSR deletes a transaction with the given transaction ID from the memory datastore. It returns an error if the deletion operation fails.
func (*MemoryDatastore) GetName ¶
func (m *MemoryDatastore) GetName() string
GetName returns the name of the MemoryDatastore.
func (*MemoryDatastore) OnePhaseCommit ¶
func (m *MemoryDatastore) OnePhaseCommit() error
func (*MemoryDatastore) Prepare ¶
func (m *MemoryDatastore) Prepare() error
func (*MemoryDatastore) Prev ¶
func (m *MemoryDatastore) Prev(key string, record string)
func (*MemoryDatastore) ReadTSR ¶
func (m *MemoryDatastore) ReadTSR(txnId string) (config.State, error)
func (*MemoryDatastore) Recover ¶
func (m *MemoryDatastore) Recover(key string)
func (*MemoryDatastore) SetTxn ¶
func (m *MemoryDatastore) SetTxn(txn *txn.Transaction)
SetTxn sets the transaction for the MemoryDatastore. It takes a pointer to a Transaction as input and assigns it to the Txn field of the MemoryDatastore.
func (*MemoryDatastore) Start ¶
func (m *MemoryDatastore) Start() error
type MockMemoryConnection ¶
type MockMemoryConnection struct { *MemoryConnection // contains filtered or unexported fields }
MockMemoryConnection is a mock of MemoryConnection When Put is called, it will return error when debugCounter is 0 Semantically, it means `Put()` call will succeed X times