34 std::cout <<
"=== gRPC Service Example ===" << std::endl;
37 std::cout <<
"\n1. gRPC Server configuration:" << std::endl;
39 config.max_concurrent_streams = 100;
41 config.keepalive_time = std::chrono::milliseconds(7200000);
42 config.keepalive_timeout = std::chrono::milliseconds(20000);
44 std::cout <<
" Max concurrent streams: " <<
config.max_concurrent_streams << std::endl;
45 std::cout <<
" Worker threads: " <<
config.num_threads << std::endl;
46 std::cout <<
" Keepalive: " <<
config.keepalive_time.count() <<
"ms" << std::endl;
49 std::cout <<
"\n2. Creating gRPC server:" << std::endl;
52 auto reg_result = server.register_unary_method(
53 "/example.Greeter/SayHello",
57 std::cout <<
" [Handler] Received request (" << request.
data.size()
58 <<
" bytes)" << std::endl;
61 std::string body =
"Hello from gRPC server!";
62 response.
data.assign(body.begin(), body.end());
63 return kcenon::common::ok(std::move(response));
66 if (reg_result.is_ok())
68 std::cout <<
" Method '/example.Greeter/SayHello' registered" << std::endl;
72 std::cout <<
" Method registration: " << reg_result.error().message << std::endl;
76 std::cout <<
"\n3. gRPC Client:" << std::endl;
77 std::cout <<
" Target: localhost:50051" << std::endl;
78 std::cout <<
" (Connection requires a running server)" << std::endl;
81 std::cout <<
"\n4. gRPC API overview:" << std::endl;
82 std::cout <<
" Server: register_unary_method(), start(port), stop()" << std::endl;
83 std::cout <<
" Client: connect(), call_raw(method, request, options)" << std::endl;
84 std::cout <<
" Message: grpc_message { data: vector<byte> }" << std::endl;
86 std::cout <<
"\nDone." << std::endl;
Context for handling a single RPC request.