Source File
loadshedding.go
Belonging Package
golang.org/x/pkgsite/internal/fetch
package fetch
import (
)
mu sync.Mutex
sizeInFlight uint64 // size of requests currently in progress.
requestsInFlight int // number of request currently in progress
requestsTotal int // total fetch requests ever seen
requestsShed int // number of requests that were shedded
}
if .sizeInFlight > 0 && .sizeInFlight+ > .maxSizeInFlight {
.requestsShed++
return true, func() {}
}
.sizeInFlight +=
.requestsInFlight++
return false, func() {
.mu.Lock()
defer .mu.Unlock()
.sizeInFlight -=
.requestsInFlight--
}
}
type LoadShedStats struct {
SizeInFlight uint64
MaxSizeInFlight uint64
RequestsInFlight int
RequestsShed int
RequestsTotal int
}
func ( *loadShedder) () LoadShedStats {
.mu.Lock()
defer .mu.Unlock()
return LoadShedStats{
RequestsInFlight: .requestsInFlight,
SizeInFlight: .sizeInFlight,
MaxSizeInFlight: .maxSizeInFlight,
RequestsShed: .requestsShed,
RequestsTotal: .requestsTotal,
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |