transaction

package
v0.0.0-...-9334841 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Pending = fsm.State("pending") // Initial state right after creation.
	Writing = fsm.State("writing") // After the frames hook has been executed.
	Written = fsm.State("written") // After a final frames hook has been executed.
	Undone  = fsm.State("undone")  // After the undo hook has been executed.
	Doomed  = fsm.State("doomed")  // The transaction has errored.
)

Possible transaction states. Most states are associated with SQLite replication hooks that are invoked upon transitioning from one lifecycle state to the next.

Variables

This section is empty.

Functions

This section is empty.

Types

type Txn

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

Txn captures information about an active WAL write transaction that has been started on a SQLite connection configured to be in either leader or replication mode.

func New

func New(conn *sqlite3.SQLiteConn, id uint64, isLeader bool, dryRun bool) *Txn

New creates a new Txn instance.

func (*Txn) Conn

func (t *Txn) Conn() *sqlite3.SQLiteConn

Conn returns the sqlite connection that started this write transaction.

func (*Txn) DryRun

func (t *Txn) DryRun(v bool)

DryRun makes this transaction only transition between states, without actually invoking the relevant SQLite APIs. This should only be used by tests.

func (*Txn) Frames

func (t *Txn) Frames(begin bool, frames *sqlite3.ReplicationFramesParams) error

Frames writes frames to the WAL.

func (*Txn) ID

func (t *Txn) ID() uint64

ID returns the ID associated with this transaction.

func (*Txn) IsLeader

func (t *Txn) IsLeader() bool

IsLeader returns true if the underlying connection is in leader replication mode.

func (*Txn) IsZombie

func (t *Txn) IsZombie() bool

IsZombie returns true if this is a zombie transaction.

func (*Txn) Resurrect

func (t *Txn) Resurrect(state fsm.State)

Resurrect a zombie transaction, to be re-used after a leader that lost leadership was re-elected right away.

func (*Txn) State

func (t *Txn) State() fsm.State

State returns the current state of the transition.

func (*Txn) String

func (t *Txn) String() string

func (*Txn) Undo

func (t *Txn) Undo() error

Undo reverts all changes to the WAL since the start of the transaction.

func (*Txn) Zombie

func (t *Txn) Zombie(state fsm.State)

Zombie marks this transaction as zombie. It must be called only for leader transactions.

A zombie transaction is one whose leader has lost leadership while applying the associated FSM command. The transaction is left in state passed as argument.

Jump to

Keyboard shortcuts

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