types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxTxnVersionDate = "2200-01-01T00:00:00Z"
	MaxTxnVersion     = uint64(7258118400000000000)
	MaxTxnId          = TxnId(MaxTxnVersion)
)

Variables

View Source
var (
	DBTypeMemory = addDBType("memory")
	DBTypeRedis  = addDBType("redis")
	DBTypeMongo  = addDBType("mongo")
)
View Source
var (
	BasicTxnTypesDesc string

	TxnTypeDefault           = newBasicTxnType(0, "default")
	TxnTypeReadModifyWrite   = newBasicTxnType(1, "read_modify_write")
	TxnTypeWaitWhenReadDirty = newBasicTxnType(1<<1, "wait_when_read_dirty")
	TxnTypeSnapshotRead      = newBasicTxnType(1<<2, "snapshot_read")
)
View Source
var AllDBTypes []DBType
View Source
var EmptyDBValue = DBValue{}
View Source
var EmptyKVCCRemoveTxnRecordOption = KVCCRemoveTxnRecordOption{}
View Source
var EmptyKVCCRollbackKeyOption = KVCCRollbackKeyOption{}
View Source
var EmptyTValue = TValue{}
View Source
var EmptyValue = Value{}
View Source
var EmptyValueCC = ValueCC{}
View Source
var KVCCClearWriteIntent = KVCCUpdateMetaOption{KVCCOperationOption: KVCCOperationOption{Flag: KVKVCCUpdateMetaOptBitMaskClearWriteIntent}}

Functions

func SafeIncr

func SafeIncr(version *uint64)

func ValidateMGetRequest

func ValidateMGetRequest(keys []string) error

func ValidateMSetRequest

func ValidateMSetRequest(keys []string, values [][]byte) error

Types

type Assertions

type Assertions struct {
	testifyassert.Assertions
}

func NewAssertion

func NewAssertion(t T) *Assertions

func (*Assertions) EqualIntValue

func (assert *Assertions) EqualIntValue(exp Value, actual Value) (b bool)

func (*Assertions) EqualValue

func (assert *Assertions) EqualValue(exp Value, actual Value) (b bool)

type AtomicTxnId

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

AtomicTxnId is a wrapper with a simpler interface around atomic.(Add|Store|Load|CompareAndSwap)TxnId functions.

func NewAtomicTxnId

func NewAtomicTxnId(n uint64) AtomicTxnId

NewAtomicTxnId initializes a new AtomicTxnId with a given value.

func (*AtomicTxnId) Get

func (i *AtomicTxnId) Get() TxnId

Get atomically returns the current value.

func (*AtomicTxnId) Set

func (i *AtomicTxnId) Set(id TxnId)

Set atomically sets n as new value.

func (*AtomicTxnId) SetIfBiggerUnsafe

func (i *AtomicTxnId) SetIfBiggerUnsafe(id TxnId)

type AtomicTxnState

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

func NewAtomicTxnState

func NewAtomicTxnState(state TxnState) AtomicTxnState

func (*AtomicTxnState) GetTxnState

func (s *AtomicTxnState) GetTxnState() TxnState

func (*AtomicTxnState) IsAborted

func (s *AtomicTxnState) IsAborted() bool

func (*AtomicTxnState) IsCommitted

func (s *AtomicTxnState) IsCommitted() bool

func (*AtomicTxnState) IsStaging

func (s *AtomicTxnState) IsStaging() bool

func (*AtomicTxnState) IsTerminated

func (s *AtomicTxnState) IsTerminated() bool

func (*AtomicTxnState) SetRollbacking

func (s *AtomicTxnState) SetRollbacking() (abortOnce bool)

func (*AtomicTxnState) SetTxnState

func (s *AtomicTxnState) SetTxnState(state TxnState) (newState TxnState, terminateOnce bool)

func (*AtomicTxnState) SetTxnStateUnsafe

func (s *AtomicTxnState) SetTxnStateUnsafe(state TxnState) (newState TxnState, terminateOnce bool)

func (*AtomicTxnState) String

func (s *AtomicTxnState) String() string

type DBMeta

type DBMeta struct {
	Flag            uint8              `json:"F"`
	InternalVersion TxnInternalVersion `json:"I"`
}

func (DBMeta) IsCommitted

func (m DBMeta) IsCommitted() bool

func (DBMeta) IsDirty

func (m DBMeta) IsDirty() bool

func (DBMeta) WithVersion

func (m DBMeta) WithVersion(version uint64) Meta

type DBType

type DBType string

type DBValue

type DBValue struct {
	DBMeta

	V []byte `json:"V"`
}

func (*DBValue) Decode

func (v *DBValue) Decode(data []byte) error

func (DBValue) Encode

func (v DBValue) Encode() []byte

func (DBValue) WithCommitted

func (v DBValue) WithCommitted() DBValue

