Documentation
¶
Overview ¶
Package utils holds small helpers shared across flakehunter's packages.
Index ¶
- func CollapseBlankLines(s string) string
- func Do(ctx context.Context, cfg RetryConfig, fn func(attempt int) error) error
- func IsRetryable(err error) bool
- func LastLines(s string, n int) []string
- func ShortHash(parts ...string) string
- func TruncateRunes(s string, max int) string
- type RetryConfig
- type Retryable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollapseBlankLines ¶
CollapseBlankLines replaces runs of blank lines with a single blank line. CI logs are full of padding that wastes scarce LLM context.
func Do ¶
Do runs fn until it succeeds, the context is cancelled, or attempts are exhausted. Backoff is exponential with jitter, so a fleet of runners retrying together does not synchronise into a thundering herd.
func IsRetryable ¶
IsRetryable reports whether err asks to be retried.
func ShortHash ¶
ShortHash returns the first 12 hex characters of the SHA-256 of s. Used to give flaky occurrences a stable identity across runs so reports can be diffed and de-duplicated.
func TruncateRunes ¶
TruncateRunes shortens s to at most max runes, appending an ellipsis when it had to cut. Rune-aware so multi-byte characters are never split in half.
Types ¶
type RetryConfig ¶
RetryConfig controls the exponential backoff used for network calls.
func DefaultRetry ¶
func DefaultRetry() RetryConfig
DefaultRetry is a sensible policy for the GitHub API: enough attempts to ride out a secondary rate limit without hanging a CI job for minutes.