summaryrefslogtreecommitdiff
path: root/src/rpc/envoy.service.ratelimit.v2.rs
blob: f04b68a8277411311c085810a90e26a37493ca2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// @generated
// This file is @generated by prost-build.
/// Main message for a rate limit request. The rate limit service is designed to be fully generic
/// in the sense that it can operate on arbitrary hierarchical key/value pairs. The loaded
/// configuration will parse the request and find the most specific limit to apply. In addition,
/// a RateLimitRequest can contain multiple "descriptors" to limit on. When multiple descriptors
/// are provided, the server will limit on *ALL* of them and return an OVER_LIMIT response if any
/// of them are over limit. This enables more complex application level rate limiting scenarios
/// if desired.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RateLimitRequest {
    /// All rate limit requests must specify a domain. This enables the configuration to be per
    /// application without fear of overlap. E.g., "envoy".
    #[prost(string, tag="1")]
    pub domain: ::prost::alloc::string::String,
    /// All rate limit requests must specify at least one RateLimitDescriptor. Each descriptor is
    /// processed by the service (see below). If any of the descriptors are over limit, the entire
    /// request is considered to be over limit.
    #[prost(message, repeated, tag="2")]
    pub descriptors: ::prost::alloc::vec::Vec<super::super::super::api::v2::ratelimit::RateLimitDescriptor>,
    /// Rate limit requests can optionally specify the number of hits a request adds to the matched
    /// limit. If the value is not set in the message, a request increases the matched limit by 1.
    #[prost(uint32, tag="3")]
    pub hits_addend: u32,
}
/// A response from a ShouldRateLimit call.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RateLimitResponse {
    /// The overall response code which takes into account all of the descriptors that were passed
    /// in the RateLimitRequest message.
    #[prost(enumeration="rate_limit_response::Code", tag="1")]
    pub overall_code: i32,
    /// A list of DescriptorStatus messages which matches the length of the descriptor list passed
    /// in the RateLimitRequest. This can be used by the caller to determine which individual
    /// descriptors failed and/or what the currently configured limits are for all of them.
    #[prost(message, repeated, tag="2")]
    pub statuses: ::prost::alloc::vec::Vec<rate_limit_response::DescriptorStatus>,
    /// A list of headers to add to the response
    #[prost(message, repeated, tag="3")]
    pub headers: ::prost::alloc::vec::Vec<super::super::super::api::v2::core::HeaderValue>,
    /// A list of headers to add to the request when forwarded
    #[prost(message, repeated, tag="4")]
    pub request_headers_to_add: ::prost::alloc::vec::Vec<super::super::super::api::v2::core::HeaderValue>,
}
/// Nested message and enum types in `RateLimitResponse`.
pub mod rate_limit_response {
    /// Defines an actual rate limit in terms of requests per unit of time and the unit itself.
    #[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
    pub struct RateLimit {
        /// A name or description of this limit.
        #[prost(string, tag="3")]
        pub name: ::prost::alloc::string::String,
        /// The number of requests per unit of time.
        #[prost(uint32, tag="1")]
        pub requests_per_unit: u32,
        /// The unit of time.
        #[prost(enumeration="rate_limit::Unit", tag="2")]
        pub unit: i32,
    }
    /// Nested message and enum types in `RateLimit`.
    pub mod rate_limit {
        #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
        #[repr(i32)]
        pub enum Unit {
            /// The time unit is not known.
            Unknown = 0,
            /// The time unit representing a second.
            Second = 1,
            /// The time unit representing a minute.
            Minute = 2,
            /// The time unit representing an hour.
            Hour = 3,
            /// The time unit representing a day.
            Day = 4,
        }
        impl Unit {
            /// String value of the enum field names used in the ProtoBuf definition.
            ///
            /// The values are not transformed in any way and thus are considered stable
            /// (if the ProtoBuf definition does not change) and safe for programmatic use.
            pub fn as_str_name(&self) -> &'static str {
                match self {
                    Unit::Unknown => "UNKNOWN",
                    Unit::Second => "SECOND",
                    Unit::Minute => "MINUTE",
                    Unit::Hour => "HOUR",
                    Unit::Day => "DAY",
                }
            }
            /// Creates an enum from field names used in the ProtoBuf definition.
            pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
                match value {
                    "UNKNOWN" => Some(Self::Unknown),
                    "SECOND" => Some(Self::Second),
                    "MINUTE" => Some(Self::Minute),
                    "HOUR" => Some(Self::Hour),
                    "DAY" => Some(Self::Day),
                    _ => None,
                }
            }
        }
    }
    #[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
    pub struct DescriptorStatus {
        /// The response code for an individual descriptor.
        #[prost(enumeration="Code", tag="1")]
        pub code: i32,
        /// The current limit as configured by the server. Useful for debugging, etc.
        #[prost(message, optional, tag="2")]
        pub current_limit: ::core::option::Option<RateLimit>,
        /// The limit remaining in the current time unit.
        #[prost(uint32, tag="3")]
        pub limit_remaining: u32,
    }
    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
    #[repr(i32)]
    pub enum Code {
        /// The response code is not known.
        Unknown = 0,
        /// The response code to notify that the number of requests are under limit.
        Ok = 1,
        /// The response code to notify that the number of requests are over limit.
        OverLimit = 2,
    }
    impl Code {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Code::Unknown => "UNKNOWN",
                Code::Ok => "OK",
                Code::OverLimit => "OVER_LIMIT",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "UNKNOWN" => Some(Self::Unknown),
                "OK" => Some(Self::Ok),
                "OVER_LIMIT" => Some(Self::OverLimit),
                _ => None,
            }
        }
    }
}
include!("envoy.service.ratelimit.v2.tonic.rs");
// @@protoc_insertion_point(module)