func (DBValue) WithVersion

func (v DBValue) WithVersion(version uint64) Value

type KV

type KV interface {
	Get(ctx context.Context, key string, opt KVReadOption) (Value, error)
	Set(ctx context.Context, key string, val Value, opt KVWriteOption) error
	UpdateMeta(ctx context.Context, key string, version uint64, opt KVUpdateMetaOption) error
	RollbackKey(ctx context.Context, key string, version uint64) error
	RemoveTxnRecord(ctx context.Context, version uint64) error
	Close() error
}

type KVCC

type KVCC interface {
	Get(ctx context.Context, key string, opt KVCCReadOption) (ValueCC, error)
	Set(ctx context.Context, key string, val Value, opt KVCCWriteOption) error
	UpdateMeta(ctx context.Context, key string, version uint64, opt KVCCUpdateMetaOption) error
	RollbackKey(ctx context.Context, key string, version uint64, opt KVCCRollbackKeyOption) error
	RemoveTxnRecord(ctx context.Context, version uint64, opt KVCCRemoveTxnRecordOption) error
	Close() error
}

type KVCCOperationOption

type KVCCOperationOption struct {
	Flag uint8
}

func (*KVCCOperationOption) CondSetOperatedByDifferentTxn

func (opt *KVCCOperationOption) CondSetOperatedByDifferentTxn(b bool)

func (*KVCCOperationOption) CondSetReadModifyWrite

func (opt *KVCCOperationOption) CondSetReadModifyWrite(b bool)

func (*KVCCOperationOption) CondSetReadOnlyKey

func (opt *KVCCOperationOption) CondSetReadOnlyKey(b bool)

func (KVCCOperationOption) GetFlagAsUint32

func (opt KVCCOperationOption) GetFlagAsUint32() uint32

func (KVCCOperationOption) IsOperatedByDifferentTxn

func (opt KVCCOperationOption) IsOperatedByDifferentTxn() bool

func (KVCCOperationOption) IsReadModifyWrite

func (opt KVCCOperationOption) IsReadModifyWrite() bool

func (KVCCOperationOption) IsReadOnlyKey

func (opt KVCCOperationOption) IsReadOnlyKey() bool

type KVCCReadOption

type KVCCReadOption struct {
	ReaderVersion uint64

	ExactVersion              uint64
	MinAllowedSnapshotVersion uint64
	// contains filtered or unexported fields
}

func NewKVCCReadOption

func NewKVCCReadOption(readerVersion uint64) KVCCReadOption

func NewKVCCReadOptionFromPB

func NewKVCCReadOptionFromPB(x *kvccpb.KVCCReadOption) KVCCReadOption

func NewSnapshotKVCCReadOption

func NewSnapshotKVCCReadOption(snapshotVersion uint64, minAllowedSnapshotVersion uint64) KVCCReadOption

func (KVCCReadOption) CondReadModifyWrite

func (opt KVCCReadOption) CondReadModifyWrite(b bool) KVCCReadOption

func (KVCCReadOption) CondReadModifyWriteFirstReadOfKey

func (opt KVCCReadOption) CondReadModifyWriteFirstReadOfKey(b bool) KVCCReadOption

func (KVCCReadOption) CondWaitWhenReadDirty

func (opt KVCCReadOption) CondWaitWhenReadDirty(b bool) KVCCReadOption

func (KVCCReadOption) GetKVReadVersion

func (opt KVCCReadOption) GetKVReadVersion() uint64

func (KVCCReadOption) IsGetMaxReadVersion

func (opt KVCCReadOption) IsGetMaxReadVersion() bool

func (KVCCReadOption) IsMetaOnly

func (opt KVCCReadOption) IsMetaOnly() bool

func (KVCCReadOption) IsReadExactVersion

func (opt KVCCReadOption) IsReadExactVersion() bool

func (KVCCReadOption) IsReadModifyWrite

func (opt KVCCReadOption) IsReadModifyWrite() bool

func (KVCCReadOption) IsReadModifyWriteFirstReadOfKey

func (opt KVCCReadOption) IsReadModifyWriteFirstReadOfKey() bool

func (KVCCReadOption) IsSnapshotRead

func (opt KVCCReadOption) IsSnapshotRead() bool

func (KVCCReadOption) IsTxnRecord

func (opt KVCCReadOption) IsTxnRecord() bool

func (KVCCReadOption) IsUpdateTimestampCache

func (opt KVCCReadOption) IsUpdateTimestampCache() bool

func (KVCCReadOption) IsWaitWhenReadDirty

func (opt KVCCReadOption) IsWaitWhenReadDirty() bool

func (KVCCReadOption) ToKVReadOption

func (opt KVCCReadOption) ToKVReadOption() (kvOpt KVReadOption)

func (KVCCReadOption) ToPB

