• 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 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
38     : public grpc::ServerBuilderOption {
39  public:
40   void UpdateArguments(::grpc::ChannelArguments* args) override;
41   void UpdatePlugins(std::vector<std::unique_ptr<::grpc::ServerBuilderPlugin>>*
42                          plugins) override;
43 };
44 
45 // Adds the load reporting cost with \a cost_name and \a cost_value in the
46 // trailing metadata of the server context.
47 void AddLoadReportingCost(grpc::ServerContext* ctx,
48                           const std::string& cost_name, double cost_value);
49 
50 }  // namespace experimental
51 }  // namespace load_reporter
52 }  // namespace grpc
53 
54 #endif  // GRPCPP_EXT_SERVER_LOAD_REPORTING_H
55