tso

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

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) (pdpb.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:

  1. When the logical time is going to be used up, the current physical time needs to increase.
  2. 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.

Jump to

Keyboard shortcuts

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