Documentation ¶
Index ¶
- func NewLocalOracle() oracle.Oracle
- func NewPdOracle(pdClient pd.Client, updateInterval time.Duration) (oracle.Oracle, error)
- type MockOracle
- func (o *MockOracle) AddOffset(d time.Duration)
- func (o *MockOracle) Close()
- func (o *MockOracle) Disable()
- func (o *MockOracle) Enable()
- func (o *MockOracle) GetExternalTimestamp(ctx context.Context) (uint64, error)
- func (o *MockOracle) GetLowResolutionTimestamp(ctx context.Context, opt *oracle.Option) (uint64, error)
- func (o *MockOracle) GetLowResolutionTimestampAsync(ctx context.Context, opt *oracle.Option) oracle.Future
- func (o *MockOracle) GetStaleTimestamp(ctx context.Context, txnScope string, prevSecond uint64) (ts uint64, err error)
- func (o *MockOracle) GetTimestamp(ctx context.Context, _ *oracle.Option) (uint64, error)
- func (o *MockOracle) GetTimestampAsync(ctx context.Context, _ *oracle.Option) oracle.Future
- func (o *MockOracle) IsExpired(lockTimestamp, TTL uint64, _ *oracle.Option) bool
- func (o *MockOracle) SetExternalTimestamp(ctx context.Context, newTimestamp uint64) error
- func (o *MockOracle) UntilExpired(lockTimeStamp, TTL uint64, _ *oracle.Option) int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLocalOracle ¶
NewLocalOracle creates an Oracle that uses local time as data source.
func NewPdOracle ¶
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 ¶
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) GetExternalTimestamp ¶
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 ¶
GetTimestamp implements oracle.Oracle interface.
func (*MockOracle) GetTimestampAsync ¶
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 ¶
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.