schedule,shared: move concurrency 429 limits into scheduler code (#849)
- make concurrency limiting the scheduler.Scheduler's responsibility - eliminate the separate concurrency limit middleware - move concurrencyLimit logic into scheduler.FIFO to maintain backwards compatibility - add HTTPError from #834 Updates #834
This commit is contained in:
@@ -37,6 +37,16 @@ var (
|
||||
)
|
||||
|
||||
func SendError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
var httpErr HTTPError
|
||||
if errors.As(err, &httpErr) {
|
||||
for k, v := range httpErr.Header() {
|
||||
w.Header()[k] = v
|
||||
}
|
||||
w.WriteHeader(httpErr.StatusCode())
|
||||
w.Write(httpErr.Body())
|
||||
return
|
||||
}
|
||||
|
||||
switch {
|
||||
case errors.Is(err, ErrNoModelInContext):
|
||||
SendResponse(w, r, http.StatusNotFound, "no model id could be identified")
|
||||
|
||||
Reference in New Issue
Block a user