示例#1
0
func (f *Follow) txDo(db *gomodel.DB, do func(gomodel.Tx, *Follow) error) (err error) {
	tx, err := db.Begin()
	if err != nil {
		return
	}

	defer tx.DeferDone(&err)

	err = do(tx, f)
	return
}
示例#2
0
func (u *User) txDo(db *gomodel.DB, do func(gomodel.Tx, *User) error) (err error) {
	tx, err := db.Begin()
	if err != nil {
		return
	}

	defer tx.DeferDone(&err)

	err = do(tx, u)
	return
}
示例#3
0
文件: rdb_gen.go 项目: cosiner/gotmsq
func (m *message) txDo(db *gomodel.DB, do func(*gomodel.Tx, *message) error) error {
	tx, err := db.Begin()
	if err != nil {
		return err
	}
	defer tx.Close()

	err = do(tx, m)
	tx.Success(err == nil)
	return err
}
示例#4
0
func (f *Follow) txDo(db *gomodel.DB, do func(*gomodel.Tx, *Follow) error) error {
	tx, err := db.Begin()
	if err != nil {
		return err
	}
	defer tx.Close()

	err = do(tx, f)
	tx.Success(err == nil)
	return err
}
示例#5
0
文件: rdb.go 项目: cosiner/gotmsq
func NewDBBackend(db *gomodel.DB, timeFormat string) (b gotmsq.Backend, err error) {
	d := &DB{timeFormat: timeFormat}
	b = d

	defer func(d *DB, err *error) {
		if *err == nil {
			return
		}
		if d.stmtClearTimeout != nil {
			d.stmtClearTimeout.Close()
		}
		if d.stmtInsert != nil {
			d.stmtInsert.Close()
		}
		if d.stmtQueryMessage != nil {
			d.stmtQueryMessage.Close()
		}
		if d.stmtDeleteById != nil {
			d.stmtDeleteById.Close()
		}
	}(d, &err)

	d.stmtClearTimeout, err = db.StmtById(deleteTimeoutMessagesSQL)
	if err != nil {
		return
	}
	d.stmtQueryMessage, err = db.StmtById(queryMessageSQL)
	if err != nil {
		return
	}
	d.stmtDeleteById, err = db.StmtById(deleteMessageByIdSQL)
	if err != nil {
		return
	}
	d.stmtInsert, err = db.StmtById(insertMessageSQL)
	if err != nil {
		return
	}
	return
}