autorc

package
Version: v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2015 License: BSD-3-Clause, BSD-3-Clause Imports: 5 Imported by: 31

Documentation

Overview

Auto reconnect interface for MyMySQL

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNetErr

func IsNetErr(err error) bool

Return true if error is network error or UnexpectedEOF.

Types

type Conn

type Conn struct {
	Raw mysql.Conn
	// Maximum reconnect retries.
	// Default is 7 which means 1+2+3+4+5+6+7 = 28 seconds before return error
	// (if waiting for error takes no time).
	MaxRetries int

	// Debug logging. You may change it at any time.
	Debug bool
}

func New

func New(proto, laddr, raddr, user, passwd string, db ...string) *Conn

func NewFromCF added in v0.4.9

func NewFromCF(cfgFile string) (*Conn, map[string]string, error)

func (*Conn) Begin added in v1.0.1

func (c *Conn) Begin(f func(mysql.Transaction, ...interface{}) error, args ...interface{}) error

Begin begins a transaction and calls f to complete it . If f returns an error and IsNetErr(error) == true it reconnects and calls f up to MaxRetries times. If error is of type *mysql.Error it tries rollback the transaction.

func (*Conn) Clone added in v0.4.10

func (c *Conn) Clone() *Conn

func (*Conn) Escape added in v1.2.1

func (c *Conn) Escape(s string) string

func (*Conn) Prepare

func (c *Conn) Prepare(sql string) (*Stmt, error)

Automatic connect/reconnect/repeat version of Prepare

func (*Conn) PrepareOnce added in v0.4.5

func (c *Conn) PrepareOnce(s *Stmt, sql string) error

Prepares statement if it wasn't prepared before

func (*Conn) Query

func (c *Conn) Query(sql string, params ...interface{}) (rows []mysql.Row, res mysql.Result, err error)

Automatic connect/reconnect/repeat version of Query

func (*Conn) QueryFirst added in v0.4.8

func (c *Conn) QueryFirst(sql string, params ...interface{}) (row mysql.Row, res mysql.Result, err error)

func (*Conn) QueryLast added in v0.4.8

func (c *Conn) QueryLast(sql string, params ...interface{}) (row mysql.Row, res mysql.Result, err error)

func (*Conn) Reconnect added in v0.4.11

func (c *Conn) Reconnect() (err error)

func (*Conn) Register added in v0.4.11

func (c *Conn) Register(sql string)

func (*Conn) SetMaxPktSize added in v0.4.11

func (c *Conn) SetMaxPktSize(new_size int) int

func (*Conn) SetTimeout added in v1.1.3

func (c *Conn) SetTimeout(timeout time.Duration)

func (*Conn) Use

func (c *Conn) Use(dbname string) (err error)

Automatic connect/reconnect/repeat version of Use

type Stmt

type Stmt struct {
	Raw mysql.Stmt
	// contains filtered or unexported fields
}

func (*Stmt) Bind added in v0.4.11

func (s *Stmt) Bind(params ...interface{})

func (*Stmt) Exec

func (s *Stmt) Exec(params ...interface{}) (rows []mysql.Row, res mysql.Result, err error)

Automatic connect/reconnect/repeat version of Exec

func (*Stmt) ExecFirst added in v0.4.8

func (s *Stmt) ExecFirst(params ...interface{}) (row mysql.Row, res mysql.Result, err error)

func (*Stmt) ExecLast added in v0.4.8

func (s *Stmt) ExecLast(params ...interface{}) (row mysql.Row, res mysql.Result, err error)

Source Files

Jump to

Keyboard shortcuts

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