Documentation ¶
Index ¶
- Variables
- type CancelFunc
- type Manager
- func (mgr *Manager) Collect(metrics chan<- prometheus.Metric)
- func (mgr *Manager) Describe(descs chan<- *prometheus.Desc)
- func (mgr *Manager) RegisterTransaction(ctx context.Context, voters []Voter, threshold uint) (Transaction, CancelFunc, error)
- func (mgr *Manager) StopTransaction(ctx context.Context, transactionID uint64) error
- func (mgr *Manager) VoteTransaction(ctx context.Context, transactionID uint64, node string, vote voting.Vote) error
- type Transaction
- type VoteResult
- type Voter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDuplicateNodes indicates a transaction was registered with two // voters having the same name. ErrDuplicateNodes = errors.New("transactions cannot have duplicate nodes") // ErrMissingNodes indicates a transaction was registered with no voters. ErrMissingNodes = errors.New("transaction requires at least one node") // ErrInvalidThreshold indicates a transaction was registered with an // invalid threshold that may either allow for multiple different // quorums or none at all. ErrInvalidThreshold = errors.New("transaction has invalid threshold") // ErrTransactionFailed indicates the transaction didn't reach quorum. ErrTransactionFailed = errors.New("transaction did not reach quorum") // ErrTransactionCanceled indicates the transaction was canceled before // reaching quorum. ErrTransactionCanceled = errors.New("transaction has been canceled") // ErrTransactionStopped indicates the transaction was gracefully stopped. ErrTransactionStopped = errors.New("transaction has been stopped") )
var ErrNotFound = errors.New("transaction not found")
nolint: stylecheck // This is unintentionally missing documentation.
Functions ¶
This section is empty.
Types ¶
type CancelFunc ¶
type CancelFunc func() error
CancelFunc is the transaction cancellation function returned by `RegisterTransaction`. Calling it will cause the transaction to be removed from the transaction manager.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles reference transactions for Praefect. It is required in order for Praefect to handle transactions directly instead of having to reach out to reference transaction RPCs.
func NewManager ¶
NewManager creates a new transactions Manager.
func (*Manager) Collect ¶
func (mgr *Manager) Collect(metrics chan<- prometheus.Metric)
nolint: stylecheck // This is unintentionally missing documentation.
func (*Manager) Describe ¶
func (mgr *Manager) Describe(descs chan<- *prometheus.Desc)
nolint: stylecheck // This is unintentionally missing documentation.
func (*Manager) RegisterTransaction ¶
func (mgr *Manager) RegisterTransaction(ctx context.Context, voters []Voter, threshold uint) (Transaction, CancelFunc, error)
RegisterTransaction registers a new reference transaction for a set of nodes taking part in the transaction. `threshold` is the threshold at which an election will succeed. It needs to be in the range `weight(voters)/2 < threshold <= weight(voters) to avoid indecidable votes.
func (*Manager) StopTransaction ¶
StopTransaction will gracefully stop a transaction.
type Transaction ¶
type Transaction interface { // ID returns the ID of the transaction which uniquely identifies the transaction. ID() uint64 // CountSubtransactions counts the number of subtransactions. CountSubtransactions() int // State returns the state of each voter part of the transaction. State() (map[string]VoteResult, error) // DidVote returns whether the given node has cast a vote. DidVote(string) bool }
Transaction is an interface for transactions.
type VoteResult ¶
type VoteResult int
VoteResult represents the outcome of a transaction for a single voter.
const ( // VoteUndecided means that the voter either didn't yet show up or that // the vote couldn't yet be decided due to there being no majority yet. VoteUndecided VoteResult = iota // VoteCommitted means that the voter committed his vote. VoteCommitted // VoteFailed means that the voter has failed the vote because a // majority of nodes has elected a different result. VoteFailed // VoteCanceled means that the transaction was cancelled. VoteCanceled // VoteStopped means that the transaction was gracefully stopped. VoteStopped )
type Voter ¶
type Voter struct { // Name of the voter, usually Gitaly's storage name. Name string // Votes is the number of votes available to this voter in the voting // process. `0` means the outcome of the vote will not be influenced by // this voter. Votes uint // contains filtered or unexported fields }
Voter is a participant in a given transaction that may cast a vote.