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_LOAD_REPORTING_SERVICE_SERVER_BUILDER_PLUGIN_H 20 #define GRPC_SRC_CPP_LOAD_REPORTING_SERVICE_SERVER_BUILDER_PLUGIN_H 21 22 #include <grpc/support/port_platform.h> 23 24 #include <grpcpp/impl/server_builder_plugin.h> 25 26 #include "src/cpp/server/load_reporter/load_reporter_async_service_impl.h" 27 28 namespace grpc { 29 namespace load_reporter { 30 31 // The plugin that registers and starts load reporting service when starting a 32 // server. 33 class LoadReportingServiceServerBuilderPlugin : public ServerBuilderPlugin { 34 public: 35 ~LoadReportingServiceServerBuilderPlugin() override = default; name()36 grpc::string name() override { return "load_reporting_service"; } 37 38 // Creates a load reporting service. 39 void UpdateServerBuilder(grpc::ServerBuilder* builder) override; 40 41 // Registers the load reporter service. 42 void InitServer(grpc::ServerInitializer* si) override; 43 44 // Starts the load reporter service. 45 void Finish(grpc::ServerInitializer* si) override; 46 ChangeArguments(const grpc::string & name,void * value)47 void ChangeArguments(const grpc::string& name, void* value) override {} UpdateChannelArguments(grpc::ChannelArguments * args)48 void UpdateChannelArguments(grpc::ChannelArguments* args) override {} 49 bool has_sync_methods() const override; 50 bool has_async_methods() const override; 51 52 private: 53 std::shared_ptr<LoadReporterAsyncServiceImpl> service_; 54 }; 55 56 std::unique_ptr<grpc::ServerBuilderPlugin> 57 CreateLoadReportingServiceServerBuilderPlugin(); 58 59 } // namespace load_reporter 60 } // namespace grpc 61 62 #endif // GRPC_SRC_CPP_LOAD_REPORTING_SERVICE_SERVER_BUILDER_PLUGIN_H 63