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 GRPCPP_EXT_SERVER_LOAD_REPORTING_H
20 #define GRPCPP_EXT_SERVER_LOAD_REPORTING_H
21 
22 #include <grpc/support/port_platform.h>
23 
24 #include <grpc/load_reporting.h>
25 #include <grpcpp/impl/codegen/config.h>
26 #include <grpcpp/impl/codegen/server_context.h>
27 #include <grpcpp/impl/server_builder_option.h>
28 
29 namespace grpc {
30 namespace load_reporter {
31 namespace experimental {
32 
33 // The ServerBuilderOption to enable server-side load reporting feature. To
34 // enable the feature, please make sure the binary builds with the
35 // grpcpp_server_load_reporting library and set this option in the
36 // ServerBuilder.
37 class LoadReportingServiceServerBuilderOption : public ServerBuilderOption {
38  public:
39   void UpdateArguments(::grpc::ChannelArguments* args) override;
40   void UpdatePlugins(std::vector<std::unique_ptr<::grpc::ServerBuilderPlugin>>*
41                          plugins) override;
42 };
43 
44 // Adds the load reporting cost with \a cost_name and \a cost_value in the
45 // trailing metadata of the server context.
46 void AddLoadReportingCost(grpc::ServerContext* ctx,
47                           const grpc::string& cost_name, double cost_value);
48 
49 }  // namespace experimental
50 }  // namespace load_reporter
51 }  // namespace grpc
52 
53 #endif  // GRPCPP_EXT_SERVER_LOAD_REPORTING_H
54