xa

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TMEndRScan ends a recovery scan.
	TMEndRScan = 0x00800000
	// TMFail disassociates the caller and marks the transaction branch
	// rollback-only.
	TMFail = 0x20000000

	// TMJoin joining existing transaction branch.
	TMJoin = 0x00200000

	// TMNoFlags indicate no flags value is selected.
	TMNoFlags = 0x00000000

	// TMOnePhase using one-phase optimization.
	TMOnePhase = 0x40000000

	// TMResume is resuming association with a suspended transaction branch.
	TMResume = 0x08000000

	// TMStartRScan starts a recovery scan.
	TMStartRScan = 0x01000000

	// TMSuccess disassociates caller from a transaction branch.
	TMSuccess = 0x04000000

	// TMSuspend is suspending (not ending) its association with a transaction branch.
	TMSuspend = 0x02000000

	// XAReadOnly the transaction branch has been read-only and has been committed.
	XAReadOnly = 0x00000003

	// XAOk The transaction work has been prepared normally.
	XAOk = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MysqlXAConn

type MysqlXAConn struct {
	driver.Conn
}

func NewMysqlXaConn

func NewMysqlXaConn(conn driver.Conn) *MysqlXAConn

func (*MysqlXAConn) Commit

func (c *MysqlXAConn) Commit(ctx context.Context, xid string, onePhase bool) error

func (*MysqlXAConn) End

func (c *MysqlXAConn) End(ctx context.Context, xid string, flags int) error

func (*MysqlXAConn) Forget

func (c *MysqlXAConn) Forget(ctx context.Context, xid string) error

func (*MysqlXAConn) GetTransactionTimeout

func (c *MysqlXAConn) GetTransactionTimeout() time.Duration

func (*MysqlXAConn) IsSameRM

func (c *MysqlXAConn) IsSameRM(ctx context.Context, xares XAResource) bool

IsSameRM is called to determine if the resource manager instance represented by the target object is the same as the resource manager instance represented by the parameter xares.

func (*MysqlXAConn) Recover

func (c *MysqlXAConn) Recover(ctx context.Context, flag int) (xids []string, err error)

Recover Obtains a list of prepared transaction branches from a resource manager. The transaction manager calls this method during recovery to obtain the list of transaction branches that are currently in prepared or heuristically completed states.

func (*MysqlXAConn) Rollback

func (c *MysqlXAConn) Rollback(ctx context.Context, xid string) error

func (*MysqlXAConn) SetTransactionTimeout

func (c *MysqlXAConn) SetTransactionTimeout(duration time.Duration) bool

func (*MysqlXAConn) Start

func (c *MysqlXAConn) Start(ctx context.Context, xid string, flags int) error

func (*MysqlXAConn) XAPrepare

func (c *MysqlXAConn) XAPrepare(ctx context.Context, xid string) error

type OracleXAConn

type OracleXAConn struct {
	driver.Conn
}

func (*OracleXAConn) Commit

func (c *OracleXAConn) Commit(xid string, onePhase bool) error

func (*OracleXAConn) End

func (c *OracleXAConn) End(xid string, flags int) error

func (*OracleXAConn) Forget

func (c *OracleXAConn) Forget(xid string) error

func (*OracleXAConn) GetTransactionTimeout

func (c *OracleXAConn) GetTransactionTimeout() time.Duration

func (*OracleXAConn) IsSameRM

func (c *OracleXAConn) IsSameRM(resource XAResource) bool

func (*OracleXAConn) Recover

func (c *OracleXAConn) Recover(flag int) []string

func (*OracleXAConn) Rollback

func (c *OracleXAConn) Rollback(xid string) error

func (*OracleXAConn) SetTransactionTimeout

func (c *OracleXAConn) SetTransactionTimeout(duration time.Duration) bool

func (*OracleXAConn) Start

func (c *OracleXAConn) Start(xid string, flags int) error

func (*OracleXAConn) XAPrepare

func (c *OracleXAConn) XAPrepare(xid string) (int, error)

type XAResource

type XAResource interface {
	Commit(ctx context.Context, xid string, onePhase bool) error
	End(ctx context.Context, xid string, flags int) error
	Forget(ctx context.Context, xid string) error
	GetTransactionTimeout() time.Duration
	IsSameRM(ctx context.Context, resource XAResource) bool
	XAPrepare(ctx context.Context, xid string) error
	Recover(ctx context.Context, flag int) ([]string, error)
	Rollback(ctx context.Context, xid string) error
	SetTransactionTimeout(duration time.Duration) bool
	Start(ctx context.Context, xid string, flags int) error
}

func CreateXAResource

func CreateXAResource(conn driver.Conn, dbType types.DBType) (XAResource, error)

CreateXAResource create a connection for xa with the different db type. Such as mysql, oracle, MARIADB, POSTGRESQL

Jump to

Keyboard shortcuts

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