func (opt KVCCReadOption) ToPB() *kvccpb.KVCCReadOption

func (KVCCReadOption) WithExactVersion

func (opt KVCCReadOption) WithExactVersion(exactVersion uint64) KVCCReadOption

func (KVCCReadOption) WithIncrReaderVersion

func (opt KVCCReadOption) WithIncrReaderVersion() KVCCReadOption

func (KVCCReadOption) WithKVReadVersion

func (opt KVCCReadOption) WithKVReadVersion(kvReadVersion uint64) (kvOpt KVReadOption)

func (KVCCReadOption) WithMetaOnly

func (opt KVCCReadOption) WithMetaOnly() KVCCReadOption

func (KVCCReadOption) WithNotGetMaxReadVersion

func (opt KVCCReadOption) WithNotGetMaxReadVersion() KVCCReadOption

func (KVCCReadOption) WithNotUpdateTimestampCache

func (opt KVCCReadOption) WithNotUpdateTimestampCache() KVCCReadOption

func (KVCCReadOption) WithTxnRecord

func (opt KVCCReadOption) WithTxnRecord() KVCCReadOption

type KVCCRemoveTxnRecordOption

type KVCCRemoveTxnRecordOption struct {
	KVCCOperationOption
}

func (KVCCRemoveTxnRecordOption) CondRemoveByDifferentTransaction

func (opt KVCCRemoveTxnRecordOption) CondRemoveByDifferentTransaction(b bool) KVCCRemoveTxnRecordOption

func (KVCCRemoveTxnRecordOption) CondRollback

func (KVCCRemoveTxnRecordOption) IsRollback

func (opt KVCCRemoveTxnRecordOption) IsRollback() bool

func (KVCCRemoveTxnRecordOption) ToPB

type KVCCRollbackKeyOption

type KVCCRollbackKeyOption struct {
	KVCCOperationOption
}

func NewKVCCCRollbackKeyOptionFromPB

func NewKVCCCRollbackKeyOptionFromPB(opt *kvccpb.KVCCRollbackKeyOption) KVCCRollbackKeyOption

func (KVCCRollbackKeyOption) CondReadModifyWrite

func (opt KVCCRollbackKeyOption) CondReadModifyWrite(b bool) KVCCRollbackKeyOption

func (KVCCRollbackKeyOption) CondReadOnlyKey

func (opt KVCCRollbackKeyOption) CondReadOnlyKey(b bool) KVCCRollbackKeyOption

func (KVCCRollbackKeyOption) CondRollbackByDifferentTxn

func (opt KVCCRollbackKeyOption) CondRollbackByDifferentTxn(b bool) KVCCRollbackKeyOption

func (KVCCRollbackKeyOption) ToPB

type KVCCUpdateMetaOption

type KVCCUpdateMetaOption struct {
	KVCCOperationOption
}

func NewKVCCCUpdateMetaOptionFromPB

func NewKVCCCUpdateMetaOptionFromPB(opt *kvccpb.KVCCUpdateMetaOption) KVCCUpdateMetaOption

func (KVCCUpdateMetaOption) CondReadModifyWrite

func (opt KVCCUpdateMetaOption) CondReadModifyWrite(b bool) KVCCUpdateMetaOption

func (KVCCUpdateMetaOption) CondReadOnlyKey

func (opt KVCCUpdateMetaOption) CondReadOnlyKey(b bool) KVCCUpdateMetaOption

func (KVCCUpdateMetaOption) CondUpdateByDifferentTxn

func (opt KVCCUpdateMetaOption) CondUpdateByDifferentTxn(b bool) KVCCUpdateMetaOption

func (KVCCUpdateMetaOption) IsClearWriteIntent

func (opt KVCCUpdateMetaOption) IsClearWriteIntent() bool

func (KVCCUpdateMetaOption) ToKV

func (KVCCUpdateMetaOption) ToPB

type KVCCWriteOption

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

func NewKVCCWriteOption

func NewKVCCWriteOption() KVCCWriteOption

func NewKVCCWriteOptionFromPB

func NewKVCCWriteOptionFromPB(x *kvccpb.KVCCWriteOption) KVCCWriteOption

func (KVCCWriteOption) CondReadModifyWrite

func (opt KVCCWriteOption) CondReadModifyWrite(b bool) KVCCWriteOption

func (KVCCWriteOption) IsReadModifyWrite

func (opt KVCCWriteOption) IsReadModifyWrite() bool

func (KVCCWriteOption) IsTxnRecord

func (opt KVCCWriteOption) IsTxnRecord() bool

func (KVCCWriteOption) ToKVWriteOption

func (opt KVCCWriteOption) ToKVWriteOption() KVWriteOption

func (*KVCCWriteOption) ToPB

func (opt *KVCCWriteOption) ToPB() *kvccpb.KVCCWriteOption

