backoff

package
v1.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package backoff는 공용 exponential backoff helper를 제공합니다.

이 패키지는 호출부가 상태 기반 또는 attempt 기반 exponential backoff 값을 계산할 때 사용할 수 있는 작은 순수 helper를 제공합니다. 실제 sleep, retry loop, context 제어는 호출부 책임으로 둡니다.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeExponentialBackoff

func ComputeExponentialBackoff(attempt int, base, maxInterval, jitter time.Duration) time.Duration

ComputeExponentialBackoff는 attempt 번호를 기반으로 base*2^attempt 지연값을 계산합니다.

func ComputeExponentialBackoffHalfJitter

func ComputeExponentialBackoffHalfJitter(attempt int, base, maxInterval time.Duration) time.Duration

ComputeExponentialBackoffHalfJitter는 base*2^attempt를 maxInterval로 cap한 값(cap)에 대해 [cap/2, cap) 범위의 backoff 값을 반환합니다. cap이 1보다 작거나 같은 극단적 케이스에서는 jitter가 의미 없어 cap 그대로 반환합니다. 분포는 cbgk legacy retryDelay/consumerRetryDelay와 통계적으로 동등합니다 (홀수 cap에서는 본 함수가 상한 1 unit을 추가로 포함해 약간 더 균등하지만 production duration 규모에서는 ±5% 이내).

func NextExponentialBackoff

func NextExponentialBackoff(current, maxInterval, step time.Duration) time.Duration

NextExponentialBackoff는 현재 backoff 값을 두 배로 늘리고 step과 maxInterval 경계를 적용합니다.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL