Versions in this module Expand all Collapse all v0 v0.9.1 Jun 30, 2024 Changes in this version + const EMPTY + const RETRYINTERVAL + var DeserializeError = errors.Errorf("deserialize error") + var DirtyRead = errors.Errorf("dirty read") + var KeyExists = errors.Errorf("key exists") + var KeyNotFound = errors.Errorf("key not found") + var ReadFailed = errors.Errorf("read failed due to unknown txn status") + var VersionMismatch = errors.Errorf("version mismatch") + type CommitInfo struct + Key string + Version string + type Connector interface + AtomicCreate func(name string, value any) (string, error) + ConditionalCommit func(key string, version string) (string, error) + ConditionalUpdate func(key string, value DataItem, doCreate bool) (string, error) + Connect func() error + Delete func(name string) error + Get func(name string) (string, error) + GetItem func(key string) (DataItem, error) + Put func(name string, value any) error + PutItem func(key string, value DataItem) (string, error) + type DataItem interface + Empty func() bool + Equal func(other DataItem) bool + IsDeleted func() bool + Key func() string + LinkedLen func() int + Prev func() string + SetIsDeleted func(bool) + SetLinkedLen func(int) + SetPrev func(string) + SetValue func(string) + Value func() string + type DataItem2 struct + IsDeleted bool + Key string + LinkedLen int + Prev string + TLease time.Time + TValid time.Time + TxnId string + TxnState config.State + Value string + Version int + func (m DataItem2) GetKey() string + func (mi *DataItem2) UnmarshalBSONValue(t bsontype.Type, raw []byte) error + func (mi DataItem2) MarshalBSONValue() (bsontype.Type, []byte, error) + func (r *DataItem2) Equal(other DataItem2) bool + func (r DataItem2) MarshalBinary() (data []byte, err error) + func (r DataItem2) String() string + type DataItemFactory interface + NewDataItem func(ItemOptions) DataItem + type Datastore struct + Name string + Txn *Transaction + func NewDatastore(name string, conn Connector, factory DataItemFactory) *Datastore + func (r *Datastore) Abort(hasCommitted bool) error + func (r *Datastore) Commit() error + func (r *Datastore) Copy() Datastorer + func (r *Datastore) CreateTSR(txnId string, txnState config.State) (config.State, error) + func (r *Datastore) Delete(key string) error + func (r *Datastore) DeleteTSR(txnId string) error + func (r *Datastore) GetName() string + func (r *Datastore) OnePhaseCommit() error + func (r *Datastore) Prepare() error + func (r *Datastore) Read(key string, value any) error + func (r *Datastore) ReadTSR(txnId string) (config.State, error) + func (r *Datastore) SetSerializer(se serializer.Serializer) + func (r *Datastore) SetTxn(txn *Transaction) + func (r *Datastore) Start() error + func (r *Datastore) Write(key string, value any) error + func (r *Datastore) WriteTSR(txnId string, txnState config.State) error + type Datastorer interface + Abort func(hasCommitted bool) error + Commit func() error + Copy func() Datastorer + Delete func(key string) error + GetName func() string + OnePhaseCommit func() error + Prepare func() error + Read func(key string, value any) error + SetTxn func(txn *Transaction) + Start func() error + Write func(key string, value any) error + type ItemOptions struct + IsDeleted bool + Key string + LinkedLen int + Prev string + TLease time.Time + TValid time.Time + TxnId string + TxnState config.State + Value string + Version string + type ItemType string + const MongoItem + const NoneItem + const RedisItem + type NetworkItem struct + DoCreate bool + Item DataItem + type PredicateInfo struct + ItemKey string + LeaseTime time.Time + State config.State + type RecordConfig struct + ConcurrentOptimizationLevel int + GlobalName string + MaxRecordLen int + ReadStrategy config.ReadStrategy + type RemoteClient interface + Abort func(dsName string, keyList []string, txnId string) error + Commit func(dsName string, infoList []CommitInfo) error + Prepare func(dsName string, itemList []DataItem, startTime time.Time, commitTime time.Time, ...) (map[string]string, error) + Read func(dsName string, key string, ts time.Time, config RecordConfig) (DataItem, RemoteDataStrategy, error) + type RemoteDataStrategy string + const AssumeAbort + const AssumeCommit + const Normal + type SourceType string + const GLOBAL + const LOCAL + type StateMachine struct + func NewStateMachine() *StateMachine + func (st *StateMachine) CheckState(state config.State) error + func (st *StateMachine) GetState() config.State + func (st *StateMachine) SetState(state config.State) error + type TSRMaintainer interface + CreateTSR func(txnId string, txnState config.State) (config.State, error) + DeleteTSR func(txnId string) error + ReadTSR func(txnId string) (config.State, error) + WriteTSR func(txnId string, txnState config.State) error + type Transaction struct + TxnCommitTime time.Time + TxnId string + TxnStartTime time.Time + func NewTransaction() *Transaction + func NewTransactionWithRemote(client RemoteClient) *Transaction + func (t *Transaction) Abort() error + func (t *Transaction) AddDatastore(ds Datastorer) error + func (t *Transaction) AddDatastores(dss ...Datastorer) error + func (t *Transaction) Commit() error + func (t *Transaction) CreateTSR(txnId string, txnState config.State) (config.State, error) + func (t *Transaction) Delete(dsName string, key string) error + func (t *Transaction) DeleteTSR() error + func (t *Transaction) GetTSRState(txnId string) (config.State, error) + func (t *Transaction) Lock(key string, id string, duration time.Duration) error + func (t *Transaction) OnePhaseCommit() error + func (t *Transaction) Read(dsName string, key string, value any) error + func (t *Transaction) RemoteAbort(dsName string, keyList []string) error + func (t *Transaction) RemoteCommit(dsName string, infoList []CommitInfo) error + func (t *Transaction) RemotePrepare(dsName string, itemList []DataItem, validationMap map[string]PredicateInfo) (map[string]string, error) + func (t *Transaction) RemoteRead(dsName string, key string) (DataItem, RemoteDataStrategy, error) + func (t *Transaction) RemoteValidate(dsName string, key string, item DataItem) error + func (t *Transaction) SetGlobalDatastore(ds Datastorer) + func (t *Transaction) SetGlobalTimeSource(url string) + func (t *Transaction) SetLocker(locker locker.Locker) + func (t *Transaction) Start() error + func (t *Transaction) Unlock(key string, id string) error + func (t *Transaction) Write(dsName string, key string, value any) error + func (t *Transaction) WriteTSR(txnId string, txnState config.State) error + type TxnError string + func (e TxnError) Error() string + type TxnItem interface + SetTLease func(time.Time) + SetTValid func(time.Time) + SetTxnState func(config.State) + SetVersion func(string) + TLease func() time.Time + TValid func() time.Time + TxnId func() string + TxnState func() config.State + Version func() string