Skip to content

Commit

Permalink
fix: division by zero for PoolHandler (fixing #14) (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
samber authored Oct 27, 2024
1 parent 8b65932 commit 70ba5dd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func (h *PoolHandler) Enabled(ctx context.Context, l slog.Level) bool {

// Implements slog.Handler
func (h *PoolHandler) Handle(ctx context.Context, r slog.Record) error {
if len(h.handlers) == 0 {
return nil
}

// round robin
rand := h.randSource.Int63() % int64(len(h.handlers))
handlers := append(h.handlers[rand:], h.handlers[:rand]...)
Expand Down

0 comments on commit 70ba5dd

Please sign in to comment.