Exemple #1
0
func (cli *grpcClient) QueryAsync(query []byte) *ReqRes {
	req := types.ToRequestQuery(query)
	res, err := cli.client.Query(context.Background(), req.GetQuery(), grpc.FailFast(true))
	if err != nil {
		cli.StopForError(err)
	}
	return cli.finishAsyncCall(req, &types.Response{&types.Response_Query{res}})
}
Exemple #2
0
func (cli *socketClient) QuerySync(query []byte) (res types.Result) {
	reqres := cli.queueRequest(types.ToRequestQuery(query))
	cli.FlushSync()
	if err := cli.Error(); err != nil {
		return types.ErrInternalError.SetLog(err.Error())
	}
	resp := reqres.Response.GetQuery()
	return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
}
Exemple #3
0
func (app *localClient) QueryAsync(tx []byte) *ReqRes {
	app.mtx.Lock()
	res := app.Application.Query(tx)
	app.mtx.Unlock()
	return app.callback(
		types.ToRequestQuery(tx),
		types.ToResponseQuery(res.Code, res.Data, res.Log),
	)
}
Exemple #4
0
func (cli *socketClient) QueryAsync(query []byte) *ReqRes {
	return cli.queueRequest(types.ToRequestQuery(query))
}