import random


def get_retry_interval(attempt: int, retry_interval_base: float,
                       retry_interval_cap: float) -> float:
    """Calculate interval before the next retry of an operation put into
    retrying loop.

    :param attempt:             int, attempt number
    :param retry_interval_base: float, lower limit of the retry interval
    :param retry_interval_cap:  float, upper limit of the retry interval

    :return:                    float, retry interval in seconds
    """
    # Implementation of the 'Exponential Backoff' with 'Full Jitter'.
    # Ref: http://www.awsarchitectureblog.com/2015/03/backoff.html
    return random.uniform(
        retry_interval_base,
        min(retry_interval_cap, pow(2, attempt) * retry_interval_base)
    )