ratelimit.proto 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. syntax = "proto3";
  2. package envoy.extensions.common.ratelimit.v3;
  3. import "envoy/type/v3/ratelimit_unit.proto";
  4. import "envoy/type/v3/token_bucket.proto";
  5. import "udpa/annotations/status.proto";
  6. import "udpa/annotations/versioning.proto";
  7. import "validate/validate.proto";
  8. option java_package = "io.envoyproxy.envoy.extensions.common.ratelimit.v3";
  9. option java_outer_classname = "RatelimitProto";
  10. option java_multiple_files = true;
  11. option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/common/ratelimit/v3;ratelimitv3";
  12. option (udpa.annotations.file_status).package_version_status = ACTIVE;
  13. // [#protodoc-title: Common rate limit components]
  14. // A RateLimitDescriptor is a list of hierarchical entries that are used by the service to
  15. // determine the final rate limit key and overall allowed limit. Here are some examples of how
  16. // they might be used for the domain "envoy".
  17. //
  18. // .. code-block:: cpp
  19. //
  20. // ["authenticated": "false"], ["remote_address": "10.0.0.1"]
  21. //
  22. // What it does: Limits all unauthenticated traffic for the IP address 10.0.0.1. The
  23. // configuration supplies a default limit for the *remote_address* key. If there is a desire to
  24. // raise the limit for 10.0.0.1 or block it entirely it can be specified directly in the
  25. // configuration.
  26. //
  27. // .. code-block:: cpp
  28. //
  29. // ["authenticated": "false"], ["path": "/foo/bar"]
  30. //
  31. // What it does: Limits all unauthenticated traffic globally for a specific path (or prefix if
  32. // configured that way in the service).
  33. //
  34. // .. code-block:: cpp
  35. //
  36. // ["authenticated": "false"], ["path": "/foo/bar"], ["remote_address": "10.0.0.1"]
  37. //
  38. // What it does: Limits unauthenticated traffic to a specific path for a specific IP address.
  39. // Like (1) we can raise/block specific IP addresses if we want with an override configuration.
  40. //
  41. // .. code-block:: cpp
  42. //
  43. // ["authenticated": "true"], ["client_id": "foo"]
  44. //
  45. // What it does: Limits all traffic for an authenticated client "foo"
  46. //
  47. // .. code-block:: cpp
  48. //
  49. // ["authenticated": "true"], ["client_id": "foo"], ["path": "/foo/bar"]
  50. //
  51. // What it does: Limits traffic to a specific path for an authenticated client "foo"
  52. //
  53. // The idea behind the API is that (1)/(2)/(3) and (4)/(5) can be sent in 1 request if desired.
  54. // This enables building complex application scenarios with a generic backend.
  55. //
  56. // Optionally the descriptor can contain a limit override under a "limit" key, that specifies
  57. // the number of requests per unit to use instead of the number configured in the
  58. // rate limiting service.
  59. message RateLimitDescriptor {
  60. option (udpa.annotations.versioning).previous_message_type =
  61. "envoy.api.v2.ratelimit.RateLimitDescriptor";
  62. message Entry {
  63. option (udpa.annotations.versioning).previous_message_type =
  64. "envoy.api.v2.ratelimit.RateLimitDescriptor.Entry";
  65. // Descriptor key.
  66. string key = 1 [(validate.rules).string = {min_len: 1}];
  67. // Descriptor value.
  68. string value = 2 [(validate.rules).string = {min_len: 1}];
  69. }
  70. // Override rate limit to apply to this descriptor instead of the limit
  71. // configured in the rate limit service. See :ref:`rate limit override
  72. // <config_http_filters_rate_limit_rate_limit_override>` for more information.
  73. message RateLimitOverride {
  74. // The number of requests per unit of time.
  75. uint32 requests_per_unit = 1;
  76. // The unit of time.
  77. type.v3.RateLimitUnit unit = 2 [(validate.rules).enum = {defined_only: true}];
  78. }
  79. // Descriptor entries.
  80. repeated Entry entries = 1 [(validate.rules).repeated = {min_items: 1}];
  81. // Optional rate limit override to supply to the ratelimit service.
  82. RateLimitOverride limit = 2;
  83. }
  84. message LocalRateLimitDescriptor {
  85. // Descriptor entries.
  86. repeated v3.RateLimitDescriptor.Entry entries = 1 [(validate.rules).repeated = {min_items: 1}];
  87. // Token Bucket algorithm for local ratelimiting.
  88. type.v3.TokenBucket token_bucket = 2 [(validate.rules).message = {required: true}];
  89. }