123456789_123456789_123456789_123456789_123456789_

Module: Mongo::Retryable::Backpressure Private

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: lib/mongo/retryable/backpressure.rb

Overview

Constants and helpers for client backpressure (exponential backoff and jitter in retry loops).

Since:

  • 2.1.0

Constant Summary

Class Method Summary

Class Method Details

.backoff_delay(attempt, jitter: rand) ⇒ Float

Calculate the backoff delay for a given retry attempt.

Parameters:

  • attempt (Integer)

    The retry attempt number (1-indexed).

  • jitter (Float)

    A random float in [0.0, 1.0). Defaults to a random value. Can be injected for deterministic testing.

Returns:

  • (Float)

    The backoff delay in seconds.

Since:

  • 2.1.0

[ GitHub ]

  
# File 'lib/mongo/retryable/backpressure.rb', line 32

def self.backoff_delay(attempt, jitter: rand)
  jitter * [ MAX_BACKOFF, BASE_BACKOFF * (2**(attempt - 1)) ].min
end