- X-Instance-Id, обязательный Idempotency-Key (PostgreSQL, одна транзакция) - HAProxy + 2..N реплик API, readiness/drain по SIGTERM, однократные миграции - скрипты stop-one/restore/restart/rolling-update/collect-evidence - трек 1: параметризованный стенд, cmd/bench, оркестратор и анализ - workflow реального прогона Docker-стенда на GitHub Actions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
454 B
Go
19 lines
454 B
Go
package middleware
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// Timeout ограничивает время выполнения запроса.
|
|
func Timeout(d time.Duration) func(http.Handler) http.Handler {
|
|
return func(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
ctx, cancel := context.WithTimeout(r.Context(), d)
|
|
defer cancel()
|
|
next.ServeHTTP(w, r.WithContext(ctx))
|
|
})
|
|
}
|
|
}
|