func (KVCCWriteOption) WithTxnRecord

func (opt KVCCWriteOption) WithTxnRecord() KVCCWriteOption

type KVReadOption

type KVReadOption struct {
	Version uint64
	Flag    uint8
}

func NewKVReadOption

func NewKVReadOption(Version uint64) KVReadOption

func NewKVReadOptionFromPB

func NewKVReadOptionFromPB(x *kvpb.KVReadOption) KVReadOption

func (KVReadOption) IsMetaOnly

func (opt KVReadOption) IsMetaOnly() bool

func (KVReadOption) IsReadExactVersion

func (opt KVReadOption) IsReadExactVersion() bool

func (KVReadOption) IsTxnRecord

func (opt KVReadOption) IsTxnRecord() bool

func (KVReadOption) ToPB

func (opt KVReadOption) ToPB() *kvpb.KVReadOption

func (KVReadOption) WithExactVersion

func (opt KVReadOption) WithExactVersion() KVReadOption

func (KVReadOption) WithTxnRecord

func (opt KVReadOption) WithTxnRecord() KVReadOption

type KVUpdateMetaOption

type KVUpdateMetaOption uint8

func NewKVUpdateMetaOptionFromPB

func NewKVUpdateMetaOptionFromPB(opt *kvpb.KVUpdateMetaOption) KVUpdateMetaOption

func (KVUpdateMetaOption) IsClearWriteIntent

func (opt KVUpdateMetaOption) IsClearWriteIntent() bool

func (KVUpdateMetaOption) ToPB

type KVWriteOption

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

func NewKVWriteOption

func NewKVWriteOption() KVWriteOption

func NewKVWriteOptionFromPB

func NewKVWriteOptionFromPB(x *kvpb.KVWriteOption) KVWriteOption

func (KVWriteOption) IsTxnRecord

func (opt KVWriteOption) IsTxnRecord() bool

func (*KVWriteOption) ToPB

func (opt *KVWriteOption) ToPB() *kvpb.KVWriteOption

func (KVWriteOption) WithTxnRecord

func (opt KVWriteOption) WithTxnRecord() KVWriteOption

type ListTask

type ListTask struct {
	basic.Task
	// contains filtered or unexported fields
}

func NewListTaskNoResult

func NewListTaskNoResult(id basic.TaskId, name string, runTimeout time.Duration,
	g func(ctx context.Context, prevResult interface{}) error) *ListTask

func NewListTaskWithResult

func NewListTaskWithResult(id basic.TaskId, name string, runTimeout time.Duration,
	g func(ctx context.Context, prevResult interface{}) (interface{}, error)) *ListTask

func (*ListTask) Initialize

func (t *ListTask) Initialize(id basic.TaskId, name string, runTimeout time.Duration,
	g func(ctx context.Context, prevResult interface{}) (interface{}, error)) *ListTask

func (*ListTask) Next

func (t *ListTask) Next() *ListTask

func (*ListTask) Prev

func (t *ListTask) Prev() *ListTask

func (*ListTask) SetNext

func (t *ListTask) SetNext(next *ListTask)

func (*ListTask) SetPrev

func (t *ListTask) SetPrev(prev *ListTask)

type Meta

type Meta struct {
	Version         uint64
	InternalVersion TxnInternalVersion
	Flag            uint8
}

func NewMetaFromPB

func NewMetaFromPB(x *commonpb.ValueMeta) Meta

func (Meta) IsAborted

func (m Meta) IsAborted() bool

func (Meta) IsCommitted

func (m Meta) IsCommitted() bool

func (Meta) IsDirty

func (m Meta) IsDirty() bool

func (Meta) IsEmpty

func (m Meta) IsEmpty() bool

func (Meta) IsFirstWriteOfKey

func (m Meta) IsFirstWriteOfKey() bool

func (Meta) IsWriteOfKey

func (m Meta) IsWriteOfKey() bool

func (*Meta) SetAborted

func (m *Meta) SetAborted()

func (*Meta) SetCommitted

func (m *Meta) SetCommitted()

func (Meta) ToDB

func (m Meta) ToDB() DBMeta

func (Meta) ToPB

func (m Meta) ToPB() *commonpb.ValueMeta

type ReadModifyWriteQueueCfg

type ReadModifyWriteQueueCfg struct {
	CapacityPerKey  int
	MaxReadersRatio float64
	MaxQueuedAge    time.Duration
}

func NewReadModifyWriteQueueCfg

func NewReadModifyWriteQueueCfg(
	capacityPerKey int,
	maxReadersRatio float64,
	maxQueuedAge time.Duration) ReadModifyWriteQueueCfg

func (ReadModifyWriteQueueCfg) WithMaxQueuedAge

func (cfg ReadModifyWriteQueueCfg) WithMaxQueuedAge(maxQueuedAge time.Duration) ReadModifyWriteQueueCfg

