tso

package
v0.0.0-...-3cfd66f Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequestFastFail

func NewRequestFastFail(err error) *tsoRequestFastFail

NewRequestFastFail creates a new fast fail TSO request.

Types

type Cli

type Cli struct {
	// contains filtered or unexported fields
}

Cli is the implementation of the TSO client.

func NewClient

func NewClient(
	ctx context.Context, option *opt.Option,
	svcDiscovery sd.ServiceDiscovery, factory tsoStreamBuilderFactory,
) *Cli

NewClient returns a new TSO client.

func (*Cli) Close

func (c *Cli) Close()

Close closes the TSO client

func (*Cli) DispatchRequest

func (c *Cli) DispatchRequest(request *Request) (bool, error)

DispatchRequest will send the TSO request to the corresponding TSO dispatcher.

func (*Cli) GetRequestPool

func (c *Cli) GetRequestPool() *sync.Pool

GetRequestPool gets the request pool of the TSO client.

func (*Cli) GetTSORequest

func (c *Cli) GetTSORequest(ctx context.Context) *Request

GetTSORequest gets a TSO request from the pool.

func (*Cli) Setup

func (c *Cli) Setup()

Setup initializes the TSO client.

type Client

type Client interface {
	// GetTS gets a timestamp from PD or TSO microservice.
	GetTS(ctx context.Context) (int64, int64, error)
	// GetTSAsync gets a timestamp from PD or TSO microservice, without block the caller.
	GetTSAsync(ctx context.Context) TSFuture
	// GetMinTS gets a timestamp from PD or the minimal timestamp across all keyspace groups from
	// the TSO microservice.
	GetMinTS(ctx context.Context) (int64, int64, error)

	// GetLocalTS gets a local timestamp from PD or TSO microservice.
	//
	// Deprecated: Local TSO will be completely removed in the future. Currently, regardless of the
	// parameters passed in, this method will default to returning the global TSO.
	GetLocalTS(ctx context.Context, _ string) (int64, int64, error)
	// GetLocalTSAsync gets a local timestamp from PD or TSO microservice, without block the caller.
	//
	// Deprecated: Local TSO will be completely removed in the future. Currently, regardless of the
	// parameters passed in, this method will default to returning the global TSO.
	GetLocalTSAsync(ctx context.Context, _ string) TSFuture
}

Client defines the interface of a TSO client.

type MSStreamBuilderFactory

type MSStreamBuilderFactory struct{}

MSStreamBuilderFactory is a factory for building TSO streams to the microservice cluster.

type PDStreamBuilderFactory

type PDStreamBuilderFactory struct{}

PDStreamBuilderFactory is a factory for building TSO streams to the PD cluster.

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request is a TSO request.

func (*Request) IsFrom

func (req *Request) IsFrom(pool *sync.Pool) bool

IsFrom checks if the request is from the specified pool.

func (*Request) TryDone

func (req *Request) TryDone(err error)

TryDone tries to send the result to the channel, it will not block.

func (*Request) Wait

func (req *Request) Wait() (physical int64, logical int64, err error)

Wait will block until the TSO result is ready.

type TSFuture

type TSFuture interface {
	// Wait gets the physical and logical time, it would block caller if data is not available yet.
	Wait() (int64, int64, error)
}

TSFuture is a future which promises to return a TSO.

Jump to

Keyboard shortcuts

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