Versions in this module Expand all Collapse all v1 v1.0.0 Apr 5, 2021 Changes in this version + const MaxTxnId + const MaxTxnVersion + const MaxTxnVersionDate + var AllDBTypes []DBType + var BasicTxnTypesDesc string + var DBTypeMemory = addDBType("memory") + var DBTypeMongo = addDBType("mongo") + var DBTypeRedis = addDBType("redis") + var DefaultReadModifyWriteQueueCfg = NewReadModifyWriteQueueCfg(consts.MaxReadModifyWriteQueueCapacityPerKey, ...) + var DefaultTableTxnCfg = NewTabletTxnConfig(consts.DefaultStaleWriteThreshold) + var DefaultTableTxnManagerCfg = NewTabletTxnManagerConfig(DefaultTableTxnCfg, DefaultReadModifyWriteQueueCfg) + var EmptyDBValue = DBValue + var EmptyKVCCRemoveTxnRecordOption = KVCCRemoveTxnRecordOption + var EmptyKVCCRollbackKeyOption = KVCCRollbackKeyOption + var EmptyTValue = TValue + var EmptyValue = Value + var EmptyValueCC = ValueCC + var KVCCClearWriteIntent = KVCCUpdateMetaOption + var TxnTypeDefault = newBasicTxnType(0, "default") + var TxnTypeReadModifyWrite = newBasicTxnType(1, "read_modify_write") + var TxnTypeSnapshotRead = newBasicTxnType(1 << 2, "snapshot_read") + var TxnTypeWaitWhenReadDirty = newBasicTxnType(1 << 1, "wait_when_read_dirty") + func SafeIncr(version *uint64) + func ValidateMGetRequest(keys []string) error + func ValidateMSetRequest(keys []string, values [][]byte) error + type Assertions struct + func NewAssertion(t T) *Assertions + func (assert *Assertions) EqualIntValue(exp Value, actual Value) (b bool) + func (assert *Assertions) EqualValue(exp Value, actual Value) (b bool) + type AtomicTxnId struct + func NewAtomicTxnId(n uint64) AtomicTxnId + func (i *AtomicTxnId) Get() TxnId + func (i *AtomicTxnId) Set(id TxnId) + func (i *AtomicTxnId) SetIfBiggerUnsafe(id TxnId) + type AtomicTxnState struct + func NewAtomicTxnState(state TxnState) AtomicTxnState + func (s *AtomicTxnState) GetTxnState() TxnState + func (s *AtomicTxnState) IsAborted() bool + func (s *AtomicTxnState) IsCommitted() bool + func (s *AtomicTxnState) IsStaging() bool + func (s *AtomicTxnState) IsTerminated() bool + func (s *AtomicTxnState) SetRollbacking() (abortOnce bool) + func (s *AtomicTxnState) SetTxnState(state TxnState) (newState TxnState, terminateOnce bool) + func (s *AtomicTxnState) SetTxnStateUnsafe(state TxnState) (newState TxnState, terminateOnce bool) + func (s *AtomicTxnState) String() string + type DBMeta struct + Flag uint8 + InternalVersion TxnInternalVersion + func (m DBMeta) IsCommitted() bool + func (m DBMeta) IsDirty() bool + func (m DBMeta) WithVersion(version uint64) Meta + type DBType string + type DBValue struct + V []byte + func (v *DBValue) Decode(data []byte) error + func (v DBValue) Encode() []byte + func (v DBValue) WithCommitted() DBValue + func (v DBValue) WithVersion(version uint64) Value + type KV interface + Close func() error + Get func(ctx context.Context, key string, opt KVReadOption) (Value, error) + RemoveTxnRecord func(ctx context.Context, version uint64) error + RollbackKey func(ctx context.Context, key string, version uint64) error + Set func(ctx context.Context, key string, val Value, opt KVWriteOption) error + UpdateMeta func(ctx context.Context, key string, version uint64, opt KVUpdateMetaOption) error + type KVCC interface + Close func() error + Get func(ctx context.Context, key string, opt KVCCReadOption) (ValueCC, error) + RemoveTxnRecord func(ctx context.Context, version uint64, opt KVCCRemoveTxnRecordOption) error + RollbackKey func(ctx context.Context, key string, version uint64, opt KVCCRollbackKeyOption) error + Set func(ctx context.Context, key string, val Value, opt KVCCWriteOption) error + UpdateMeta func(ctx context.Context, key string, version uint64, opt KVCCUpdateMetaOption) error + type KVCCOperationOption struct + Flag uint8 + func (opt *KVCCOperationOption) CondSetOperatedByDifferentTxn(b bool) + func (opt *KVCCOperationOption) CondSetReadModifyWrite(b bool) + func (opt *KVCCOperationOption) CondSetReadOnlyKey(b bool) + func (opt KVCCOperationOption) GetFlagAsUint32() uint32 + func (opt KVCCOperationOption) IsOperatedByDifferentTxn() bool + func (opt KVCCOperationOption) IsReadModifyWrite() bool + func (opt KVCCOperationOption) IsReadOnlyKey() bool + type KVCCReadOption struct + ExactVersion uint64 + MinAllowedSnapshotVersion uint64 + ReaderVersion uint64 + func NewKVCCReadOption(readerVersion uint64) KVCCReadOption + func NewKVCCReadOptionFromPB(x *kvccpb.KVCCReadOption) KVCCReadOption + func NewSnapshotKVCCReadOption(snapshotVersion uint64, minAllowedSnapshotVersion uint64) KVCCReadOption + func (opt KVCCReadOption) CondReadModifyWrite(b bool) KVCCReadOption + func (opt KVCCReadOption) CondReadModifyWriteFirstReadOfKey(b bool) KVCCReadOption + func (opt KVCCReadOption) CondWaitWhenReadDirty(b bool) KVCCReadOption + func (opt KVCCReadOption) GetKVReadVersion() uint64 + func (opt KVCCReadOption) IsGetMaxReadVersion() bool + func (opt KVCCReadOption) IsMetaOnly() bool + func (opt KVCCReadOption) IsReadExactVersion() bool + func (opt KVCCReadOption) IsReadModifyWrite() bool + func (opt KVCCReadOption) IsReadModifyWriteFirstReadOfKey() bool + func (opt KVCCReadOption) IsSnapshotRead() bool + func (opt KVCCReadOption) IsTxnRecord() bool + func (opt KVCCReadOption) IsUpdateTimestampCache() bool + func (opt KVCCReadOption) IsWaitWhenReadDirty() bool + func (opt KVCCReadOption) ToKVReadOption() (kvOpt KVReadOption) + func (opt KVCCReadOption) ToPB() *kvccpb.KVCCReadOption + func (opt KVCCReadOption) WithExactVersion(exactVersion uint64) KVCCReadOption + func (opt KVCCReadOption) WithIncrReaderVersion() KVCCReadOption + func (opt KVCCReadOption) WithKVReadVersion(kvReadVersion uint64) (kvOpt KVReadOption) + func (opt KVCCReadOption) WithMetaOnly() KVCCReadOption + func (opt KVCCReadOption) WithNotGetMaxReadVersion() KVCCReadOption + func (opt KVCCReadOption) WithNotUpdateTimestampCache() KVCCReadOption + func (opt KVCCReadOption) WithTxnRecord() KVCCReadOption + type KVCCRemoveTxnRecordOption struct + func NewKVCCCRemoveTxnRecordOptionFromPB(opt *kvccpb.KVCCRemoveTxnRecordOption) KVCCRemoveTxnRecordOption + func (opt KVCCRemoveTxnRecordOption) CondRemoveByDifferentTransaction(b bool) KVCCRemoveTxnRecordOption + func (opt KVCCRemoveTxnRecordOption) CondRollback(b bool) KVCCRemoveTxnRecordOption + func (opt KVCCRemoveTxnRecordOption) IsRollback() bool + func (opt KVCCRemoveTxnRecordOption) ToPB() *kvccpb.KVCCRemoveTxnRecordOption + type KVCCRollbackKeyOption struct + func NewKVCCCRollbackKeyOptionFromPB(opt *kvccpb.KVCCRollbackKeyOption) KVCCRollbackKeyOption + func (opt KVCCRollbackKeyOption) CondReadModifyWrite(b bool) KVCCRollbackKeyOption + func (opt KVCCRollbackKeyOption) CondReadOnlyKey(b bool) KVCCRollbackKeyOption + func (opt KVCCRollbackKeyOption) CondRollbackByDifferentTxn(b bool) KVCCRollbackKeyOption + func (opt KVCCRollbackKeyOption) ToPB() *kvccpb.KVCCRollbackKeyOption + type KVCCUpdateMetaOption struct + func NewKVCCCUpdateMetaOptionFromPB(opt *kvccpb.KVCCUpdateMetaOption) KVCCUpdateMetaOption + func (opt KVCCUpdateMetaOption) CondReadModifyWrite(b bool) KVCCUpdateMetaOption + func (opt KVCCUpdateMetaOption) CondReadOnlyKey(b bool) KVCCUpdateMetaOption + func (opt KVCCUpdateMetaOption) CondUpdateByDifferentTxn(b bool) KVCCUpdateMetaOption + func (opt KVCCUpdateMetaOption) IsClearWriteIntent() bool + func (opt KVCCUpdateMetaOption) ToKV() KVUpdateMetaOption + func (opt KVCCUpdateMetaOption) ToPB() *kvccpb.KVCCUpdateMetaOption + type KVCCWriteOption struct + func NewKVCCWriteOption() KVCCWriteOption + func NewKVCCWriteOptionFromPB(x *kvccpb.KVCCWriteOption) KVCCWriteOption + func (opt *KVCCWriteOption) ToPB() *kvccpb.KVCCWriteOption + func (opt KVCCWriteOption) CondReadModifyWrite(b bool) KVCCWriteOption + func (opt KVCCWriteOption) IsReadModifyWrite() bool + func (opt KVCCWriteOption) IsTxnRecord() bool + func (opt KVCCWriteOption) ToKVWriteOption() KVWriteOption + func (opt KVCCWriteOption) WithTxnRecord() KVCCWriteOption + type KVReadOption struct + Flag uint8 + Version uint64 + func NewKVReadOption(Version uint64) KVReadOption + func NewKVReadOptionFromPB(x *kvpb.KVReadOption) KVReadOption + func (opt KVReadOption) IsMetaOnly() bool + func (opt KVReadOption) IsReadExactVersion() bool + func (opt KVReadOption) IsTxnRecord() bool + func (opt KVReadOption) ToPB() *kvpb.KVReadOption + func (opt KVReadOption) WithExactVersion() KVReadOption + func (opt KVReadOption) WithTxnRecord() KVReadOption + type KVUpdateMetaOption uint8 + func NewKVUpdateMetaOptionFromPB(opt *kvpb.KVUpdateMetaOption) KVUpdateMetaOption + func (opt KVUpdateMetaOption) IsClearWriteIntent() bool + func (opt KVUpdateMetaOption) ToPB() *kvpb.KVUpdateMetaOption + type KVWriteOption struct + func NewKVWriteOption() KVWriteOption + func NewKVWriteOptionFromPB(x *kvpb.KVWriteOption) KVWriteOption + func (opt *KVWriteOption) ToPB() *kvpb.KVWriteOption + func (opt KVWriteOption) IsTxnRecord() bool + func (opt KVWriteOption) WithTxnRecord() KVWriteOption + type ListTask struct + func NewListTaskNoResult(id basic.TaskId, name string, runTimeout time.Duration, ...) *ListTask + func NewListTaskWithResult(id basic.TaskId, name string, runTimeout time.Duration, ...) *ListTask + func (t *ListTask) Initialize(id basic.TaskId, name string, runTimeout time.Duration, ...) *ListTask + func (t *ListTask) Next() *ListTask + func (t *ListTask) Prev() *ListTask + func (t *ListTask) SetNext(next *ListTask) + func (t *ListTask) SetPrev(prev *ListTask) + type Meta struct + Flag uint8 + InternalVersion TxnInternalVersion + Version uint64 + func NewMetaFromPB(x *commonpb.ValueMeta) Meta + func (m *Meta) SetAborted() + func (m *Meta) SetCommitted() + func (m Meta) IsAborted() bool + func (m Meta) IsCommitted() bool + func (m Meta) IsDirty() bool + func (m Meta) IsEmpty() bool + func (m Meta) IsFirstWriteOfKey() bool + func (m Meta) IsWriteOfKey() bool + func (m Meta) ToDB() DBMeta + func (m Meta) ToPB() *commonpb.ValueMeta + type ReadModifyWriteQueueCfg struct + CapacityPerKey int + MaxQueuedAge time.Duration + MaxReadersRatio float64 + func NewReadModifyWriteQueueCfg(capacityPerKey int, maxReadersRatio float64, maxQueuedAge time.Duration) ReadModifyWriteQueueCfg + func (cfg ReadModifyWriteQueueCfg) WithMaxQueuedAge(maxQueuedAge time.Duration) ReadModifyWriteQueueCfg + type ReadResultCC map[string]ValueCC + func (r ReadResultCC) Contains(key string) bool + func (r ReadResultCC) MustFirst() string + func (r ReadResultCC) ToTValues(keys []string, newSnapshotVersion uint64) []TValue + type RecordValuesTxn struct + func NewRecordValuesTxn(txn Txn) *RecordValuesTxn + func (txn *RecordValuesTxn) Get(ctx context.Context, key string) (TValue, error) + func (txn *RecordValuesTxn) GetReadValues() map[string]TValue + func (txn *RecordValuesTxn) GetWriteValues() map[string]Value + func (txn *RecordValuesTxn) HasWritten(key string) bool + func (txn *RecordValuesTxn) MGet(ctx context.Context, keys []string) ([]TValue, error) + func (txn *RecordValuesTxn) MSet(ctx context.Context, keys []string, values [][]byte) error + func (txn *RecordValuesTxn) Set(ctx context.Context, key string, val []byte) error + type RetryDetailItem struct + Count int + func (i RetryDetailItem) String() string + type RetryDetailItems []RetryDetailItem + func (r RetryDetailItems) Len() int + func (r RetryDetailItems) Less(i, j int) bool + func (r RetryDetailItems) Swap(i, j int) + type RetryDetails map[errors.ErrorKey]int + func (d RetryDetails) Collect(another RetryDetails) + func (d RetryDetails) GetSortedRetryDetails() (items RetryDetailItems) + func (d RetryDetails) String() string + type T interface + Errorf func(format string, args ...interface{}) + Logf func(format string, args ...interface{}) + Name func() string + type TValue struct + SnapshotVersion uint64 + func NewTValue(value Value, snapshotVersion uint64) TValue + func NewTValueFromPB(x *txnpb.TValue) TValue + func NewTValuesFromPB(pbValues []*txnpb.TValue) []TValue + func (v TValue) CondPreventedFutureWrite(b bool) TValue + func (v TValue) IsEmpty() bool + func (v TValue) IsFutureWritePrevented() bool + func (v TValue) ToPB() *txnpb.TValue + type TValues []TValue + func (vs TValues) ToPB() []*txnpb.TValue + type TabletTxnConfig struct + MaxClockDrift time.Duration + StaleWriteThreshold time.Duration + func NewTabletTxnConfig(staleWriteThreshold time.Duration) TabletTxnConfig + func (cfg TabletTxnConfig) GetWaitTimestampCacheInvalidTimeout() time.Duration + func (cfg TabletTxnConfig) String() string + func (cfg TabletTxnConfig) SupportReadModifyWriteTxn() bool + func (cfg TabletTxnConfig) Validate() error + func (cfg TabletTxnConfig) WithMaxClockDrift(val time.Duration) TabletTxnConfig + func (cfg TabletTxnConfig) WithStaleWriteThreshold(val time.Duration) TabletTxnConfig + type TabletTxnConfigMarshaller struct + MaxClockDrift string + StaleWriteThreshold string + type TabletTxnManagerConfig struct + TxnLifeSpan time.Duration + func NewTabletTxnManagerConfig(tabletCfg TabletTxnConfig, readModifyWriteQueueCfg ReadModifyWriteQueueCfg) TabletTxnManagerConfig + func (c TabletTxnManagerConfig) Sanitize() TabletTxnManagerConfig + type TreeTask struct + func NewTreeTaskNoResult(id basic.TaskId, name string, runTimeout time.Duration, parent *TreeTask, ...) *TreeTask + func NewTreeTaskWithResult(id basic.TaskId, name string, runTimeout time.Duration, parent *TreeTask, ...) *TreeTask + func (t *TreeTask) AllChildrenSuccess() bool + func (t *TreeTask) Children() []*TreeTask + func (t *TreeTask) ChildrenSuccess(children []*TreeTask) bool + func (t *TreeTask) Initialize(id basic.TaskId, name string, runTimeout time.Duration, parent *TreeTask, ...) *TreeTask + type Txn interface + Commit func(ctx context.Context) error + Get func(ctx context.Context, key string) (TValue, error) + GetId func() TxnId + GetReadValues func() map[string]TValue + GetSnapshotReadOption func() TxnSnapshotReadOption + GetState func() TxnState + GetType func() TxnType + GetWriteValues func() map[string]Value + MGet func(ctx context.Context, keys []string) (values []TValue, err error) + MSet func(ctx context.Context, keys []string, values [][]byte) error + Rollback func(ctx context.Context) error + Set func(ctx context.Context, key string, val []byte) error + type TxnId uint64 + func (i TxnId) After(duration time.Duration) time.Time + func (i TxnId) Age() time.Duration + func (i TxnId) Max(another TxnId) TxnId + func (i TxnId) String() string + func (i TxnId) Time() time.Time + func (i TxnId) Version() uint64 + type TxnInternalVersion uint8 + const TxnInternalVersionMax + const TxnInternalVersionMin + const TxnInternalVersionPositiveInvalid + func (v TxnInternalVersion) IsValid() bool + type TxnKeyUnion struct + Key string + TxnId TxnId + func (tk TxnKeyUnion) Hash() uint64 + func (tk TxnKeyUnion) String() string + type TxnKind uint8 + const TxnKindReadOnly + const TxnKindReadWrite + const TxnKindWriteOnly + func (k TxnKind) String() string + type TxnManager interface + BeginTransaction func(ctx context.Context, opt TxnOption) (Txn, error) + Close func() error + type TxnManagerConfig struct + ClearTimeout time.Duration + ClearerNum int + MaxTaskBufferedPerPartition int + ReaderNum int + SnapshotBackwardPeriod time.Duration + WoundUncommittedTxnThreshold time.Duration + WriterNum int + func NewTxnManagerConfig(woundUncommittedTxnThreshold time.Duration) TxnManagerConfig + func (cfg TxnManagerConfig) Validate() error + func (cfg TxnManagerConfig) WithClearerNum(clearerNum int) TxnManagerConfig + func (cfg TxnManagerConfig) WithMaxTaskBufferedPerPartition(maxTaskBufferedPerPartition int) TxnManagerConfig + func (cfg TxnManagerConfig) WithReaderNum(readerNum int) TxnManagerConfig + func (cfg TxnManagerConfig) WithWoundUncommittedTxnThreshold(woundUncommittedTxnThreshold time.Duration) TxnManagerConfig + func (cfg TxnManagerConfig) WithWriterNum(writerNum int) TxnManagerConfig + type TxnOption struct + SnapshotReadOption TxnSnapshotReadOption + func NewDefaultTxnOption() TxnOption + func NewTxnOption(typ TxnType) TxnOption + func NewTxnOptionFromPB(option *txnpb.TxnOption) TxnOption + func (opt TxnOption) CondSnapshotReadDontAllowVersionBack(b bool) TxnOption + func (opt TxnOption) ToPB() *txnpb.TxnOption + func (opt TxnOption) WithRelativeSnapshotVersion(snapshotVersionDiff uint64) TxnOption + func (opt TxnOption) WithSnapshotReadDontAllowVersionBack() TxnOption + func (opt TxnOption) WithSnapshotReadMinAllowedSnapshotVersion(minAllowedSnapshotVersion uint64) TxnOption + func (opt TxnOption) WithSnapshotReadRelativeMinAllowedSnapshotVersion(relativeMinAllowedSnapshotVersionDiff uint64) TxnOption + func (opt TxnOption) WithSnapshotVersion(snapshotVersion uint64) TxnOption + type TxnSnapshotReadOption struct + MinAllowedSnapshotVersion uint64 + SnapshotVersion uint64 + func NewTxnSnapshotReadOptionFromPB(opt *txnpb.TxnSnapshotReadOption) TxnSnapshotReadOption + func (opt *TxnSnapshotReadOption) SetSnapshotVersion(snapshotVersion uint64, checkMinAllowedSnapshotVersion bool) + func (opt TxnSnapshotReadOption) AllowsVersionBack() bool + func (opt TxnSnapshotReadOption) Equals(another TxnSnapshotReadOption) bool + func (opt TxnSnapshotReadOption) IsEmpty() bool + func (opt TxnSnapshotReadOption) IsExplicitSnapshotVersion() bool + func (opt TxnSnapshotReadOption) IsRelativeMinAllowedSnapshotVersion() bool + func (opt TxnSnapshotReadOption) IsRelativeSnapshotVersion() bool + func (opt TxnSnapshotReadOption) String() string + func (opt TxnSnapshotReadOption) ToPB() *txnpb.TxnSnapshotReadOption + func (opt TxnSnapshotReadOption) WithClearDontAllowsVersionBack() TxnSnapshotReadOption + type TxnState uint8 + const TxnStateCommitted + const TxnStateInvalid + const TxnStateRollbacked + const TxnStateRollbacking + const TxnStateStaging + const TxnStateUncommitted + func (s TxnState) AsInt32() int32 + func (s TxnState) IsAborted() bool + func (s TxnState) IsCommitted() bool + func (s TxnState) IsStaging() bool + func (s TxnState) IsTerminated() bool + func (s TxnState) String() string + func (s TxnState) ToPB() txnpb.TxnState + type TxnType uint8 + func ParseTxnType(str string) (typ TxnType, _ error) + func (t TxnType) CondWaitWhenReadDirty(b bool) TxnType + func (t TxnType) IsReadModifyWrite() bool + func (t TxnType) IsSnapshotRead() bool + func (t TxnType) IsWaitWhenReadDirty() bool + func (t TxnType) String() string + func (t TxnType) ToUint32() uint32 + type Value struct + V []byte + func NewIntValue(i int) Value + func NewValue(val []byte, version uint64) Value + func NewValueFromPB(x *commonpb.Value) Value + func (v Value) Int() (int, error) + func (v Value) IsEmpty() bool + func (v Value) MustInt() int + func (v Value) String() string + func (v Value) ToDB() DBValue + func (v Value) ToPB() *commonpb.Value + func (v Value) WithCommitted() Value + func (v Value) WithInternalVersion(version TxnInternalVersion) Value + func (v Value) WithMaxReadVersion(maxReadVersion uint64) ValueCC + func (v Value) WithSnapshotVersion(snapshotVersion uint64) ValueCC + func (v Value) WithVersion(version uint64) Value + type ValueCC struct + MaxReadVersion uint64 + SnapshotVersion uint64 + func NewValueCCFromPB(x *commonpb.ValueCC) ValueCC + func (v ValueCC) IsEmpty() bool + func (v ValueCC) ToPB() *commonpb.ValueCC + func (v ValueCC) ToTValue() TValue + func (v ValueCC) WithCommitted() ValueCC + func (v ValueCC) WithMaxReadVersion(maxReadVersion uint64) ValueCC + func (v ValueCC) WithSnapshotVersion(_ uint64) ValueCC + type ValueCCs []ValueCC + func (vs ValueCCs) ToValues() []Value + type Writer struct + Next *Writer + OnUnlocked func() + Version uint64 + func NewWriter(version uint64) *Writer + func (w *Writer) IsClean() bool + func (w *Writer) IsRollbacked() bool + func (w *Writer) IsWriting() bool + func (w *Writer) Lock() + func (w *Writer) MarkClean() + func (w *Writer) MarkRollbacked() + func (w *Writer) Unlock() + func (w *Writer) WaitFinish() + type WriterHeap Writers + func (h *WriterHeap) Initialize() + func (h *WriterHeap) MustContain(writers ...*Writer) + func (h *WriterHeap) Push(x *Writer) + func (h *WriterHeap) Remove(writer *Writer) + func (h WriterHeap) Min() *Writer + type Writers struct + func (ws *Writers) Initialize() + func (ws *Writers) Pop() interface{} + func (ws *Writers) Push(x interface{}) + func (ws Writers) Len() int + func (ws Writers) Less(i, j int) bool + func (ws Writers) Swap(i, j int)