Exemple #1
0
func sendUseDB(conn net.Conn) error {
	var usedb dbproto.UseDB
	usedb.Dbname = proto.String(dbName)

	err := sirius_net.SendMsg(conn, &usedb, uint32(dbproto.Command_CMD_USEDB_REQ), 1)
	if err != nil {
		return err
	}

	var header sirius_net.Header
	var body [64]byte
	_, err = sirius_net.Recv(conn, &header, body[0:])
	if err != nil {
		return err
	}

	if header.Err != 0 {
		log.Fatal("use db err %v\n", err)
	}
	return nil
}
Exemple #2
0
func (task *FlushTask) useDB() error {
	var usedb dbproto.UseDB
	usedb.Dbname = proto.String(task.dbname)

	err := sirius_net.SendMsg(task.proxy_conn[0], &usedb, uint32(dbproto.Command_CMD_USEDB_REQ), 1)
	if err != nil {
		return err
	}

	var header sirius_net.Header
	var b [64]byte
	_, err = sirius_net.Recv(task.proxy_conn[0], &header, b[0:])
	if err != nil {
		return err
	}

	if header.Err != 0 {
		logger.Print("use db err:", err)
		return ErrorUseDB
	}
	return nil
}