xref: /aosp_15_r20/external/grpc-grpc/include/grpcpp/ext/server_load_reporting.h (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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/load_reporting.h>
23 #include <grpc/support/port_platform.h>
24 #include <grpcpp/impl/server_builder_option.h>
25 #include <grpcpp/server_context.h>
26 #include <grpcpp/support/config.h>
27 
28 namespace grpc {
29 namespace load_reporter {
30 namespace experimental {
31 
32 // The ServerBuilderOption to enable server-side load reporting feature. To
33 // enable the feature, please make sure the binary builds with the
34 // grpcpp_server_load_reporting library and set this option in the
35 // ServerBuilder.
36 class LoadReportingServiceServerBuilderOption
37     : public grpc::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 std::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