oracles

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 2

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) GetExternalTimestamp added in v2.0.2

func (o *MockOracle) GetExternalTimestamp(ctx context.Context) (uint64, error)

GetExternalTimestamp implement oracle.Oracle interface.

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) SetExternalTimestamp added in v2.0.2

func (o *MockOracle) SetExternalTimestamp(ctx context.Context, newTimestamp uint64) error

SetExternalTimestamp implement 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