type ReadResultCC

type ReadResultCC map[string]ValueCC

func (ReadResultCC) Contains

func (r ReadResultCC) Contains(key string) bool

func (ReadResultCC) MustFirst

func (r ReadResultCC) MustFirst() string

func (ReadResultCC) ToTValues

func (r ReadResultCC) ToTValues(keys []string, newSnapshotVersion uint64) []TValue

type RecordValuesTxn

type RecordValuesTxn struct {
	Txn
	// contains filtered or unexported fields
}

func NewRecordValuesTxn

func NewRecordValuesTxn(txn Txn) *RecordValuesTxn

func (*RecordValuesTxn) Get

func (txn *RecordValuesTxn) Get(ctx context.Context, key string) (TValue, error)

func (*RecordValuesTxn) GetReadValues

func (txn *RecordValuesTxn) GetReadValues() map[string]TValue

func (*RecordValuesTxn) GetWriteValues

func (txn *RecordValuesTxn) GetWriteValues() map[string]Value

func (*RecordValuesTxn) HasWritten

func (txn *RecordValuesTxn) HasWritten(key string) bool

func (*RecordValuesTxn) MGet

func (txn *RecordValuesTxn) MGet(ctx context.Context, keys []string) ([]TValue, error)

func (*RecordValuesTxn) MSet

func (txn *RecordValuesTxn) MSet(ctx context.Context, keys []string, values [][]byte) error

func (*RecordValuesTxn) Set

func (txn *RecordValuesTxn) Set(ctx context.Context, key string, val []byte) error

type RetryDetailItem

type RetryDetailItem struct {
	errors.ErrorKey
	Count int
}

func (RetryDetailItem) String

func (i RetryDetailItem) String() string

type RetryDetailItems

type RetryDetailItems []RetryDetailItem

func (RetryDetailItems) Len

func (r RetryDetailItems) Len() int

func (RetryDetailItems) Less

func (r RetryDetailItems) Less(i, j int) bool

func (RetryDetailItems) Swap

func (r RetryDetailItems) Swap(i, j int)

type RetryDetails

type RetryDetails map[errors.ErrorKey]int

func (RetryDetails) Collect

func (d RetryDetails) Collect(another RetryDetails)

func (RetryDetails) GetSortedRetryDetails

func (d RetryDetails) GetSortedRetryDetails() (items RetryDetailItems)

func (RetryDetails) String

func (d RetryDetails) String() string

type T

type T interface {
	Errorf(format string, args ...interface{})
	Logf(format string, args ...interface{})
	Name() string
}

type TValue

type TValue struct {
	Value
	SnapshotVersion uint64
}

func NewTValue

func NewTValue(value Value, snapshotVersion uint64) TValue

func NewTValueFromPB

func NewTValueFromPB(x *txnpb.TValue) TValue

func NewTValuesFromPB

func NewTValuesFromPB(pbValues []*txnpb.TValue) []TValue

func (TValue) CondPreventedFutureWrite

func (v TValue) CondPreventedFutureWrite(b bool) TValue

func (TValue) IsEmpty

func (v TValue) IsEmpty() bool

func (TValue) IsFutureWritePrevented

func (v TValue) IsFutureWritePrevented() bool

func (TValue) ToPB

func (v TValue) ToPB() *txnpb.TValue

type TValues

type TValues []TValue

func (TValues) ToPB

func (vs TValues) ToPB() []*txnpb.TValue

type TabletTxnConfig

type TabletTxnConfig struct {
	StaleWriteThreshold time.Duration
	MaxClockDrift       time.Duration
}

func NewTabletTxnConfig

func NewTabletTxnConfig(staleWriteThreshold time.Duration) TabletTxnConfig

func (TabletTxnConfig) GetWaitTimestampCacheInvalidTimeout

func (cfg TabletTxnConfig) GetWaitTimestampCacheInvalidTimeout() time.Duration

func (TabletTxnConfig) String

func (cfg TabletTxnConfig) String() string

func (TabletTxnConfig) SupportReadModifyWriteTxn

func (cfg TabletTxnConfig) SupportReadModifyWriteTxn() bool

func (TabletTxnConfig) Validate

func (cfg TabletTxnConfig) Validate() error

func (TabletTxnConfig) WithMaxClockDrift

func (cfg TabletTxnConfig) WithMaxClockDrift(val time.Duration) TabletTxnConfig

func (TabletTxnConfig) WithStaleWriteThreshold

func (cfg TabletTxnConfig) WithStaleWriteThreshold(val time.Duration) TabletTxnConfig

type TabletTxnConfigMarshaller

type TabletTxnConfigMarshaller struct {
	StaleWriteThreshold string
	MaxClockDrift       string
}

type TabletTxnManagerConfig

