Documentation ¶
Index ¶
- Constants
- func Check(a interface{})
- func DbxDatabase() *dbx.Database
- func ExecuteContext(ctx context.Context, fn func(*dbx.TxRunner) error) error
- func GetEnvelopeActivityLink() string
- func GetEnvelopeDomain() string
- func Iris() *iris.Application
- func Props() kvs.ConfigSource
- func Register(fn func())
- func RpcRegister(ri interface{})
- func RpcServer() *rpc.Server
- func Translator() ut.Translator
- func Tx(fn func(*dbx.TxRunner) error) error
- func TxContext(ctx context.Context, fn func(runner *dbx.TxRunner) error) error
- func Validate() *validator.Validate
- func ValidateStruct(s interface{}) (err error)
- func WithValueContext(parent context.Context, runner *dbx.TxRunner) context.Context
- type BaseDao
- type DbxDatabaseStarter
- type EurekaStarter
- type GoRPCStarter
- type HookStarter
- type IrisServerStarter
- type PropsStarter
- type ResCode
- type Response
- type SystemAccount
- type ValidatorStarter
Constants ¶
View Source
const TX = "tx"
Variables ¶
This section is empty.
Functions ¶
func Check ¶
func Check(a interface{})
结构体指针检查验证,如果传入的interface为nil,就通过log.Panic函数抛出一个异常 被用在starter中检查公共资源是否被实例化了
func DbxDatabase ¶
func ExecuteContext ¶
在事务上下文中执行事务逻辑 传入绑定了runner的上下文,并执行事务函数代码 函数只能用在绑定了runner的事务上下文中,也就是说用在事务函数内部,和WithValueContext配合一起来完成。 举例:
func CreateXyz() error { err := Tx(func(runner *dbx.TxRunner) error { //将runner绑定到上下文 ctx := WithValueContext(context.Background(), runner) //dao.insert xxx TxStepY(ctx) TxStepZ(ctx) return nil }) return err }
func TxStepY(ctx context.Context) error { //事务上下文中执行Y数据库操作 return ExecuteContext(ctx, func(runner *dbx.TxRunner) error { //dao.insert yyy return nil })
}
func TxStepZ(ctx context.Context) error { //事务上下文中执行Z数据库操作 return ExecuteContext(ctx, func(runner *dbx.TxRunner) error { //dao.update zzz return nil })
}
func GetEnvelopeDomain ¶
func GetEnvelopeDomain() string
func Props ¶
func Props() kvs.ConfigSource
func Translator ¶
func Translator() ut.Translator
Types ¶
type DbxDatabaseStarter ¶
type DbxDatabaseStarter struct {
infra.BaseStarter
}
dbx 数据库 starter,并设置为全局
func (*DbxDatabaseStarter) Setup ¶
func (s *DbxDatabaseStarter) Setup(ctx infra.StarterContext)
数据库连接的生命周期要晚于配置文件的加载,为了更好的符合此逻辑,将连接的初始化设置在 Setup 阶段
type EurekaStarter ¶
type EurekaStarter struct { infra.BaseStarter // contains filtered or unexported fields }
func (*EurekaStarter) Init ¶
func (e *EurekaStarter) Init(ctx infra.StarterContext)
func (*EurekaStarter) Setup ¶
func (e *EurekaStarter) Setup(ctx infra.StarterContext)
type GoRPCStarter ¶
type GoRPCStarter struct { infra.BaseStarter // contains filtered or unexported fields }
func (*GoRPCStarter) Init ¶
func (g *GoRPCStarter) Init(ctx infra.StarterContext)
func (*GoRPCStarter) Start ¶
func (g *GoRPCStarter) Start(ctx infra.StarterContext)
type HookStarter ¶
type HookStarter struct {
infra.BaseStarter
}
func (*HookStarter) Init ¶
func (h *HookStarter) Init(ctx infra.StarterContext)
func (*HookStarter) Start ¶
func (h *HookStarter) Start(ctx infra.StarterContext)
type IrisServerStarter ¶
type IrisServerStarter struct {
infra.BaseStarter
}
func (*IrisServerStarter) Init ¶
func (i *IrisServerStarter) Init(ctx infra.StarterContext)
func (*IrisServerStarter) Start ¶
func (i *IrisServerStarter) Start(ctx infra.StarterContext)
func (*IrisServerStarter) StartBlocking ¶
func (i *IrisServerStarter) StartBlocking() bool
type PropsStarter ¶
type PropsStarter struct {
infra.BaseStarter
}
func (*PropsStarter) Init ¶
func (p *PropsStarter) Init(ctx infra.StarterContext)
type Response ¶
type Response struct { Code ResCode `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
http 响应结构体
type ValidatorStarter ¶
type ValidatorStarter struct {
infra.BaseStarter
}
func (*ValidatorStarter) Init ¶
func (v *ValidatorStarter) Init(ctx infra.StarterContext)
Click to show internal directories.
Click to hide internal directories.