Skip to content

Commit

Permalink
feature: remove data from shedders by downstream shedders
Browse files Browse the repository at this point in the history
Signed-off-by: Sandor Szücs <[email protected]>
  • Loading branch information
szuecs committed Jun 29, 2023
1 parent 969bccd commit 25d20a7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions filters/shedder/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ func (m mode) String() string {
}

const (
counterPrefix = "shedder.admission_control."
admissionControlSpanName = "admission_control"
admissionControlKey = "shedder:admission_control"
admissionControlValue = "reject"
minWindowSize = 1
maxWindowSize = 100
counterPrefix = "shedder.admission_control."
admissionControlSpanName = "admission_control"
admissionSignalHeaderKey = "Admission-Control"
admissionSignalHeaderValue = "true"
admissionControlKey = "shedder:admission_control"
admissionControlValue = "reject"
minWindowSize = 1
maxWindowSize = 100
)

type Options struct {
Expand Down Expand Up @@ -422,7 +424,11 @@ func (ac *admissionControl) Request(ctx filters.FilterContext) {
if ac.mode != active {
return
}

header := make(http.Header)
header.Set(admissionSignalHeaderKey, admissionSignalHeaderValue)
ctx.Serve(&http.Response{
Header: header,
StatusCode: http.StatusServiceUnavailable,
})
}
Expand All @@ -433,6 +439,9 @@ func (ac *admissionControl) Response(ctx filters.FilterContext) {
if ctx.StateBag()[admissionControlKey] == admissionControlValue {
return
}
if ctx.Response().Header.Get(admissionControlKey) != "" {
return
}

if ctx.Response().StatusCode < 499 {
ac.successCounter.Add(1)
Expand Down

0 comments on commit 25d20a7

Please sign in to comment.