feat: API replicas over HAProxy (3)

This commit is contained in:
2026-11-06 03:26:54 +03:00
parent de2f63b926
commit ec111aadfb
32 changed files with 396 additions and 147 deletions
+4 -1
View File
@@ -57,7 +57,7 @@ func newStack(t *testing.T, dbURL, redisURL string, ttl time.Duration) *httptest
chats := service.NewChatService(store)
messages := service.NewMessageService(chats, store)
h := handler.New(users, auth, chats, messages, []handler.Pinger{store.Ping, sessions.Ping}, slog.New(slog.DiscardHandler))
srv := httptest.NewServer(router.New(h))
srv := httptest.NewServer(router.New(h, "test"))
t.Cleanup(srv.Close)
return srv
}
@@ -81,6 +81,9 @@ func request(t *testing.T, srv *httptest.Server, method, path, token, body strin
if token != "" {
req.Header.Set("Authorization", "Bearer "+token)
}
if method == http.MethodPost && strings.HasSuffix(path, "/messages") {
req.Header.Set("Idempotency-Key", uuid.New().String())
}
resp, err := srv.Client().Do(req)
if err != nil {
t.Fatal(err)