3 * Copyright 2018 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <grpc/support/port_platform.h>
21 #include "src/cpp/server/load_reporter/load_reporting_service_server_builder_plugin.h"
23 #include <grpcpp/impl/server_initializer.h>
26 namespace load_reporter {
28 bool LoadReportingServiceServerBuilderPlugin::has_sync_methods() const {
29 if (service_ != nullptr) {
30 return service_->has_synchronous_methods();
35 bool LoadReportingServiceServerBuilderPlugin::has_async_methods() const {
36 if (service_ != nullptr) {
37 return service_->has_async_methods();
42 void LoadReportingServiceServerBuilderPlugin::UpdateServerBuilder(
43 grpc::ServerBuilder* builder) {
44 auto cq = builder->AddCompletionQueue();
45 service_ = std::make_shared<LoadReporterAsyncServiceImpl>(std::move(cq));
48 void LoadReportingServiceServerBuilderPlugin::InitServer(
49 grpc::ServerInitializer* si) {
50 si->RegisterService(service_);
53 void LoadReportingServiceServerBuilderPlugin::Finish(
54 grpc::ServerInitializer* /*si*/) {
55 service_->StartThread();
59 } // namespace load_reporter