Documentation ¶
Index ¶
- Constants
- type TimestampOracle
- func (t *TimestampOracle) GetRespTS(count uint32) (schedulerpb.Timestamp, error)
- func (t *TimestampOracle) ResetTimestamp()
- func (t *TimestampOracle) ResetUserTimestamp(tso uint64) error
- func (t *TimestampOracle) SyncTimestamp(lease *member.LeaderLease) error
- func (t *TimestampOracle) UpdateTimestamp() error
Constants ¶
View Source
const ( // UpdateTimestampStep is used to update timestamp. UpdateTimestampStep = 50 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimestampOracle ¶
type TimestampOracle struct {
// contains filtered or unexported fields
}
TimestampOracle is used to maintain the logic of tso.
func NewTimestampOracle ¶
func NewTimestampOracle(client *clientv3.Client, rootPath string, member string, saveInterval time.Duration, maxResetTsGap func() time.Duration) *TimestampOracle
NewTimestampOracle creates a new TimestampOracle. TODO: remove saveInterval
func (*TimestampOracle) GetRespTS ¶
func (t *TimestampOracle) GetRespTS(count uint32) (schedulerpb.Timestamp, error)
GetRespTS is used to get a timestamp.
func (*TimestampOracle) ResetTimestamp ¶
func (t *TimestampOracle) ResetTimestamp()
ResetTimestamp is used to reset the timestamp.
func (*TimestampOracle) ResetUserTimestamp ¶
func (t *TimestampOracle) ResetUserTimestamp(tso uint64) error
ResetUserTimestamp update the physical part with specified tso.
func (*TimestampOracle) SyncTimestamp ¶
func (t *TimestampOracle) SyncTimestamp(lease *member.LeaderLease) error
SyncTimestamp is used to synchronize the timestamp.
func (*TimestampOracle) UpdateTimestamp ¶
func (t *TimestampOracle) UpdateTimestamp() error
UpdateTimestamp is used to update the timestamp. This function will do two things:
- When the logical time is going to be used up, the current physical time needs to increase.
- If the time window is not enough, which means the saved etcd time minus the next physical time is less than or equal to `updateTimestampGuard`, it will need to be updated and save the next physical time plus `TsoSaveInterval` into etcd.
Here is some constraints that this function must satisfy: 1. The physical time is monotonically increasing. 2. The saved time is monotonically increasing. 3. The physical time is always less than the saved timestamp.
Click to show internal directories.
Click to hide internal directories.