Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateNextInterval ¶
func CalculateNextInterval(attempt int, config BackoffConfig) time.Duration
CalculateNextInterval calculates the next retry interval using exponential backoff The formula is: interval = min(min_interval * (multiplier ^ attempt), max_interval) Attempt is zero-indexed (first retry is attempt 0)
Types ¶
type BackoffConfig ¶
type BackoffConfig struct {
MinInterval time.Duration // Minimum interval between retries
MaxInterval time.Duration // Maximum interval between retries
Multiplier float64 // Exponential backoff multiplier
InitialDelay time.Duration // Delay before first attempt
}
BackoffConfig configures the exponential backoff strategy
func DefaultBackoffConfig ¶
func DefaultBackoffConfig() BackoffConfig
DefaultBackoffConfig returns the default backoff configuration
func (BackoffConfig) Validate ¶
func (c BackoffConfig) Validate() error
Validate validates the backoff configuration
type Condition ¶
type Condition struct {
Type ConditionType
Operator Operator
Value int64
}
Condition represents a success condition for waiting
func ParseCondition ¶
ParseCondition parses a condition string in kubectl-like format Supported formats:
- count=N (exactly N records)
- count-gte=N (at least N records, >=)
- count-gt=N (more than N records, >)
- count-lte=N (at most N records, <=)
- count-lt=N (fewer than N records, <)
- any (any records, count > 0)
- none (no records, count == 0)
type ConditionType ¶
type ConditionType string
ConditionType defines the type of condition
const ( ConditionTypeCount ConditionType = "count" ConditionTypeAny ConditionType = "any" ConditionTypeNone ConditionType = "none" )
type QueryWaiter ¶
type QueryWaiter struct {
// contains filtered or unexported fields
}
QueryWaiter polls a query until a condition is met
func NewQueryWaiter ¶
func NewQueryWaiter(executor *exec.DQLExecutor, config WaitConfig) *QueryWaiter
NewQueryWaiter creates a new query waiter
func (*QueryWaiter) PrintResults ¶
func (w *QueryWaiter) PrintResults(result *Result) error
PrintResults prints the query results if output format is specified
type Result ¶
type Result struct {
Success bool
Attempts int
Elapsed time.Duration
RecordCount int64
Records []map[string]any
FailureReason string
}
Result contains the result of a wait operation
type ValidationError ¶
ValidationError represents a validation error for backoff configuration
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type WaitConfig ¶
type WaitConfig struct {
Query string
Condition Condition
Timeout time.Duration
MaxAttempts int // 0 = unlimited
Backoff BackoffConfig
QueryOptions exec.DQLExecuteOptions
OutputFormat string
Quiet bool
Verbose bool
ProgressOut io.Writer // Where to write progress messages (default: os.Stderr, even if Out is set)
Out io.Writer // Where PrintResults writes (default: os.Stdout); progress goes to ProgressOut
}
WaitConfig configures the wait operation