coordinator

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAutomatic = fmt.Errorf("transaction phase2 has been processed automatically")
)

Functions

This section is empty.

Types

type Coordinator

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

func NewCoordinator

func NewCoordinator(dao dao.TransactionDao, executor Executor, notify notify.Notify, automaticExecution2 bool) *Coordinator

func (*Coordinator) Begin

func (c *Coordinator) Begin(ctx context.Context) (string, error)

func (*Coordinator) Close

func (c *Coordinator) Close(ctx context.Context) error

func (*Coordinator) Commit

func (c *Coordinator) Commit(ctx context.Context, global *entity.Global) error

func (*Coordinator) GetBranchList

func (c *Coordinator) GetBranchList(ctx context.Context, gid string) (list []*entity.Branch, err error)

func (*Coordinator) GetGlobal

func (c *Coordinator) GetGlobal(ctx context.Context, gid string) (entity.Global, error)

func (*Coordinator) Phase1

func (c *Coordinator) Phase1(ctx context.Context, global *entity.Global) (err error)

func (*Coordinator) Phase2

func (c *Coordinator) Phase2(ctx context.Context, global *entity.Global) (err error)

func (*Coordinator) Register

func (c *Coordinator) Register(ctx context.Context, branches entity.BranchList) error

func (*Coordinator) Rollback

func (c *Coordinator) Rollback(ctx context.Context, global *entity.Global) error

func (*Coordinator) Start

func (c *Coordinator) Start(ctx context.Context, global *entity.Global) error

func (*Coordinator) UpdateGlobalState

func (c *Coordinator) UpdateGlobalState(ctx context.Context, gid string,
	state consts.GlobalState) error

type Executor

type Executor interface {
	Phase1(ctx context.Context, global *entity.Global) error
	Phase2(ctx context.Context, global *entity.Global) error
	// Close when the server stop
	Close(ctx context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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