oracles

package
v2.0.0-...-7ffc49f Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLocalOracle

func NewLocalOracle() oracle.Oracle

NewLocalOracle creates an Oracle that uses local time as data source.

func NewPdOracle

func NewPdOracle(pdClient pd.Client, updateInterval time.Duration) (oracle.Oracle, error)

NewPdOracle create an Oracle that uses a pd client source. Refer https://github.com/tikv/pd/blob/master/client/client.go for more details. PdOracle mantains `lastTS` to store the last timestamp got from PD server. If `GetTimestamp()` is not called after `updateInterval`, it will be called by itself to keep up with the timestamp on PD server.

Types

type MockOracle

type MockOracle struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MockOracle is a mock oracle for test.

func (*MockOracle) AddOffset

func (o *MockOracle) AddOffset(d time.Duration)

AddOffset adds the offset of the oracle.

func (*MockOracle) Close

func (o *MockOracle) Close()

Close implements oracle.Oracle interface.

func (*MockOracle) Disable

func (o *MockOracle) Disable()

Disable disables the Oracle

func (*MockOracle) Enable

func (o *MockOracle) Enable()

Enable enables the Oracle

func (*MockOracle) GetLowResolutionTimestamp

func (o *MockOracle) GetLowResolutionTimestamp(ctx context.Context, opt *oracle.Option) (uint64, error)

GetLowResolutionTimestamp implements oracle.Oracle interface.

func (*MockOracle) GetLowResolutionTimestampAsync

func (o *MockOracle) GetLowResolutionTimestampAsync(ctx context.Context, opt *oracle.Option) oracle.Future

GetLowResolutionTimestampAsync implements oracle.Oracle interface.

func (*MockOracle) GetStaleTimestamp

func (o *MockOracle) GetStaleTimestamp(ctx context.Context, txnScope string, prevSecond uint64) (ts uint64, err error)

GetStaleTimestamp implements oracle.Oracle interface.

func (*MockOracle) GetTimestamp

func (o *MockOracle) GetTimestamp(ctx context.Context, _ *oracle.Option) (uint64, error)

GetTimestamp implements oracle.Oracle interface.

func (*MockOracle) GetTimestampAsync

func (o *MockOracle) GetTimestampAsync(ctx context.Context, _ *oracle.Option) oracle.Future

GetTimestampAsync implements oracle.Oracle interface.

func (*MockOracle) IsExpired

func (o *MockOracle) IsExpired(lockTimestamp, TTL uint64, _ *oracle.Option) bool

IsExpired implements oracle.Oracle interface.

func (*MockOracle) UntilExpired

func (o *MockOracle) UntilExpired(lockTimeStamp, TTL uint64, _ *oracle.Option) int64

UntilExpired implement oracle.Oracle interface.

Jump to

Keyboard shortcuts

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