forked from trpc-group/trpc-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream_server.cc
53 lines (41 loc) · 1.53 KB
/
stream_server.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
//
// Tencent is pleased to support the open source community by making tRPC available.
//
// Copyright (C) 2023 THL A29 Limited, a Tencent company.
// All rights reserved.
//
// If you have downloaded a copy of the tRPC source code from Tencent,
// please note that tRPC source code is licensed under the Apache 2.0 License,
// A copy of the Apache 2.0 License is included in this file.
//
//
#include <string>
#include <utility>
#include "trpc/common/logging/trpc_logging.h"
#include "trpc/common/trpc_app.h"
#include "examples/features/trpc_stream/server/stream_service.h"
namespace test {
namespace helloworld {
class HelloWorldStreamServer : public ::trpc::TrpcApp {
public:
int Initialize() override {
const auto& config = ::trpc::TrpcConfig::GetInstance()->GetServerConfig();
std::string service_name = fmt::format("{}.{}.{}.{}", "trpc", config.app, config.server, "StreamGreeter");
TRPC_FMT_INFO("service name:{}", service_name);
RegisterService(service_name, std::make_shared<::test::helloworld::StreamGreeterServiceImpl>());
service_name = fmt::format("{}.{}.{}.{}", "trpc", config.app, config.server, "RawDataStreamService");
TRPC_FMT_INFO("service name:{}", service_name);
RegisterService(service_name, std::make_shared<::test::helloworld::RawDataStreamService>());
return 0;
}
void Destroy() override {}
};
} // namespace helloworld
} // namespace test
int main(int argc, char** argv) {
test::helloworld::HelloWorldStreamServer server;
server.Main(argc, argv);
server.Wait();
return 0;
}