Documentation ¶
Index ¶
- Variables
- func CommitLockedFile(ctx context.Context, m Manager, writer *safe.LockingFileWriter) (returnedErr error)
- func RunOnContext(ctx context.Context, fn func(txinfo.Transaction) error) error
- func VoteOnContext(ctx context.Context, m Manager, vote voting.Vote, phase voting.Phase) error
- type Manager
- type MockManager
- type PhasedVote
- type PoolManager
- func (m *PoolManager) Collect(metrics chan<- prometheus.Metric)
- func (m *PoolManager) Describe(descs chan<- *prometheus.Desc)
- func (m *PoolManager) Stop(ctx context.Context, tx txinfo.Transaction) error
- func (m *PoolManager) Vote(ctx context.Context, tx txinfo.Transaction, vote voting.Vote, ...) error
- type TrackingManager
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTransactionAborted indicates a transaction was aborted, either // because it timed out or because the vote failed to reach quorum. ErrTransactionAborted = errors.New("transaction was aborted") // ErrTransactionStopped indicates a transaction was gracefully // stopped. This only happens in case the transaction was terminated // because of an external condition, e.g. access checks or hooks // rejected a change. ErrTransactionStopped = errors.New("transaction was stopped") )
Functions ¶
func CommitLockedFile ¶
func CommitLockedFile(ctx context.Context, m Manager, writer *safe.LockingFileWriter) (returnedErr error)
CommitLockedFile will lock, vote and commit the LockingFileWriter in a race-free manner.
func RunOnContext ¶
RunOnContext runs the given function if the context identifies a transaction.
Types ¶
type Manager ¶
type Manager interface { // Vote casts a vote on the given transaction which is hosted by the // given Praefect server. Vote(context.Context, txinfo.Transaction, voting.Vote, voting.Phase) error // Stop gracefully stops the given transaction which is hosted by the // given Praefect server. Stop(context.Context, txinfo.Transaction) error }
Manager is an interface for handling voting on transactions.
type MockManager ¶
type MockManager struct { VoteFn func(context.Context, txinfo.Transaction, voting.Vote, voting.Phase) error StopFn func(context.Context, txinfo.Transaction) error }
MockManager is a mock Manager for use in tests.
func (*MockManager) Stop ¶
func (m *MockManager) Stop(ctx context.Context, tx txinfo.Transaction) error
Stop calls the MockManager's Stop function, if set. Otherwise, it returns an error.
type PhasedVote ¶
PhasedVote is used to keep track of votes and the phase they were cast in.
type PoolManager ¶
type PoolManager struct {
// contains filtered or unexported fields
}
PoolManager is an implementation of the Manager interface using a pool to connect to the transaction hosts.
func NewManager ¶
func NewManager(cfg config.Cfg, logger log.Logger, backchannels *backchannel.Registry) *PoolManager
NewManager creates a new PoolManager to handle transactional voting.
func (*PoolManager) Collect ¶
func (m *PoolManager) Collect(metrics chan<- prometheus.Metric)
Collect is used to collect Prometheus metrics.
func (*PoolManager) Describe ¶
func (m *PoolManager) Describe(descs chan<- *prometheus.Desc)
Describe is used to describe Prometheus metrics.
func (*PoolManager) Stop ¶
func (m *PoolManager) Stop(ctx context.Context, tx txinfo.Transaction) error
Stop connects to the given server and stops the transaction identified by tx.
type TrackingManager ¶
type TrackingManager struct { MockManager // contains filtered or unexported fields }
TrackingManager is a transaction manager which tracks all votes. Voting functions never return an error.
func NewTrackingManager ¶
func NewTrackingManager() *TrackingManager
NewTrackingManager creates a new TrackingManager which is ready for use.
func (*TrackingManager) Reset ¶
func (m *TrackingManager) Reset()
Reset resets all votes which have been recorded up to this point.
func (*TrackingManager) Votes ¶
func (m *TrackingManager) Votes() []PhasedVote
Votes returns a copy of all votes which have been cast.