zormexamples

package
v0.0.0-...-28272ef Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MyFuncGlobalTransaction

func MyFuncGlobalTransaction(ctx context.Context) (zorm.IGlobalTransaction, context.Context, error)

MyFuncGlobalTransaction zorm适配seata/hptx 全局分布式事务的函数 重要!!!!需要配置zorm.DataSourceConfig.FuncGlobalTransaction=MyFuncGlobalTransaction 重要!!!

Types

type CustomDMText

type CustomDMText struct{}

实现CustomDriverValueConver接口,扩展自定义类型,例如 达梦数据库text类型,映射出来的是dm.DmClob类型,无法使用string类型直接接收

func (CustomDMText) ConverDriverValue

func (dmtext CustomDMText) ConverDriverValue(ctx context.Context, columnType *sql.ColumnType, structFieldType *reflect.Type, tempDriverValue driver.Value, finder *zorm.Finder) (interface{}, error)

ConverDriverValue 数据库列类型,实体类属性类型,GetDriverValue返回的driver.Value的临时接收值,Finder对象 如果无法获取到structFieldType,例如Map查询,会传入nil 返回符合接收类型值的指针,指针,指针!!!!

func (CustomDMText) GetDriverValue

func (dmtext CustomDMText) GetDriverValue(ctx context.Context, columnType *sql.ColumnType, structFieldType *reflect.Type, finder *zorm.Finder) (driver.Value, error)

GetDriverValue 根据数据库列类型,实体类属性类型,Finder对象,返回driver.Value的实例 如果无法获取到structFieldType,例如Map查询,会传入nil 如果返回值为nil,接口扩展逻辑无效,使用原生的方式接收数据库字段值

type ZormGlobalTransaction

type ZormGlobalTransaction struct {
	*tm.DefaultGlobalTransaction
}

ZormGlobalTransaction 包装seata/hptx的*tm.DefaultGlobalTransaction,实现zorm.IGlobalTransaction接口

func (*ZormGlobalTransaction) BeginGTX

func (gtx *ZormGlobalTransaction) BeginGTX(ctx context.Context, globalRootContext context.Context) error

实现zorm.IGlobalTransaction 托管全局分布式事务接口,seata和hptx目前实现代码一致,只是引用的实现包不同 BeginGTX 开启全局分布式事务

func (*ZormGlobalTransaction) CommitGTX

func (gtx *ZormGlobalTransaction) CommitGTX(ctx context.Context, globalRootContext context.Context) error

CommitGTX 提交全局分布式事务

func (*ZormGlobalTransaction) GetGTXID

func (gtx *ZormGlobalTransaction) GetGTXID(ctx context.Context, globalRootContext context.Context) string

GetGTXID 获取全局分布式事务的XID

func (*ZormGlobalTransaction) RollbackGTX

func (gtx *ZormGlobalTransaction) RollbackGTX(ctx context.Context, globalRootContext context.Context) error

RollbackGTX 回滚全局分布式事务

Jump to

Keyboard shortcuts

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