Skip to content

Commit

Permalink
Update tutorial (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
holmes1412 committed Mar 18, 2024
1 parent e75ec96 commit 1cbe518
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tutorial/tutorial-01-srpc_pb_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ int main()

if (server.start(1412) == 0)
{
printf("SRPC framework SRPC Protobuf server is running on 1412\n"
"Try ./srpc_pb_client to send requests.\n\n");
wait_group.wait();
server.stop();
}
Expand Down
1 change: 1 addition & 0 deletions tutorial/tutorial-02-srpc_pb_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int main()
else
printf("status[%d] error[%d] errmsg:%s\n",
ctx->get_status_code(), ctx->get_error(), ctx->get_errmsg());
wait_group.done();
});

//sync
Expand Down
2 changes: 2 additions & 0 deletions tutorial/tutorial-03-srpc_thrift_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ int main()

if (server.start(1412) == 0)
{
printf("SRPC framework SRPC protocol server with thrift IDL is running on 1412\n"
"Try ./srpc_thrift_client to send requests.\n\n");
wait_group.wait();
server.stop();
}
Expand Down
1 change: 1 addition & 0 deletions tutorial/tutorial-04-srpc_thrift_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ int main()
else
printf("status[%d] error[%d] errmsg:%s\n",
ctx->get_status_code(), ctx->get_error(), ctx->get_errmsg());
wait_group.done();
});

//sync
Expand Down
2 changes: 2 additions & 0 deletions tutorial/tutorial-05-brpc_pb_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ int main()

if (server.start(1412) == 0)
{
printf("SRPC framework BRPC Protobuf server is running on 1412\n"
"Try ./brpc_pb_client to send requests.\n\n");
wait_group.wait();
server.stop();
}
Expand Down
2 changes: 2 additions & 0 deletions tutorial/tutorial-06-brpc_pb_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ int main()

while (ctx->get_attachment(&attachment, &len))
printf("get attachment [%.*s] len=%zu\n", (int)len, attachment, len);

wait_group.done();
});

//sync
Expand Down
2 changes: 2 additions & 0 deletions tutorial/tutorial-07-thrift_thrift_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ int main()

if (server.start(1412) == 0)
{
printf("SRPC framework Thrift protocol server with thrift IDL is running on 1412\n"
"Try ./thrift_thrift_client to send requests.\n\n");
wait_group.wait();
server.stop();
}
Expand Down
2 changes: 2 additions & 0 deletions tutorial/tutorial-10-server_async.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ int main(int argc, char *argv[])

if (server.start(1412) == 0)
{
printf("Asynchronous server with HTTP requests is running on 1412\n"
"Try ./client_task or ./srpc_pb_client to trigger this example.\n\n");
wait_group.wait();
server.stop();
}
Expand Down
3 changes: 2 additions & 1 deletion tutorial/tutorial-11-trpc_pb_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ int main()

if (server.start(1412) == 0)
{
printf("SRPC framework TRPC server running on 1412...\n");
printf("SRPC framework TRPC server is running on 1412\n"
"Try ./trpc_pb_client to send requests.\n\n");
wait_group.wait();
server.stop();
}
Expand Down
1 change: 1 addition & 0 deletions tutorial/tutorial-12-trpc_pb_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ int main()
else
printf("status[%d] error[%d] errmsg:%s\n",
ctx->get_status_code(), ctx->get_error(), ctx->get_errmsg());
wait_group.done();
});

//sync
Expand Down
3 changes: 2 additions & 1 deletion tutorial/tutorial-13-trpc_http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ int main()

if (server.start(1412) == 0)
{
printf("SRPC framework TRPCHttp server running on 1412...\n");
printf("SRPC framework TRPCHttp server is running on 1412\n"
"Try ./trpc_http_client to send requests.\n\n");
wait_group.wait();
server.stop();
}
Expand Down
7 changes: 7 additions & 0 deletions tutorial/tutorial-15-srpc_pb_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ class ExampleProxyServiceImpl : public Example::Service
public:
void Echo(EchoRequest *request, EchoResponse *response, RPCContext *context) override
{
printf("Proxy Server Echo() get and transfer request:\n%s\n",
request->DebugString().c_str());

auto *task = this->client->create_Echo_task([response](EchoResponse *resp,
RPCContext *ctx) {
printf("Proxy Server Echo() get and transfer response:\n%s\n",
resp->DebugString().c_str());
if (ctx->success())
*response = std::move(*resp);
});
Expand Down Expand Up @@ -67,6 +72,8 @@ int main()

if (server.start(61412) == 0)
{
printf("Proxy server serving on 61412 and redirect to backend server 127.0.0.1:1412\n"
"Try start ./srpc_pb_server as backend and send requests to 61412.\n\n");
wait_group.wait();
server.stop();
}
Expand Down
3 changes: 3 additions & 0 deletions tutorial/tutorial-16-server_with_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ int main()

if (server.start(1412) == 0)
{
printf("Server with metrics for Promethes(port:8080) is running on 1412\n"
"Try ./srpc_pb_client to send requests.\n"
"Try ' curl http://localhost:8080/metrics ' to get prometheus data.\n");
wait_group.wait();
server.stop();
}
Expand Down
2 changes: 2 additions & 0 deletions tutorial/tutorial-17-http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ int main()

if (server.start(1412) == 0)
{
printf("HTTP protocol server is running on 1412\n"
"Try ./http_client to send requests.\n\n");
wait_group.wait();
server.stop();
}
Expand Down
2 changes: 2 additions & 0 deletions tutorial/tutorial-18-http_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ void callback(WFHttpTask *task)
fflush(stdout);
fprintf(stderr, "\nfinish print body. body_len = %zu\n", body_len);
}

wait_group.done();
}

int main()
Expand Down

0 comments on commit 1cbe518

Please sign in to comment.