refactor(notif): enhance retry mechanism with exponential backoff and jitter; replace retry channel with a set for managing retry messages

This commit is contained in:
yusing
2025-06-14 09:31:09 +08:00
parent 96b7c3fcec
commit 4abf61a421
3 changed files with 125 additions and 58 deletions

View File

@@ -8,7 +8,6 @@ import (
"net/http"
"time"
"github.com/rs/zerolog/log"
"github.com/yusing/go-proxy/internal/gperr"
"github.com/yusing/go-proxy/internal/serialization"
)
@@ -72,13 +71,6 @@ func (msg *LogMessage) notify(ctx context.Context, provider Provider) error {
switch resp.StatusCode {
case http.StatusOK, http.StatusCreated, http.StatusAccepted, http.StatusNoContent:
body, _ := io.ReadAll(resp.Body)
log.Debug().
Str("provider", provider.GetName()).
Str("url", provider.GetURL()).
Str("status", resp.Status).
RawJSON("resp_body", body).
Msg("notification sent")
return nil
default:
return fmt.Errorf("http status %d: %w", resp.StatusCode, provider.fmtError(resp.Body))