type TabletTxnManagerConfig struct {
	TabletTxnConfig
	ReadModifyWriteQueueCfg

	// outputs
	TxnLifeSpan time.Duration
}

func NewTabletTxnManagerConfig

func NewTabletTxnManagerConfig(
	tabletCfg TabletTxnConfig,
	readModifyWriteQueueCfg ReadModifyWriteQueueCfg) TabletTxnManagerConfig

func (TabletTxnManagerConfig) Sanitize

type TreeTask

type TreeTask struct {
	basic.Task
	// contains filtered or unexported fields
}

func NewTreeTaskNoResult

func NewTreeTaskNoResult(
	id basic.TaskId, name string, runTimeout time.Duration,
	parent *TreeTask,
	g func(ctx context.Context, childrenResult []interface{}) error) *TreeTask

func NewTreeTaskWithResult

func NewTreeTaskWithResult(
	id basic.TaskId, name string, runTimeout time.Duration,
	parent *TreeTask,
	g func(ctx context.Context, childrenResult []interface{}) (interface{}, error)) *TreeTask

func (*TreeTask) AllChildrenSuccess

func (t *TreeTask) AllChildrenSuccess() bool

func (*TreeTask) Children

func (t *TreeTask) Children() []*TreeTask

func (*TreeTask) ChildrenSuccess

func (t *TreeTask) ChildrenSuccess(children []*TreeTask) bool

func (*TreeTask) Initialize

func (t *TreeTask) Initialize(id basic.TaskId, name string, runTimeout time.Duration,
	parent *TreeTask,
	g func(ctx context.Context, childrenResult []interface{}) (interface{}, error)) *TreeTask

type Txn

type Txn interface {
	GetId() TxnId
	GetState() TxnState
	GetType() TxnType
	GetSnapshotReadOption() TxnSnapshotReadOption // only used when txn type is snapshot
	Get(ctx context.Context, key string) (TValue, error)
	MGet(ctx context.Context, keys []string) (values []TValue, err error)
	Set(ctx context.Context, key string, val []byte) error // async func, doesn't guarantee see set result after call
	MSet(ctx context.Context, keys []string, values [][]byte) error
	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error

	GetReadValues() map[string]TValue
	GetWriteValues() map[string]Value
}

type TxnId

type TxnId uint64

func (TxnId) After

func (i TxnId) After(duration time.Duration) time.Time

func (TxnId) Age

func (i TxnId) Age() time.Duration

func (TxnId) Max

func (i TxnId) Max(another TxnId) TxnId

func (TxnId) String

func (i TxnId) String() string

func (TxnId) Time

func (i TxnId) Time() time.Time

func (TxnId) Version

func (i TxnId) Version() uint64

type TxnInternalVersion

type TxnInternalVersion uint8
const (
	TxnInternalVersionMin             TxnInternalVersion = consts.MinTxnInternalVersion
	TxnInternalVersionMax             TxnInternalVersion = consts.MaxTxnInternalVersion
	TxnInternalVersionPositiveInvalid TxnInternalVersion = consts.PositiveInvalidTxnInternalVersion
)

func (TxnInternalVersion) IsValid

func (v TxnInternalVersion) IsValid() bool

type TxnKeyUnion

type TxnKeyUnion struct {
	Key   string
	TxnId TxnId
}

func (TxnKeyUnion) Hash

func (tk TxnKeyUnion) Hash() uint64

func (TxnKeyUnion) String

func (tk TxnKeyUnion) String() string

type TxnKind

type TxnKind uint8
const (
	TxnKindReadOnly  TxnKind = 1 << iota
	TxnKindReadWrite         // include read for write, read after write, write k1, read k2, etc.
	TxnKindWriteOnly
)

func (TxnKind) String

func (k TxnKind) String() string

type TxnManager

type TxnManager interface {
	BeginTransaction(ctx context.Context, opt TxnOption) (Txn, error)
	Close() error
}

type TxnManagerConfig

type TxnManagerConfig struct {
	WoundUncommittedTxnThreshold     time.Duration
	ClearerNum, WriterNum, ReaderNum int
	ClearTimeout                     time.Duration
	MaxTaskBufferedPerPartition      int
	SnapshotBackwardPeriod           time.Duration
}

func NewTxnManagerConfig

func NewTxnManagerConfig(woundUncommittedTxnThreshold time.Duration) TxnManagerConfig

func (TxnManagerConfig) Validate

func (cfg TxnManagerConfig) Validate() error

func (TxnManagerConfig) WithClearerNum

func (cfg TxnManagerConfig) WithClearerNum(clearerNum int) TxnManagerConfig

func (TxnManagerConfig) WithMaxTaskBufferedPerPartition

func (cfg TxnManagerConfig) WithMaxTaskBufferedPerPartition(maxTaskBufferedPerPartition int) TxnManagerConfig

