-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TT-8735, initial commit #6317
base: master
Are you sure you want to change the base?
TT-8735, initial commit #6317
Conversation
API Changes --- prev.txt 2024-06-06 06:35:41.220511284 +0000
+++ current.txt 2024-06-06 06:35:38.200468488 +0000
@@ -1666,81 +1666,6 @@
Value string `bson:"value" json:"value"`
}
-type RateLimitSmoothing struct {
- // Enabled indicates if rate limit smoothing is active.
- Enabled bool `json:"enabled" bson:"enabled"`
-
- // Threshold is the request rate above which smoothing is applied.
- Threshold int64 `json:"threshold" bson:"threshold"`
-
- // Trigger is the step factor determining when smoothing events trigger.
- Trigger float64 `json:"trigger" bson:"trigger"`
-
- // Step is the increment/decrement for adjusting the rate limit.
- Step int64 `json:"step" bson:"step"`
-
- // Delay is the minimum time between rate limit changes (in seconds).
- Delay int64 `json:"delay" bson:"delay"`
-}
- RateLimitSmoothing holds the rate smoothing configuration.
-
- Rate Limit Smoothing is a mechanism to dynamically adjust the request rate
- limits based on the current traffic patterns. It helps in managing request
- spikes by gradually increasing or decreasing the rate limit instead of
- making abrupt changes or blocking requests excessively.
-
- Once the rate limit smoothing triggers an allowance change, one of the
- following events is emitted:
-
- - `RateLimitSmoothingUp` when the allowance increases -
- `RateLimitSmoothingDown` when the allowance decreases
-
- Events are emitted based on the configuration:
-
- - `enabled` (boolean) to enable or disable rate limit smoothing -
- `threshold` after which to apply smoothing (minimum rate for window) -
- `trigger` configures at which fraction of a step a smoothing event is
- emitted - `step` is the value by which the rate allowance will get adjusted
- - `delay` is the amount of seconds between smoothing updates
-
- This is used to compute a request allowance. The request allowance will
- be smoothed between `threshold`, and the defined rate limits (maximum).
- The request allowance will be updated internally every `delay` seconds.
-
- The `step * trigger` value is substracted from the request allowance, and
- if your request rate goes above that, then a RateLimitSmoothingUp event is
- emitted and the allowance is increased by `step`. A RateLimitSmoothingDown
- event is emitted when the request rate drops one step below that, and the
- allowance then decreases by step.
-
- For any allowance, events are emitted based on the following calculations:
-
- - When the request rate rises above `allowance - (step * trigger)`, a
- RateLimitSmoothingUp event is emitted and allowance increases by `step`.
- - When the request rate falls below `allowance - (step + step * trigger)`,
- a RateLimitSmoothingDown event is emitted and allowance decreases by
- `step`.
-
- Example: Allowance: 600, Current rate: 500, Step: 100, Trigger: 0.5
-
- - To trigger a RateLimitSmoothingUp event, the request rate must exceed:
- Allowance - (Step * Trigger) Calculation: 600 - (100 * 0.5) = 550
- Exceeding a request rate of 550 will increase the allowance to 700
- (Allowance + Step).
-
- - To trigger a RateLimitSmoothingDown event, the request rate must fall
- below: Allowance - (Step + (Step * Trigger)) Calculation: 600 - (100
- + (100 * 0.5)) = 450 As the request rate falls below 450, that will
- decrease the allowance to 500 (Allowance - Step).
-
-func (r *RateLimitSmoothing) Err() error
- Err checks the rate limit smoothing configuration for validity and returns
- an error if it is not valid. It checks for a nil value, the enabled flag and
- valid values for each setting.
-
-func (r *RateLimitSmoothing) Valid() bool
- Valid will return true if the rate limit smoothing should be applied.
-
type RequestHeadersRewriteConfig struct {
Value string `json:"value" bson:"value"`
Remove bool `json:"remove" bson:"remove"`
@@ -5929,10 +5854,6 @@
// The standard rate limiter offers similar performance as the sentinel-based limiter. This is disabled by default.
EnableSentinelRateLimiter bool `json:"enable_sentinel_rate_limiter"`
- // EnableRateLimitSmoothing enables or disables rate smoothing. The rate smoothing is only supported on the
- // Redis Rate Limiter, or the Sentinel Rate Limiter, as both algorithms implement a sliding log.
- EnableRateLimitSmoothing bool `json:"enable_rate_limit_smoothing"`
-
// An enhancement for the Redis and Sentinel rate limiters, that offers a significant improvement in performance by not using transactions on Redis rate-limit buckets.
EnableNonTransactionalRateLimiter bool `json:"enable_non_transactional_rate_limiter"`
@@ -6831,7 +6752,6 @@
const (
SessionData Key = iota
- // Deprecated: UpdateSession was used to trigger a session update, use *SessionData.Touch instead.
UpdateSession
AuthToken
HashedAuthToken
@@ -7101,8 +7021,9 @@
const (
// EventQuotaExceeded is an alias maintained for backwards compatibility.
EventQuotaExceeded = event.QuotaExceeded
- // RateLimitExceeded is an alias maintained for backwards compatibility.
+ // EventRateLimitExceeded is an alias maintained for backwards compatibility.
EventRateLimitExceeded = event.RateLimitExceeded
+
// EventAuthFailure is an alias maintained for backwards compatibility.
EventAuthFailure = event.AuthFailure
// EventKeyExpired is an alias maintained for backwards compatibility.
@@ -7333,7 +7254,7 @@
EnsureTransport sanitizes host/protocol pairs and returns a valid URL.
func GenerateTestBinaryData() (buf *bytes.Buffer)
-func GetAccessDefinitionByAPIIDOrSession(session *user.SessionState, api *APISpec) (accessDef *user.AccessDefinition, allowanceScope string, err error)
+func GetAccessDefinitionByAPIIDOrSession(currentSession *user.SessionState, api *APISpec) (accessDef *user.AccessDefinition, allowanceScope string, err error)
func GetTLSClient(cert *tls.Certificate, caCert []byte) *http.Client
func GetTLSConfig(cert *tls.Certificate, caCert []byte) *tls.Config
func InitTestMain(ctx context.Context, m *testing.M) int
@@ -9802,12 +9723,12 @@
func (l *SessionLimiter) Context() context.Context
-func (l *SessionLimiter) ForwardMessage(r *http.Request, session *user.SessionState, rateLimitKey string, quotaKey string, store storage.Handler, enableRL, enableQ bool, api *APISpec, dryRun bool) sessionFailReason
+func (l *SessionLimiter) ForwardMessage(r *http.Request, currentSession *user.SessionState, rateLimitKey string, quotaKey string, store storage.Handler, enableRL, enableQ bool, api *APISpec, dryRun bool) sessionFailReason
ForwardMessage will enforce rate limiting, returning a non-zero
sessionFailReason if session limits have been exceeded. Key values to manage
rate are Rate and Per, e.g. Rate of 10 messages Per 10 seconds
-func (l *SessionLimiter) RedisQuotaExceeded(r *http.Request, session *user.SessionState, quotaKey, scope string, limit *user.APILimit, store storage.Handler, hashKeys bool) bool
+func (l *SessionLimiter) RedisQuotaExceeded(r *http.Request, currentSession *user.SessionState, quotaKey, scope string, limit *user.APILimit, store storage.Handler, hashKeys bool) bool
type SlaveDataCenter struct {
SlaveOptions config.SlaveOptionsConfig
@@ -9871,7 +9792,7 @@
SuccessHandler represents the final ServeHTTP() request for a proxied API
request
-func (s *SuccessHandler) RecordHit(r *http.Request, timing analytics.Latency, code int, responseCopy *http.Response, cached bool)
+func (s *SuccessHandler) RecordHit(r *http.Request, timing analytics.Latency, code int, responseCopy *http.Response)
func (s *SuccessHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) *http.Response
ServeHTTP will store the request details in the analytics store if necessary
@@ -11999,22 +11920,11 @@
QuotaRemaining int64 `json:"quota_remaining" msg:"quota_remaining"`
QuotaRenewalRate int64 `json:"quota_renewal_rate" msg:"quota_renewal_rate"`
SetBy string `json:"-" msg:"-"`
-
- // Smoothing contains rate limit smoothing settings.
- Smoothing *apidef.RateLimitSmoothing `json:"smoothing" bson:"smoothing"`
}
APILimit stores quota and rate limit on ACL level (per API)
-func (g *APILimit) Duration() time.Duration
- Duration returns the time between two allowed requests at the defined rate.
- It's used to decide which rate limit has a bigger allowance.
-
func (limit APILimit) IsEmpty() bool
-func (g *APILimit) Less(in APILimit) bool
- Less will return true if the receiver has a smaller duration between
- requests than `in`.
-
type AccessDefinition struct {
APIName string `json:"api_name" msg:"api_name"`
APIID string `json:"api_id" msg:"api_id"`
@@ -12090,14 +12000,9 @@
LastUpdated string `bson:"last_updated" json:"last_updated"`
MetaData map[string]interface{} `bson:"meta_data" json:"meta_data"`
GraphQL map[string]GraphAccessDefinition `bson:"graphql_access_rights" json:"graphql_access_rights"`
-
- // Smoothing contains rate limit smoothing settings.
- Smoothing *apidef.RateLimitSmoothing `json:"smoothing" bson:"smoothing"`
}
Policy represents a user policy swagger:model
-func (p *Policy) APILimit() APILimit
-
type PolicyPartitions struct {
Quota bool `bson:"quota" json:"quota"`
RateLimit bool `bson:"rate_limit" json:"rate_limit"`
@@ -12148,10 +12053,6 @@
SessionLifetime int64 `bson:"session_lifetime" json:"session_lifetime"`
KeyID string `json:"-"`
-
- // Smoothing contains rate limit smoothing settings.
- Smoothing *apidef.RateLimitSmoothing `json:"smoothing" bson:"smoothing"`
-
// Has unexported fields.
}
SessionState objects represent a current API session, mainly used
@@ -12164,9 +12065,6 @@
func NewSessionState() *SessionState
-func (s *SessionState) APILimit() APILimit
- APILimit returns an user.APILimit from the session data.
-
func (s SessionState) Clone() SessionState
Clone returns a fresh copy of s
@@ -12179,10 +12077,6 @@
func (s *SessionState) IsBasicAuth() bool
IsBasicAuth returns whether the key is basic auth or not.
-func (s *SessionState) IsModified() bool
- IsModified will return true if session has been modified to trigger an
- update.
-
func (s *SessionState) KeyHash() string
func (s *SessionState) KeyHashEmpty() bool
@@ -12206,9 +12100,6 @@
For backwards compatibility reasons, this falls back to ApplyPolicyID if
ApplyPolicies is empty.
-func (s *SessionState) Reset()
- Reset marks the session as not modified, skipping related updates.
-
func (s *SessionState) SetCustomPolicies(list []Policy)
func (s *SessionState) SetKeyHash(hash string)
@@ -12218,6 +12109,3 @@
func (s *SessionState) TagsFromMetadata(data map[string]interface{}) (updateSession bool)
TagsFromMetadata updates the session state with the tags from the metadata.
-func (s *SessionState) Touch()
- Touch marks the session as modified, indicating that it should be updated.
- |
…tually uses last built image instead of running release tests separately for each case
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Please retry analysis of this Pull-Request directly on SonarCloud |
… on plugin compiler as build step is not done
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Description
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist