lab5: очередь RabbitMQ, outbox, worker, варианты, fault-injection

This commit is contained in:
2026-11-09 17:34:10 +03:00
parent 276dbdad8a
commit 5f4b10ac2b
96 changed files with 10573 additions and 1 deletions
@@ -0,0 +1,18 @@
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))
})
}
}