func (TxnManagerConfig) WithReaderNum

func (cfg TxnManagerConfig) WithReaderNum(readerNum int) TxnManagerConfig

func (TxnManagerConfig) WithWoundUncommittedTxnThreshold

func (cfg TxnManagerConfig) WithWoundUncommittedTxnThreshold(woundUncommittedTxnThreshold time.Duration) TxnManagerConfig

func (TxnManagerConfig) WithWriterNum

func (cfg TxnManagerConfig) WithWriterNum(writerNum int) TxnManagerConfig

type TxnOption

type TxnOption struct {
	TxnType

	SnapshotReadOption TxnSnapshotReadOption // only valid if TxnType is SnapshotRead
}

func NewDefaultTxnOption

func NewDefaultTxnOption() TxnOption

func NewTxnOption

func NewTxnOption(typ TxnType) TxnOption

func NewTxnOptionFromPB

func NewTxnOptionFromPB(option *txnpb.TxnOption) TxnOption

func (TxnOption) CondSnapshotReadDontAllowVersionBack

func (opt TxnOption) CondSnapshotReadDontAllowVersionBack(b bool) TxnOption

func (TxnOption) ToPB

func (opt TxnOption) ToPB() *txnpb.TxnOption

func (TxnOption) WithRelativeSnapshotVersion

func (opt TxnOption) WithRelativeSnapshotVersion(snapshotVersionDiff uint64) TxnOption

func (TxnOption) WithSnapshotReadDontAllowVersionBack

func (opt TxnOption) WithSnapshotReadDontAllowVersionBack() TxnOption

func (TxnOption) WithSnapshotReadMinAllowedSnapshotVersion

func (opt TxnOption) WithSnapshotReadMinAllowedSnapshotVersion(minAllowedSnapshotVersion uint64) TxnOption

func (TxnOption) WithSnapshotReadRelativeMinAllowedSnapshotVersion

func (opt TxnOption) WithSnapshotReadRelativeMinAllowedSnapshotVersion(relativeMinAllowedSnapshotVersionDiff uint64) TxnOption

func (TxnOption) WithSnapshotVersion

func (opt TxnOption) WithSnapshotVersion(snapshotVersion uint64) TxnOption

type TxnSnapshotReadOption

type TxnSnapshotReadOption struct {
	SnapshotVersion           uint64
	MinAllowedSnapshotVersion uint64
	// contains filtered or unexported fields
}

func NewTxnSnapshotReadOptionFromPB

func NewTxnSnapshotReadOptionFromPB(opt *txnpb.TxnSnapshotReadOption) TxnSnapshotReadOption

func (TxnSnapshotReadOption) AllowsVersionBack

func (opt TxnSnapshotReadOption) AllowsVersionBack() bool

func (TxnSnapshotReadOption) Equals

func (opt TxnSnapshotReadOption) Equals(another TxnSnapshotReadOption) bool

func (TxnSnapshotReadOption) IsEmpty

func (opt TxnSnapshotReadOption) IsEmpty() bool

func (TxnSnapshotReadOption) IsExplicitSnapshotVersion

func (opt TxnSnapshotReadOption) IsExplicitSnapshotVersion() bool

func (TxnSnapshotReadOption) IsRelativeMinAllowedSnapshotVersion

func (opt TxnSnapshotReadOption) IsRelativeMinAllowedSnapshotVersion() bool

func (TxnSnapshotReadOption) IsRelativeSnapshotVersion

func (opt TxnSnapshotReadOption) IsRelativeSnapshotVersion() bool

func (*TxnSnapshotReadOption) SetSnapshotVersion

func (opt *TxnSnapshotReadOption) SetSnapshotVersion(snapshotVersion uint64, checkMinAllowedSnapshotVersion bool)

func (TxnSnapshotReadOption) String

func (opt TxnSnapshotReadOption) String() string

func (TxnSnapshotReadOption) ToPB

func (TxnSnapshotReadOption) WithClearDontAllowsVersionBack

func (opt TxnSnapshotReadOption) WithClearDontAllowsVersionBack() TxnSnapshotReadOption

type TxnState

type TxnState uint8
const (
	TxnStateInvalid     TxnState = 0
	TxnStateUncommitted TxnState = 1
	TxnStateStaging     TxnState = 2
	TxnStateCommitted   TxnState = 3
	TxnStateRollbacking TxnState = 4
	TxnStateRollbacked  TxnState = 5
)

func (TxnState) AsInt32

func (s TxnState) AsInt32() int32

func (TxnState) IsAborted

func (s TxnState) IsAborted() bool

func (TxnState) IsCommitted

func (s TxnState) IsCommitted() bool

func (TxnState) IsStaging

func (s TxnState) IsStaging() bool

func (TxnState) IsTerminated

func (s TxnState) IsTerminated() bool

