Migrate logging to go-mana-component; delete logging/ package
Replaces the flat key-value logging scheme with component-based structured logging via go-mana-component. Each layer (pool, worker, connection) builds its own component identity and derives a *slog.Logger from a caller-supplied slog.Handler. - Delete logging/ package (logging.go, logging_test.go) - Strip LoggingEnabled and LogLevel from ConnectionConfig, PoolConfig, WorkerConfig; remove associated option funcs - Change NewConnection and NewConnectionFromSocket to accept ctx and slog.Handler instead of *slog.Logger; constructors build component identity via MustNew/MustExtend internally - Change WorkerFactory, NewWorker, connect, and RunDialer to carry slog.Handler; remove PoolPlugin.Handler - Change NewPool to establish pool component identity via MustNew; remove pool_id field, PoolPlugin.ID, and ErrInvalidPoolID - Fix data race in MockSlogHandler: WithAttrs now shares parent mutex pointer rather than allocating a new one per child - Run go fix
This commit is contained in:
+4
-10
@@ -59,22 +59,16 @@ func (r *RetryManager) CalculateDelay() time.Duration {
|
||||
}
|
||||
|
||||
// Exponential backoff: InitialDelay * 2^(attempts-1)
|
||||
shift := r.retryCount - 1
|
||||
if shift > 62 {
|
||||
shift = 62
|
||||
} // prevent overflow
|
||||
shift := min(r.retryCount-1, 62) // prevent overflow
|
||||
backoffMultiplier := float64(int64(1) << shift)
|
||||
baseDelay := float64(r.config.InitialDelay) * backoffMultiplier
|
||||
|
||||
// Apply jitter: delay * (1 + jitterFactor * (random - 0.5))
|
||||
random := rand.Float64()
|
||||
jitterMultiplier := 1 + r.config.JitterFactor*(random-0.5)
|
||||
delay := time.Duration(baseDelay * jitterMultiplier)
|
||||
|
||||
// Cap at MaxDelay
|
||||
if delay > r.config.MaxDelay {
|
||||
delay = r.config.MaxDelay
|
||||
}
|
||||
delay := min(
|
||||
// Cap at MaxDelay
|
||||
time.Duration(baseDelay*jitterMultiplier), r.config.MaxDelay)
|
||||
|
||||
return delay
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user