server_load_reporting.h 1.8 KB

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