Documentation ¶
Index ¶
- type QueueDriver
- func (d *QueueDriver) DoCommit(ctx context.Context, in gdb.DoCommitInput) (out gdb.DoCommitOutput, err error)
- func (d *QueueDriver) Exec(ctx context.Context, sql string, args ...interface{}) (result sql.Result, err error)
- func (d *QueueDriver) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type QueueDriver ¶
type QueueDriver struct {
*mysql.DriverMysql
}
func (*QueueDriver) DoCommit ¶
func (d *QueueDriver) DoCommit(ctx context.Context, in gdb.DoCommitInput) (out gdb.DoCommitOutput, err error)
DoCommit commits current sql and arguments to underlying sql driver.
func (*QueueDriver) Exec ¶
func (d *QueueDriver) Exec(ctx context.Context, sql string, args ...interface{}) (result sql.Result, err error)
func (d *QueueDriver) DoExec(ctx g.Ctx, link gdb.Link, sql string, args ...interface{}) (result sql.Result, err error) { // Transaction checks. if link == nil { if tx := gdb.TXFromCtx(ctx, d.Ctx(ctx).GetGroup()); tx != nil { // Firstly, check and retrieve transaction link from context. //link = &gdb.Link{tx.tx} } else if link, err = d.Core.MasterLink(); err != nil { // Or else it creates one from master node. return nil, err } } else if !link.IsTransaction() { // If current link is not transaction link, it checks and retrieves transaction from context. if tx := gdb.TXFromCtx(ctx, d.Ctx(ctx).GetGroup()); tx != nil { //link = &txLink{tx.tx} } } if d.Core.GetConfig().ExecTimeout > 0 { var cancelFunc context.CancelFunc ctx, cancelFunc = context.WithTimeout(ctx, d.Core.GetConfig().ExecTimeout) defer cancelFunc() } //写入QUEUE队 sqlstring := gdb.FormatSqlWithArgs(sql, args) queue.New().Add(ctx, sqlstring) return
}
func (*QueueDriver) New ¶
func (d *QueueDriver) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error)
Click to show internal directories.
Click to hide internal directories.