tcommit

package
v0.0.0-...-97b9ebb Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package tcommit provides API interfaces and base primitives for transacrion commit protocol. Base types are `Manager` which specify interface for transaction manager (TM) and `Resource` for resource manager (RM). This API assumes that RM votes on the transaction that can be either prepared or aborted. RM also may know votes of other RMs but it's not required.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// Begin a transaction, update votes for RMs.
	// RM starts a transaction when it's prepared. RM doesn't
	// know if the transaction was started already, so it always
	// assume it's not started yet and calls begin-transaction of
	// TM. RM includes all known votes about the transaction
	// into this message, so TM has to merge all votes
	// and manage the transaction state correctly. If TM sees that
	// It receives a quorum of `prepared` votes for each RM,
	// it can decide to commit; or if it receives a quorum
	// of `abort` at least for one RM, it can decide to abort.
	Begin(context.Context, Votes, Meta) error

	// Finish a transaction. RM notifies about finished transaction.
	// TM counts finished RM to send synchronous response to the client
	// when all RMs are finished. TM already know the state of the transaction,
	// so it needs only a notification hint from RMs without state parameters.
	Finish(context.Context, NodeID, Meta) error
}

Manager of the transaction (TM).

type Meta

type Meta string

Meta is an optional additional transaction metadata that could be sent by RM and used by TM.

type NodeID

type NodeID string

NodeID unique identifier of the RM

type Resource

type Resource interface {
	// Commit the transaction
	Commit(context.Context) error

	// Abort the transaction
	Abort(context.Context) error
}

Resource manager API

type TxID

type TxID string

TxID is unique identifier of the transacion

type Vote

type Vote uint8

Vote of RM

const (
	// VoteUnkown means that RM was not decided yet
	VoteUnkown Vote = iota
	// VotePrepared means that RM was prepared to commit
	VotePrepared
	// VoteAborted means that RM failed to prepare
	VoteAborted
)

func (Vote) String

func (i Vote) String() string

type Votes

type Votes map[NodeID]Vote

Votes is a map of votes by node

Directories

Path Synopsis
Package grpc implements transaction protocols using gRPC
Package grpc implements transaction protocols using gRPC
pb

Jump to

Keyboard shortcuts

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