Skip to content

Commit

Permalink
fix staticcheck
Browse files Browse the repository at this point in the history
Signed-off-by: Sandor Szücs <[email protected]>
  • Loading branch information
szuecs committed Oct 17, 2023
1 parent f113384 commit 4028656
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions filters/scheduler/fifo.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@ import (
"github.com/zalando/skipper/scheduler"
)

const (
fifoKey string = "fifo"
)

type fifoType int

const (
fifo fifoType = iota + 1
fifoWithBody
)

func (t fifoType) String() string {
switch t {
case fifo:
return filters.FifoName
case fifoWithBody:
return filters.FifoWithBodyName
}
return "unknown"
}

type (
fifoSpec struct {
typ fifoType
Expand All @@ -45,14 +51,8 @@ func NewFifoWithBody() filters.Spec {
}
}

func (f *fifoSpec) Name() string {
switch f.typ {
case fifo:
return filters.FifoName
case fifoWithBody:
return filters.FifoWithBodyName
}
return "unknown"
func (s *fifoSpec) Name() string {
return s.typ.String()
}

// CreateFilter creates a fifoFilter, that will use a semaphore based
Expand Down Expand Up @@ -157,8 +157,8 @@ func (f *fifoFilter) Request(ctx filters.FilterContext) {
}

// ok
pending, _ := ctx.StateBag()[fifoKey].([]func())
ctx.StateBag()[fifoKey] = append(pending, done)
pending, _ := ctx.StateBag()[f.typ.String()].([]func())
ctx.StateBag()[f.typ.String()] = append(pending, done)
}

// Response will decrease the number of inflight requests to release
Expand All @@ -175,7 +175,7 @@ func (f *fifoFilter) Response(ctx filters.FilterContext) {

func (f *fifoFilter) createResponse(ctx filters.FilterContext) func() {
return func() {
pending, ok := ctx.StateBag()[fifoKey].([]func())
pending, ok := ctx.StateBag()[f.typ.String()].([]func())
if !ok {
return
}
Expand All @@ -184,7 +184,7 @@ func (f *fifoFilter) createResponse(ctx filters.FilterContext) func() {
return
}
pending[last]()
ctx.StateBag()[fifoKey] = pending[:last]
ctx.StateBag()[f.typ.String()] = pending[:last]
}
}

Expand Down

0 comments on commit 4028656

Please sign in to comment.