queuemysql

package module
v0.0.0-...-cee0da7 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

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)

Jump to

Keyboard shortcuts

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