Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Poll ¶
Poll calls fetch repeatedly until it returns done or an error. It calls fetch immediately on the first iteration (no initial wait).
func WithOnProgress ¶ added in v0.6.0
func WithOnProgress(ctx context.Context, fn OnProgress) context.Context
WithOnProgress attaches a progress callback to the context. When Poll is called without Config.OnProgress, it falls back to this.
Types ¶
type Config ¶
type Config struct {
Interval time.Duration // base polling interval
MaxAttempts int // 0 means unlimited
Backoff float64 // multiplier per attempt; 1.0 = fixed interval
MaxInterval time.Duration // upper bound for backoff growth
OnProgress OnProgress // optional progress callback
}
Config controls polling behavior.
type Fetcher ¶
Fetcher checks whether an async task has completed. It returns the result string when done is true.
type OnProgress ¶
OnProgress is called after each poll attempt (optional).
type TaskStatus ¶ added in v0.13.0
type TaskStatus int
TaskStatus represents the normalized status of an async task.
const ( StatusPending TaskStatus = iota // queued, not yet started StatusRunning // in progress StatusSuccess // completed successfully StatusFailed // completed with error StatusCancelled // cancelled by user or system )
func MapStatus ¶ added in v0.13.0
func MapStatus(raw string) TaskStatus
MapStatus maps a raw status string from any engine API to a normalized TaskStatus. The mapping is case-insensitive and covers common variations across providers.
func (TaskStatus) Done ¶ added in v0.13.0
func (s TaskStatus) Done() bool
Done returns true if the status is terminal (success, failed, or cancelled).
func (TaskStatus) String ¶ added in v0.13.0
func (s TaskStatus) String() string
String returns a human-readable status name.