mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-27 05:29:43 +01:00
e4a28e9e4b
* remove parent ptr from unregistered calls -- unneeded * begin unregistered high level server loop * undo changes to highlevel server, add mkConfig for unregistered server * move call CQ create/destroy into call create/destroy * async normal call function * preliminary unregistered server loop for non-streaming methods * working unregistered highlevel example * loop counters for benchmarking * changes for benchmarking, add ruby example server for benchmarking * async version of withCall, refactor unregistered server loop to handle all method types * unregistered client streaming * add remaining streaming modes * unregistered server streaming test * unregistered streaming tests * add error logging * fix bug in add example * remove old TODOs * fix bug: don't assume slices are null-terminated * add TODO re: unregistered client streaming functions
42 lines
931 B
C++
42 lines
931 B
C++
#include <string>
|
|
#include <iostream>
|
|
#include <atomic>
|
|
|
|
#include <grpc++/grpc++.h>
|
|
#include "echo.grpc.pb.h"
|
|
|
|
using namespace std;
|
|
|
|
using grpc::Server;
|
|
using grpc::ServerBuilder;
|
|
using grpc::ServerContext;
|
|
using grpc::Status;
|
|
|
|
using echo::EchoRequest;
|
|
using echo::Echo;
|
|
|
|
atomic_int reqCount;
|
|
|
|
class EchoServiceImpl final : public Echo::Service {
|
|
Status DoEcho(ServerContext* ctx, const EchoRequest* req,
|
|
EchoRequest* resp) override {
|
|
reqCount++;
|
|
if(reqCount % 100 == 0){
|
|
cout<<reqCount<<endl;
|
|
}
|
|
resp->set_message(req->message());
|
|
return Status::OK;
|
|
}
|
|
};
|
|
|
|
int main(){
|
|
string server_address("localhost:50051");
|
|
EchoServiceImpl service;
|
|
|
|
ServerBuilder builder;
|
|
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
|
|
builder.RegisterService(&service);
|
|
unique_ptr<Server> server(builder.BuildAndStart());
|
|
server->Wait();
|
|
return 0;
|
|
}
|