Documentation ¶
Overview ¶
Package twopc provides a implementation of Two-Phase Commit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator is a 2PC coordinator.
func NewCoordinator ¶
func NewCoordinator(opt *Options) *Coordinator
NewCoordinator creates a new 2PC Coordinator.
func (*Coordinator) Put ¶
func (c *Coordinator) Put(workers []Worker, wb WriteBatch) (result interface{}, err error)
Put initiates a 2PC process to apply given WriteBatch on all workers.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options represents options of a 2PC coordinator.
func NewOptions ¶
NewOptions returns a new coordinator option.
type Worker ¶
type Worker interface { Prepare(ctx context.Context, wb WriteBatch) error Commit(ctx context.Context, wb WriteBatch) (interface{}, error) Rollback(ctx context.Context, wb WriteBatch) error }
Worker represents a 2PC worker who implements Prepare, Commit, and Rollback.
type WriteBatch ¶
type WriteBatch interface{}
WriteBatch is an empty interface which will be passed to Worker methods.
Click to show internal directories.
Click to hide internal directories.