Пример #1
0
func (this *HttpClient) Close() {
	this.Client.Close()
	if this.Connect != nil {
		if err := this.Connect.Close(); err != nil {
			log.Errorf("client %s close with error:%s", this.Name, err.Error())
		}
	}
}
Пример #2
0
//执行带参数的特定id的sql,并返回数据
func BySqlParamName(id string, p map[string]interface{}) (map[string]int, [][]interface{}, error) {
	if client, err := rpc.DialHTTP("tcp", fmt.Sprintf("%s:%d", ServerIP, Port)); err != nil {
		var reply = new(common.RPCResponseSql)
		args := common.RPCRequestSql{Id: id, Param: p}
		err = client.Call("Oracle.BySqlParamName", args, &reply)
		if err != nil {
			log.Error("bysql error:", err)
		}
		return reply.Cols, reply.Rows, err
	} else {
		log.Errorf("rcp %s:%d error", ServerIP, Port, err.Error())
	}
	return nil, nil, fmt.Errorf("sql %s not exists", id)
}