Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

FIX (slack): Add request timeout for 30 seconds

Rostislav Dugind521e2abc62f
diff --git a/backend/internal/features/notifiers/models/slack/model.go b/backend/internal/features/notifiers/models/slack/model.go
index fb38efa4..5849306f 100644
--- a/backend/internal/features/notifiers/models/slack/model.go
+++ b/backend/internal/features/notifiers/models/slack/model.go
@@ -70,6 +70,7 @@ func (s *SlackNotifier) Send(
maxAttempts = 5
defaultBackoff = 2 * time.Second // when Retry-After header missing
backoffMultiplier = 1.5 // use exponential growth
+ requestTimeout = 30 * time.Second
)
var (
@@ -77,6 +78,10 @@ func (s *SlackNotifier) Send(
attempts = 0
)
+ client := &http.Client{
+ Timeout: requestTimeout,
+ }
+
for {
attempts++
@@ -92,7 +97,7 @@ func (s *SlackNotifier) Send(
req.Header.Set("Content-Type", "application/json; charset=utf-8")
req.Header.Set("Authorization", "Bearer "+botToken)
- resp, err := http.DefaultClient.Do(req)
+ resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("send slack message: %w", err)
}