LCOV - code coverage report
Current view: top level - envoy/router - router_ratelimit.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 2 3 66.7 %
Date: 2024-01-05 06:35:25 Functions: 2 3 66.7 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <cstdint>
       4             : #include <memory>
       5             : #include <string>
       6             : #include <vector>
       7             : 
       8             : #include "envoy/config/core/v3/base.pb.h"
       9             : #include "envoy/http/filter.h"
      10             : #include "envoy/ratelimit/ratelimit.h"
      11             : 
      12             : namespace Envoy {
      13             : namespace Router {
      14             : 
      15             : /**
      16             :  * Base interface for generic rate limit override action.
      17             :  */
      18             : class RateLimitOverrideAction {
      19             : public:
      20           0 :   virtual ~RateLimitOverrideAction() = default;
      21             : 
      22             :   /**
      23             :    * Potentially populate the descriptors 'limit' property with a RateLimitOverride instance
      24             :    * @param descriptor supplies the descriptor to optionally fill.
      25             :    * @param metadata supplies the dynamic metadata for the request.
      26             :    * @return true if RateLimitOverride was set in the descriptor.
      27             :    */
      28             :   virtual bool populateOverride(RateLimit::Descriptor& descriptor,
      29             :                                 const envoy::config::core::v3::Metadata* metadata) const PURE;
      30             : };
      31             : 
      32             : using RateLimitOverrideActionPtr = std::unique_ptr<RateLimitOverrideAction>;
      33             : 
      34             : /**
      35             :  * Rate limit configuration.
      36             :  */
      37             : class RateLimitPolicyEntry {
      38             : public:
      39           4 :   virtual ~RateLimitPolicyEntry() = default;
      40             : 
      41             :   /**
      42             :    * @return the stage value that the configuration is applicable to.
      43             :    */
      44             :   virtual uint64_t stage() const PURE;
      45             : 
      46             :   /**
      47             :    * @return runtime key to be set to disable the configuration.
      48             :    */
      49             :   virtual const std::string& disableKey() const PURE;
      50             : 
      51             :   /**
      52             :    * Potentially populate the descriptor array with new descriptors to query.
      53             :    * @param descriptors supplies the descriptor array to optionally fill.
      54             :    * @param local_service_cluster supplies the name of the local service cluster.
      55             :    * @param headers supplies the header for the request.
      56             :    * @param info stream info associated with the request
      57             :    */
      58             :   virtual void populateDescriptors(std::vector<RateLimit::Descriptor>& descriptors,
      59             :                                    const std::string& local_service_cluster,
      60             :                                    const Http::RequestHeaderMap& headers,
      61             :                                    const StreamInfo::StreamInfo& info) const PURE;
      62             : 
      63             :   /**
      64             :    * Potentially populate the local descriptor array with new descriptors to query.
      65             :    * @param descriptors supplies the descriptor array to optionally fill.
      66             :    * @param local_service_cluster supplies the name of the local service cluster.
      67             :    * @param headers supplies the header for the request.
      68             :    * @param info stream info associated with the request
      69             :    */
      70             :   virtual void populateLocalDescriptors(std::vector<RateLimit::LocalDescriptor>& descriptors,
      71             :                                         const std::string& local_service_cluster,
      72             :                                         const Http::RequestHeaderMap& headers,
      73             :                                         const StreamInfo::StreamInfo& info) const PURE;
      74             : };
      75             : 
      76             : /**
      77             :  * Rate limiting policy.
      78             :  */
      79             : class RateLimitPolicy {
      80             : public:
      81         206 :   virtual ~RateLimitPolicy() = default;
      82             : 
      83             :   /**
      84             :    * @return true if there is no rate limit policy for all stage settings.
      85             :    */
      86             :   virtual bool empty() const PURE;
      87             : 
      88             :   /**
      89             :    * @param stage the value for finding applicable rate limit configurations.
      90             :    * @return set of RateLimitPolicyEntry that are applicable for a stage.
      91             :    */
      92             :   virtual const std::vector<std::reference_wrapper<const RateLimitPolicyEntry>>&
      93             :   getApplicableRateLimit(uint64_t stage) const PURE;
      94             : };
      95             : 
      96             : } // namespace Router
      97             : } // namespace Envoy

Generated by: LCOV version 1.15