Documentation ¶
Index ¶
- Constants
- func CleanTxHooks()
- func Init()
- func InitAT(cfg undo.Config, asyncCfg AsyncWorkerConfig)
- func RegisterTxHook(h txHook)
- type ATConn
- func (c *ATConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (c *ATConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *ATConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (c *ATConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- type ATSourceManager
- func (a *ATSourceManager) BranchCommit(ctx context.Context, resource rm.BranchResource) (branch.BranchStatus, error)
- func (a *ATSourceManager) BranchRegister(ctx context.Context, req rm.BranchRegisterParam) (int64, error)
- func (a *ATSourceManager) BranchReport(ctx context.Context, param rm.BranchReportParam) error
- func (a *ATSourceManager) BranchRollback(ctx context.Context, branchResource rm.BranchResource) (branch.BranchStatus, error)
- func (a *ATSourceManager) CreateTableMetaCache(ctx context.Context, resID string, dbType types.DBType, db *sql.DB) (datasource.TableMetaCache, error)
- func (a *ATSourceManager) GetBranchType() branch.BranchType
- func (a *ATSourceManager) GetCachedResources() *sync.Map
- func (a *ATSourceManager) LockQuery(ctx context.Context, param rm.LockQueryParam) (bool, error)
- func (a *ATSourceManager) RegisterResource(res rm.Resource) error
- func (a *ATSourceManager) UnregisterResource(res rm.Resource) error
- type ATTx
- type AsyncWorker
- type AsyncWorkerConfig
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)deprecated
- func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (c *Conn) Close() error
- func (c *Conn) Exec(query string, args []driver.Value) (driver.Result, error)
- func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *Conn) GetAutoCommit() bool
- func (c *Conn) Prepare(query string) (driver.Stmt, error)
- func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (c *Conn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- func (c *Conn) ResetSession(ctx context.Context) error
- type DBResource
- func (db *DBResource) ConnectionForXA(ctx context.Context, xaXid XAXid) (*XAConn, error)
- func (db *DBResource) GetBranchType() branch.BranchType
- func (db *DBResource) GetDB() *sql.DB
- func (db *DBResource) GetDBName() string
- func (db *DBResource) GetDbType() types.DBType
- func (db *DBResource) GetDbVersion() string
- func (db *DBResource) GetKeeper() *sync.Map
- func (db *DBResource) GetResourceGroupId() string
- func (db *DBResource) GetResourceId() string
- func (db *DBResource) Hold(xaBranchID string, v interface{}) error
- func (db *DBResource) IsShouldBeHeld() bool
- func (db *DBResource) Lookup(xaBranchID string) (interface{}, bool)
- func (db *DBResource) Release(xaBranchID string)
- func (db *DBResource) SetDbType(dbType types.DBType)
- func (db *DBResource) SetDbVersion(v string)
- type Option
- type Stmt
- func (s *Stmt) Close() error
- func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)deprecated
- func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (s *Stmt) NumInput() int
- func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)deprecated
- func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- type Tx
- type XABranchXid
- type XAConfig
- type XAConn
- func (c *XAConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (c *XAConn) Close() error
- func (c *XAConn) CloseForce() error
- func (c *XAConn) Commit(ctx context.Context) error
- func (c *XAConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *XAConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (c *XAConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- func (c *XAConn) Rollback(ctx context.Context) error
- func (c *XAConn) ShouldBeHeld() bool
- func (c *XAConn) XaCommit(ctx context.Context, xaXid XAXid) error
- func (c *XAConn) XaRollback(ctx context.Context, xaXid XAXid) error
- func (c *XAConn) XaRollbackByBranchId(ctx context.Context, xaXid XAXid) error
- type XAConnConf
- type XAResourceManager
- func (xaManager *XAResourceManager) BranchCommit(ctx context.Context, branchResource rm.BranchResource) (branch.BranchStatus, error)
- func (xaManager *XAResourceManager) BranchRegister(ctx context.Context, req rm.BranchRegisterParam) (int64, error)
- func (xaManager *XAResourceManager) BranchReport(ctx context.Context, param rm.BranchReportParam) error
- func (xaManager *XAResourceManager) BranchRollback(ctx context.Context, branchResource rm.BranchResource) (branch.BranchStatus, error)
- func (xaManager *XAResourceManager) CreateTableMetaCache(ctx context.Context, resID string, dbType types.DBType, db *sql.DB) (datasource.TableMetaCache, error)
- func (xaManager *XAResourceManager) GetBranchType() branch.BranchType
- func (xaManager *XAResourceManager) GetCachedResources() *sync.Map
- func (xaManager *XAResourceManager) LockQuery(ctx context.Context, param rm.LockQueryParam) (bool, error)
- func (xaManager *XAResourceManager) RegisterResource(res rm.Resource) error
- func (xaManager *XAResourceManager) UnregisterResource(resource rm.Resource) error
- type XATx
- type XAXid
Constants ¶
const ( // SeataATMySQLDriver MySQL driver for AT mode SeataATMySQLDriver = "seata-at-mysql" // SeataXAMySQLDriver MySQL driver for XA mode SeataXAMySQLDriver = "seata-xa-mysql" )
Variables ¶
This section is empty.
Functions ¶
func CleanTxHooks ¶
func CleanTxHooks()
func InitAT ¶
func InitAT(cfg undo.Config, asyncCfg AsyncWorkerConfig)
func RegisterTxHook ¶
func RegisterTxHook(h txHook)
Types ¶
type ATConn ¶
type ATConn struct {
*Conn
}
ATConn Database connection proxy object under XA transaction model Conn is assumed to be stateful.
func (*ATConn) ExecContext ¶
func (c *ATConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
ExecContext
func (*ATConn) PrepareContext ¶
type ATSourceManager ¶
type ATSourceManager struct {
// contains filtered or unexported fields
}
func (*ATSourceManager) BranchCommit ¶
func (a *ATSourceManager) BranchCommit(ctx context.Context, resource rm.BranchResource) (branch.BranchStatus, error)
BranchCommit commit the branch transaction
func (*ATSourceManager) BranchRegister ¶
func (a *ATSourceManager) BranchRegister(ctx context.Context, req rm.BranchRegisterParam) (int64, error)
BranchRegister branch transaction register
func (*ATSourceManager) BranchReport ¶
func (a *ATSourceManager) BranchReport(ctx context.Context, param rm.BranchReportParam) error
BranchReport Report status of transaction branch
func (*ATSourceManager) BranchRollback ¶
func (a *ATSourceManager) BranchRollback(ctx context.Context, branchResource rm.BranchResource) (branch.BranchStatus, error)
BranchRollback rollback a branch transaction
func (*ATSourceManager) CreateTableMetaCache ¶
func (a *ATSourceManager) CreateTableMetaCache(ctx context.Context, resID string, dbType types.DBType, db *sql.DB) (datasource.TableMetaCache, error)
func (*ATSourceManager) GetBranchType ¶
func (a *ATSourceManager) GetBranchType() branch.BranchType
func (*ATSourceManager) GetCachedResources ¶
func (a *ATSourceManager) GetCachedResources() *sync.Map
GetCachedResources get all resources managed by this manager
func (*ATSourceManager) LockQuery ¶
func (a *ATSourceManager) LockQuery(ctx context.Context, param rm.LockQueryParam) (bool, error)
func (*ATSourceManager) RegisterResource ¶
func (a *ATSourceManager) RegisterResource(res rm.Resource) error
RegisterResource register a Resource to be managed by Resource Manager
func (*ATSourceManager) UnregisterResource ¶
func (a *ATSourceManager) UnregisterResource(res rm.Resource) error
UnregisterResource unregister a Resource from the Resource Manager
type ATTx ¶
type ATTx struct {
// contains filtered or unexported fields
}
ATTx
type AsyncWorker ¶
type AsyncWorker struct {
// contains filtered or unexported fields
}
AsyncWorker executor for branch transaction commit and undo log
func NewAsyncWorker ¶
func NewAsyncWorker(prom prometheus.Registerer, conf AsyncWorkerConfig, sourceManager datasource.DataSourceManager) *AsyncWorker
func (*AsyncWorker) BranchCommit ¶
func (aw *AsyncWorker) BranchCommit(ctx context.Context, req rm.BranchResource) (branch.BranchStatus, error)
BranchCommit commit branch transaction
type AsyncWorkerConfig ¶
type AsyncWorkerConfig struct { BufferLimit int `yaml:"buffer_limit" json:"buffer_limit"` BufferCleanInterval time.Duration `yaml:"buffer_clean_interval" json:"buffer_clean_interval"` ReceiveChanSize int `yaml:"receive_chan_size" json:"receive_chan_size"` CommitWorkerCount int `yaml:"commit_worker_count" json:"commit_worker_count"` CommitWorkerBufferSize int `yaml:"commit_worker_buffer_size" json:"commit_worker_buffer_size"` }
func (*AsyncWorkerConfig) RegisterFlagsWithPrefix ¶
func (cfg *AsyncWorkerConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a connection to a database. It is not used concurrently by multiple goroutines.
Conn is assumed to be stateful.
func (*Conn) BeginTx ¶
BeginTx Open a transaction and judge whether the current transaction needs to open a
global transaction according to tranCtx. If so, it needs to be included in the transaction management of seata
func (*Conn) Close ¶
Close invalidates and potentially stops any current prepared statements and transactions, marking this connection as no longer in use.
Because the sql package maintains a free pool of connections and only calls Close when there's a surplus of idle connections, it shouldn't be necessary for drivers to do their own connection caching.
Drivers must ensure all network calls made by Close do not block indefinitely (e.g. apply a timeout).
func (*Conn) Exec ¶
Exec warning: if you want to use global transaction, please use ExecContext function
func (*Conn) ExecContext ¶
func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
ExecContext
func (*Conn) GetAutoCommit ¶
func (*Conn) PrepareContext ¶
PrepareContext
type DBResource ¶
type DBResource struct {
// contains filtered or unexported fields
}
DBResource proxy sql.DB, enchance database/sql.DB to add distribute transaction ability
func (*DBResource) ConnectionForXA ¶
func (*DBResource) GetBranchType ¶
func (db *DBResource) GetBranchType() branch.BranchType
func (*DBResource) GetDB ¶
func (db *DBResource) GetDB() *sql.DB
func (*DBResource) GetDBName ¶
func (db *DBResource) GetDBName() string
func (*DBResource) GetDbType ¶
func (db *DBResource) GetDbType() types.DBType
func (*DBResource) GetDbVersion ¶
func (db *DBResource) GetDbVersion() string
func (*DBResource) GetKeeper ¶
func (db *DBResource) GetKeeper() *sync.Map
func (*DBResource) GetResourceGroupId ¶
func (db *DBResource) GetResourceGroupId() string
func (*DBResource) GetResourceId ¶
func (db *DBResource) GetResourceId() string
func (*DBResource) Hold ¶
func (db *DBResource) Hold(xaBranchID string, v interface{}) error
Hold the xa connection.
func (*DBResource) IsShouldBeHeld ¶
func (db *DBResource) IsShouldBeHeld() bool
func (*DBResource) Lookup ¶
func (db *DBResource) Lookup(xaBranchID string) (interface{}, bool)
func (*DBResource) Release ¶
func (db *DBResource) Release(xaBranchID string)
func (*DBResource) SetDbType ¶
func (db *DBResource) SetDbType(dbType types.DBType)
func (*DBResource) SetDbVersion ¶
func (db *DBResource) SetDbVersion(v string)
type Option ¶
type Option func(*XABranchXid)
func WithBranchId ¶
func WithBranchQualifier ¶
func WithGlobalTransactionId ¶
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
func (*Stmt) Close ¶
Close closes the statement.
As of Go 1.1, a Stmt will not be closed if it's in use by any queries.
Drivers must ensure all network calls made by Close do not block indefinitely (e.g. apply a timeout).
func (*Stmt) ExecContext ¶
ExecContext executes a query that doesn't return rows, such as an INSERT or UPDATE.
ExecContext must honor the context timeout and return when it is canceled.
func (*Stmt) NumInput ¶
NumInput returns the number of placeholder parameters.
If NumInput returns >= 0, the sql package will sanity check argument counts from callers and return errors to the caller before the statement's Exec or Query methods are called.
NumInput may also return -1, if the driver doesn't know its number of placeholders. In that case, the sql package will not sanity check Exec or Query argument counts.
func (*Stmt) QueryContext ¶
QueryContext StmtQueryContext enhances the Stmt interface by providing Query with context. QueryContext executes a query that may return rows, such as a SELECT. QueryContext must honor the context timeout and return when it is canceled.
type XABranchXid ¶
type XABranchXid struct {
// contains filtered or unexported fields
}
func NewXABranchXid ¶
func NewXABranchXid(opt ...Option) *XABranchXid
func XaIdBuild ¶
func XaIdBuild(xid string, branchId uint64) *XABranchXid
func XaIdBuildWithByte ¶
func XaIdBuildWithByte(globalTransactionId []byte, branchQualifier []byte) *XABranchXid
func (*XABranchXid) GetBranchId ¶
func (x *XABranchXid) GetBranchId() uint64
func (*XABranchXid) GetBranchQualifier ¶
func (x *XABranchXid) GetBranchQualifier() []byte
func (*XABranchXid) GetGlobalTransactionId ¶
func (x *XABranchXid) GetGlobalTransactionId() []byte
func (*XABranchXid) GetGlobalXid ¶
func (x *XABranchXid) GetGlobalXid() string
func (*XABranchXid) String ¶
func (x *XABranchXid) String() string
type XAConfig ¶
type XAConn ¶
type XAConn struct { *Conn // contains filtered or unexported fields }
XAConn Database connection proxy object under XA transaction model Conn is assumed to be stateful.
func (*XAConn) CloseForce ¶
func (*XAConn) ExecContext ¶
func (*XAConn) PrepareContext ¶
func (*XAConn) QueryContext ¶
func (c *XAConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
QueryContext exec xa sql
func (*XAConn) ShouldBeHeld ¶
type XAConnConf ¶
type XAConnConf struct {
XaBranchExecutionTimeout time.Duration `json:"xa_branch_execution_timeout" xml:"xa_branch_execution_timeout" koanf:"xa_branch_execution_timeout"`
}
func (*XAConnConf) RegisterFlagsWithPrefix ¶
func (cfg *XAConnConf) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)
type XAResourceManager ¶
type XAResourceManager struct {
// contains filtered or unexported fields
}
func InitXA ¶
func InitXA(config XAConfig) *XAResourceManager
func (*XAResourceManager) BranchCommit ¶
func (xaManager *XAResourceManager) BranchCommit(ctx context.Context, branchResource rm.BranchResource) (branch.BranchStatus, error)
func (*XAResourceManager) BranchRegister ¶
func (xaManager *XAResourceManager) BranchRegister(ctx context.Context, req rm.BranchRegisterParam) (int64, error)
func (*XAResourceManager) BranchReport ¶
func (xaManager *XAResourceManager) BranchReport(ctx context.Context, param rm.BranchReportParam) error
func (*XAResourceManager) BranchRollback ¶
func (xaManager *XAResourceManager) BranchRollback(ctx context.Context, branchResource rm.BranchResource) (branch.BranchStatus, error)
func (*XAResourceManager) CreateTableMetaCache ¶
func (xaManager *XAResourceManager) CreateTableMetaCache(ctx context.Context, resID string, dbType types.DBType, db *sql.DB) (datasource.TableMetaCache, error)
func (*XAResourceManager) GetBranchType ¶
func (xaManager *XAResourceManager) GetBranchType() branch.BranchType
func (*XAResourceManager) GetCachedResources ¶
func (xaManager *XAResourceManager) GetCachedResources() *sync.Map
func (*XAResourceManager) LockQuery ¶
func (xaManager *XAResourceManager) LockQuery(ctx context.Context, param rm.LockQueryParam) (bool, error)
func (*XAResourceManager) RegisterResource ¶
func (xaManager *XAResourceManager) RegisterResource(res rm.Resource) error
func (*XAResourceManager) UnregisterResource ¶
func (xaManager *XAResourceManager) UnregisterResource(resource rm.Resource) error
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
Package sql provides a generic interface around SQL (or SQL-like) databases.
|
Package sql provides a generic interface around SQL (or SQL-like) databases. |