• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //
3 // Copyright 2018 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPC_SRC_CPP_SERVER_LOAD_REPORTER_LOAD_REPORTING_SERVICE_SERVER_BUILDER_PLUGIN_H
20 #define GRPC_SRC_CPP_SERVER_LOAD_REPORTER_LOAD_REPORTING_SERVICE_SERVER_BUILDER_PLUGIN_H
21 
22 #include <grpc/support/port_platform.h>
23 #include <grpcpp/grpcpp.h>
24 #include <grpcpp/impl/server_builder_plugin.h>
25 #include <grpcpp/server_builder.h>
26 #include <grpcpp/support/channel_arguments.h>
27 
28 #include <memory>
29 #include <string>
30 
31 #include "src/cpp/server/load_reporter/load_reporter_async_service_impl.h"
32 
33 namespace grpc {
34 namespace load_reporter {
35 
36 // The plugin that registers and starts load reporting service when starting a
37 // server.
38 class LoadReportingServiceServerBuilderPlugin : public ServerBuilderPlugin {
39  public:
40   ~LoadReportingServiceServerBuilderPlugin() override = default;
name()41   std::string name() override { return "load_reporting_service"; }
42 
43   // Creates a load reporting service.
44   void UpdateServerBuilder(ServerBuilder* builder) override;
45 
46   // Registers the load reporter service.
47   void InitServer(ServerInitializer* si) override;
48 
49   // Starts the load reporter service.
50   void Finish(ServerInitializer* si) override;
51 
ChangeArguments(const std::string &,void *)52   void ChangeArguments(const std::string& /*name*/, void* /*value*/) override {}
UpdateChannelArguments(grpc::ChannelArguments *)53   void UpdateChannelArguments(grpc::ChannelArguments* /*args*/) override {}
54   bool has_sync_methods() const override;
55   bool has_async_methods() const override;
56 
57  private:
58   std::shared_ptr<LoadReporterAsyncServiceImpl> service_;
59 };
60 
61 std::unique_ptr<grpc::ServerBuilderPlugin>
62 CreateLoadReportingServiceServerBuilderPlugin();
63 
64 }  // namespace load_reporter
65 }  // namespace grpc
66 
67 #endif  // GRPC_SRC_CPP_SERVER_LOAD_REPORTER_LOAD_REPORTING_SERVICE_SERVER_BUILDER_PLUGIN_H
68