#include "grpcdbclient.h" grpcdbclient::grpcdbclient() { } void grpcdbclient::run() { std::string target_str = mstrserverip+":"; target_str = target_str + mstrserverport ;//std::to_string() auto cargs = grpc::ChannelArguments(); cargs.SetMaxReceiveMessageSize(1024 * 1024 * 1024); // 1 GB cargs.SetMaxSendMessageSize(1024 * 1024 * 1024); std::shared_ptr channel = grpc::CreateCustomChannel( target_str, grpc::InsecureChannelCredentials(),cargs); std::unique_ptr stub_ = iv::db::dbservice::NewStub(channel); gpr_timespec timespec; timespec.tv_sec = 5;//设置阻塞时间为5秒 timespec.tv_nsec = 0; timespec.clock_type = GPR_TIMESPAN; while(!QThread::isInterruptionRequested()) { mWaitMutex.lock(); mwc.wait(&mWaitMutex,100); mWaitMutex.unlock(); if(mblistrequpdate) { iv::db::listRequest xlistreq; iv::db::listReply xlistreply; mMutexReq.lock(); xlistreq.CopyFrom(mlistreq); mblistrequpdate = false; mMutexReq.unlock(); ClientContext context ; context.set_deadline(timespec); Status status = stub_->querylist(&context, xlistreq, &xlistreply); if (status.ok()) { std::cout<<"get list ok"<