~fi ddlZddlmZmZdZdZGddeZGddeZGd d eZGd d eZ Gd deZ GddeZ GddeZ dZ y)N)ABCabstractmethodgMb?gMb?c0eZdZdZdZededefdZy)AbstractBackoffzBackoff interfacecy)z Reset internal state before an operation. `reset` is called once at the beginning of every call to `Retry.call_with_retry` Nselfs V/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/redis/backoff.pyresetzAbstractBackoff.reset s failuresreturncy)z'Compute backoff in seconds upon failureNrr rs r computezAbstractBackoff.computes r N) __name__ __module__ __qualname____doc__r rintfloatrrr r rr s,     r rc0eZdZdZdeddfdZdedefdZy)ConstantBackoffzConstant backoff upon failurebackoffrNc||_y)z"`backoff`: backoff time in secondsN_backoff)r rs r __init__zConstantBackoff.__init__s  r rc|jSNrrs r rzConstantBackoff.compute"s }}r )rrrrrrrrrr r rrs+'  $ r rc$eZdZdZdfd ZxZS) NoBackoffzNo backoff upon failurec$t|dyNr)superr)r __class__s r rzNoBackoff.__init__)s r rN)rrrrr __classcell__)r's@r r#r#&s!r r#c6eZdZdZeefdedefdZdedefdZ y) ExponentialBackoffz Exponential backoff upon failurecapbasec ||_||_ye `cap`: maximum backoff time in seconds `base`: base backoff time in seconds N_cap_baser r,r-s r rzExponentialBackoff.__init__0   r rrcNt|j|jd|zzS)N)minr2r3rs r rzExponentialBackoff.compute8s 499djj1h;677r N rrrr DEFAULT_CAP DEFAULT_BASErrrrrr r r+r+-s0*$/|Eu888r r+c:eZdZdZeefdededdfdZdedefdZ y) FullJitterBackoffz Full jitter backoff upon failurer,r-rNc ||_||_yr/r1r4s r rzFullJitterBackoff.__init__?r5r rc vtjdt|j|jd|zzS)Nrr7)randomuniformr8r2r3rs r rzFullJitterBackoff.computeGs+~~aTYY Q[0H!IJJr r9rr r r=r=<s;*$/|EuPTKKKr r=c:eZdZdZeefdededdfdZdedefdZ y) EqualJitterBackoffz!Equal jitter backoff upon failurer,r-rNc ||_||_yr/r1r4s r rzEqualJitterBackoff.__init__Nr5r rct|j|jd|zzdz }|tjd|zS)Nr7r)r8r2r3r@rA)r rtemps r rzEqualJitterBackoff.computeVs:499djj1h;67!;fnnQ---r r9rr r rCrCKs8+$/|EuPT...r rCcBeZdZdZeefdededdfdZd dZde defd Z y) DecorrelatedJitterBackoffz(Decorrelated jitter backoff upon failurer,r-rNc.||_||_d|_y)r0rN)r2r3_previous_backoffr4s r rz"DecorrelatedJitterBackoff.__init__^s   !"r cd|_yr%)rJr s r r zDecorrelatedJitterBackoff.resetgs !"r rct|j|jdz}tj|j|}t |j ||_|jS)N)maxr3rJr@rAr8r2)r r max_backoffrFs r rz!DecorrelatedJitterBackoff.computejsP$**d&<&rSsr #   c "o 8 8 K K . . &&, r