Skip to content

Commit

Permalink
fix phxrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
taohexxx committed Aug 13, 2018
1 parent b793953 commit b64b19c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
11 changes: 7 additions & 4 deletions phxbinlogsvr/framework/phxrpc/client/phxbinlog_stub_phxrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
Tencent is pleased to support the open source community by making PhxSQL available.
Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the GNU General Public License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://opensource.org/licenses/GPL-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

#include "phxbinlog_stub_phxrpc.h"
#include "phxrpc_phxbinlog_stub.h"
#include "phxcomm/phx_log.h"

#include "phxrpc/http.h"
#include "phxrpc/rpc.h"

#include <iostream>
Expand Down Expand Up @@ -80,7 +81,8 @@ int PhxBinlogStub_PhxRPC::RpcCallWithIPList(const FuncName &func, const vector<s
ReqType tmp_req = req;
google::protobuf::BytesValue resp;

PhxbinlogStub stub(socket, *(global_phxbinlogclient_client_monitor.get()));
phxrpc::HttpMessageHandlerFactory http_msg_factory;
PhxbinlogStub stub(socket, *(global_phxbinlogclient_client_monitor.get()), http_msg_factory);
int ret = (stub.*func)(tmp_req, &resp);
(*resp_bufferlist)[i]=make_pair(resp.value(), ret);

Expand All @@ -107,7 +109,8 @@ int PhxBinlogStub_PhxRPC::RpcCallWithIP(const FuncName &func, const string &ip,
if (phxrpc::PhxrpcTcpUtils::Open(&socket, ip.c_str(), port, GetTimeOutMS(), NULL, 0,
*(global_phxbinlogclient_client_monitor.get()))) {
socket.SetTimeout(GetTimeOutMS());
PhxbinlogStub stub(socket, *(global_phxbinlogclient_client_monitor.get()));
phxrpc::HttpMessageHandlerFactory http_msg_factory;
PhxbinlogStub stub(socket, *(global_phxbinlogclient_client_monitor.get()), http_msg_factory);
ret = (stub.*func)(req, resp);
}
if (ret) {
Expand Down
11 changes: 5 additions & 6 deletions phxbinlogsvr/framework/phxrpc/svr/phxbinlog_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,17 @@ PhxBinLogSvrHandler *Server::GetSvrHandler() {
return svr_handler_;
}

void Server::Dispatch(const phxrpc::HttpRequest &req,
phxrpc::HttpResponse *const resp,
phxrpc::DispatcherArgs_t *args) {
void Server::Dispatch(const phxrpc::BaseRequest &req,
phxrpc::BaseResponse *const resp,
phxrpc::DispatcherArgs_t *const args) {
ServiceArgs_t *service_args = (ServiceArgs_t *)(args->service_args);
PhxbinlogServiceImpl service(service_args);

PhxbinlogDispatcher dispatcher(service, args);
phxrpc::HttpDispatcher<PhxbinlogDispatcher>
phxrpc::BaseDispatcher<PhxbinlogDispatcher>
base_dispatcher(dispatcher, PhxbinlogDispatcher::GetURIFuncMap());
if (!base_dispatcher.Dispatch(req, resp)) {
resp->SetStatusCode(404);
resp->SetReasonPhrase("Not Found");
resp->SetFake(phxrpc::BaseResponse::FakeReason::DISPATCH_ERROR);
}
}

8 changes: 4 additions & 4 deletions phxbinlogsvr/framework/phxrpc/svr/phxbinlog_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ class Server {
PhxbinlogServerConfig *GetServerConfig();
phxbinlogsvr::PhxBinLogSvrHandler *GetSvrHandler();

static void Dispatch(const phxrpc::HttpRequest &req,
phxrpc::HttpResponse *const resp,
phxrpc::DispatcherArgs_t *args);
static void Dispatch(const phxrpc::BaseRequest &req,
phxrpc::BaseResponse *const resp,
phxrpc::DispatcherArgs_t *const args);

protected:
typedef void (*OpenLogFunc)(const char *, const int &log_level, const char * log_path,
typedef void (*OpenLogFunc)(const char *, const int &log_level, const char *log_path,
const uint32_t &log_file_max_size);
typedef void (*LogFunc)(int log_level, const char *format, va_list args);

Expand Down

0 comments on commit b64b19c

Please sign in to comment.