func (TxnState) String

func (s TxnState) String() string

func (TxnState) ToPB

func (s TxnState) ToPB() txnpb.TxnState

type TxnType

type TxnType uint8

func ParseTxnType

func ParseTxnType(str string) (typ TxnType, _ error)

func (TxnType) CondWaitWhenReadDirty

func (t TxnType) CondWaitWhenReadDirty(b bool) TxnType

func (TxnType) IsReadModifyWrite

func (t TxnType) IsReadModifyWrite() bool

func (TxnType) IsSnapshotRead

func (t TxnType) IsSnapshotRead() bool

func (TxnType) IsWaitWhenReadDirty

func (t TxnType) IsWaitWhenReadDirty() bool

func (TxnType) String

func (t TxnType) String() string

func (TxnType) ToUint32

func (t TxnType) ToUint32() uint32

type Value

type Value struct {
	Meta

	V []byte
}

func NewIntValue

func NewIntValue(i int) Value

func NewValue

func NewValue(val []byte, version uint64) Value

NewValue create a value with write intent

func NewValueFromPB

func NewValueFromPB(x *commonpb.Value) Value

func (Value) Int

func (v Value) Int() (int, error)

func (Value) IsEmpty

func (v Value) IsEmpty() bool

func (Value) MustInt

func (v Value) MustInt() int

func (Value) String

func (v Value) String() string

func (Value) ToDB

func (v Value) ToDB() DBValue

func (Value) ToPB

func (v Value) ToPB() *commonpb.Value

func (Value) WithCommitted

func (v Value) WithCommitted() Value

func (Value) WithInternalVersion

func (v Value) WithInternalVersion(version TxnInternalVersion) Value

func (Value) WithMaxReadVersion

func (v Value) WithMaxReadVersion(maxReadVersion uint64) ValueCC

func (Value) WithSnapshotVersion

func (v Value) WithSnapshotVersion(snapshotVersion uint64) ValueCC

func (Value) WithVersion

func (v Value) WithVersion(version uint64) Value

type ValueCC

type ValueCC struct {
	Value

	MaxReadVersion  uint64
	SnapshotVersion uint64
}

func NewValueCCFromPB

func NewValueCCFromPB(x *commonpb.ValueCC) ValueCC

func (ValueCC) IsEmpty

func (v ValueCC) IsEmpty() bool

func (ValueCC) ToPB

func (v ValueCC) ToPB() *commonpb.ValueCC

func (ValueCC) ToTValue

func (v ValueCC) ToTValue() TValue

func (ValueCC) WithCommitted

func (v ValueCC) WithCommitted() ValueCC

func (ValueCC) WithMaxReadVersion

func (v ValueCC) WithMaxReadVersion(maxReadVersion uint64) ValueCC

Hide Value::WithMaxReadVersion

func (ValueCC) WithSnapshotVersion

func (v ValueCC) WithSnapshotVersion(_ uint64) ValueCC

Hide Value::WithMaxReadVersion

type ValueCCs

type ValueCCs []ValueCC

func (ValueCCs) ToValues

func (vs ValueCCs) ToValues() []Value

type Writer

type Writer struct {
	Version    uint64
	OnUnlocked func()

	Next *Writer
	// contains filtered or unexported fields
}

Deprecated

func NewWriter

func NewWriter(version uint64) *Writer

Deprecated

func (*Writer) IsClean

func (w *Writer) IsClean() bool

func (*Writer) IsRollbacked

func (w *Writer) IsRollbacked() bool

func (*Writer) IsWriting

func (w *Writer) IsWriting() bool

func (*Writer) Lock

func (w *Writer) Lock()

func (*Writer) MarkClean

func (w *Writer) MarkClean()

func (*Writer) MarkRollbacked

func (w *Writer) MarkRollbacked()

func (*Writer) Unlock

func (w *Writer) Unlock()

func (*Writer) WaitFinish

func (w *Writer) WaitFinish()

type WriterHeap

type WriterHeap Writers

func (*WriterHeap) Initialize

func (h *WriterHeap) Initialize()

func (WriterHeap) Min

func (h WriterHeap) Min() *Writer

func (*WriterHeap) MustContain

func (h *WriterHeap) MustContain(writers ...*Writer)

func (*WriterHeap) Push

func (h *WriterHeap) Push(x *Writer)

func (*WriterHeap) Remove

func (h *WriterHeap) Remove(writer *Writer)

type Writers

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

func (*Writers) Initialize

func (ws *Writers) Initialize()

func (Writers) Len

func (ws Writers) Len() int

func (Writers) Less

func (ws Writers) Less(i, j int) bool

func (*Writers) Pop

func (ws *Writers) Pop() interface{}

func (*Writers) Push

func (ws *Writers) Push(x interface{})

func (Writers) Swap

func (ws Writers) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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