oracle

package
v2.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 2 Imported by: 209

Documentation

Index

Constants

View Source
const (

	// GlobalTxnScope is the default transaction scope for a Oracle service.
	GlobalTxnScope = "global"
)

Variables

This section is empty.

Functions

func ComposeTS

func ComposeTS(physical, logical int64) uint64

ComposeTS creates a ts from physical and logical parts.

func ExtractLogical

func ExtractLogical(ts uint64) int64

ExtractLogical return a ts's logical part.

func ExtractPhysical

func ExtractPhysical(ts uint64) int64

ExtractPhysical returns a ts's physical part.

func GetPhysical

func GetPhysical(t time.Time) int64

GetPhysical returns physical from an instant time with millisecond precision.

func GetTimeFromTS

func GetTimeFromTS(ts uint64) time.Time

GetTimeFromTS extracts time.Time from a timestamp.

func GoTimeToLowerLimitStartTS

func GoTimeToLowerLimitStartTS(now time.Time, maxTxnTimeUse int64) uint64

GoTimeToLowerLimitStartTS returns the min start_ts of the uncommitted transaction. maxTxnTimeUse means the max time a Txn May use (in ms) from its begin to commit.

func GoTimeToTS

func GoTimeToTS(t time.Time) uint64

GoTimeToTS converts a Go time to uint64 timestamp.

Types

type Future

type Future interface {
	Wait() (uint64, error)
}

Future is a future which promises to return a timestamp.

type Option

type Option struct {
	TxnScope string
}

Option represents available options for the oracle.Oracle.

type Oracle

type Oracle interface {
	GetTimestamp(ctx context.Context, opt *Option) (uint64, error)
	GetTimestampAsync(ctx context.Context, opt *Option) Future
	GetLowResolutionTimestamp(ctx context.Context, opt *Option) (uint64, error)
	GetLowResolutionTimestampAsync(ctx context.Context, opt *Option) Future
	GetStaleTimestamp(ctx context.Context, txnScope string, prevSecond uint64) (uint64, error)
	IsExpired(lockTimestamp, TTL uint64, opt *Option) bool
	UntilExpired(lockTimeStamp, TTL uint64, opt *Option) int64
	Close()

	GetExternalTimestamp(ctx context.Context) (uint64, error)
	SetExternalTimestamp(ctx context.Context, ts uint64) error
}

Oracle is the interface that provides strictly ascending timestamps.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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