Version: v0.0.0-...-6719cd2 Latest Latest

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 13 Imported by: 0



Package txtimer watches for slow transactions and aborts them.



This section is empty.


This section is empty.


This section is empty.


type GetReplayPosition

type GetReplayPosition func(context.Context) (rpc.LogPosition, error)

GetReplayPosition returns the earliest position (log index and version) that might have a pending transaction. This is where reading the log will begin. It continues retrying until it succeeds; the only error it returns is a context error.

type Options

type Options struct {
	// The minimum time after seeing a start transaction command before appending a
	// corresponding abort decision. The zero value defaults to 3s.
	AbortTxAfter time.Duration

Options define optional arguments to New. The zero value of Options is usable.

type TxTimer

type TxTimer struct {
	// contains filtered or unexported fields

TxTimer watches for slow transactions and aborts them. A TxTimer must be constructed with New.

func New

func New(
	backgroundCtx context.Context,
	aLog blog.AkutanLog,
	getReplayPosition GetReplayPosition,
	options Options,
) *TxTimer

New constructs a new TxTimer. The TxTimer will not do anything until Run is called. The given context is for the background activity of the TxTimer, not just for the call to New. The TxTimer will read from and append to aLog.

func (*TxTimer) LastApplied

func (txTimer *TxTimer) LastApplied() blog.Index

LastApplied returns the last applied log index. This method is thread safe.

func (*TxTimer) PendingTxs

func (txTimer *TxTimer) PendingTxs() int

PendingTxs returns the number of pending transactions. This method is thread safe.

func (*TxTimer) Run

func (txTimer *TxTimer) Run()

Run is a blocking call that watches for slow transactions and aborts them. Run returns once the context given to New is canceled or the AkutanLog given to New is closed. Run may only be called once per TxTimer.

Jump to

Keyboard shortcuts

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