Getting Target that client connected to

26 views
Skip to first unread message

mica...@seas.upenn.edu

unread,
Apr 30, 2018, 12:27:42 PM4/30/18
to grpc.io
Hi, I would like to just obtain the information of the server I connected to here is how my functionality is being used:

ProjectGuideClient client(grpc::CreateChannel(server,grpc::InsecureChannelCredentials()));
client.Dele(args);

If I return back a not ok status I would like to connect to a master node and retrieve the back up server to connect to. To do this I need to send the server that I want the back up to. In this case I need to obtain the variable "server" as shown in above. where can I access this information? and how. below there are questions marks of how I would to use it and I thought I could get the information? Thanks!!

/*
 Dele rpc command
 Parms string row, string col
 Returns true if deleted, false if an error
 */
bool ProjectGuideClient::Dele(DeleArgs args) {

DeleResponse response;

ClientContext context;

Status status = stub_->Dele(&context, args, &response);
  if(status.ok())
return status.ok();
  else{
    //get my channel to senda rewuest for backup
my channel = "Channel.Target(); ???????

  }
}

Sree Kuchibhotla

unread,
May 21, 2018, 1:45:51 PM5/21/18
to grpc.io
gRPC does not return the target name (this is something the user/application should keep track of when creating the channel).

however, the ClientContext::Peer() would return you the address of the exact backend the Call went to..

-Sree
Reply all
Reply to author
Forward
0 new messages