Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Option ¶
type Option func(*executor)
func Once ¶
func Once() Option
Once configures the executor to allow only a single successful Start() call. After the first successful execution, subsequent Start() calls will return an error.
Note: Once() is compatible with WithRetry(). When both are used:
- The first Start() call can retry on failure (if WithRetry is configured)
- Only one successful Start() execution is allowed
- Once a Start() call succeeds, no further Start() calls are permitted
This is useful for idempotent initialization tasks that should only complete once but may need retries due to transient failures.
Example:
je := New(job, Once(), WithRetry(3, 1*time.Second)) je.Start(...) // May retry up to 3 times on failure je.Start(...) // Returns error if previous call succeeded
func WithCooldown ¶
func WithRetry ¶
WithRetry configures the executor to retry failed job executions. The retry mechanism applies to each Start() call independently.
Parameters:
- attempts: number of retry attempts (must be > 0)
- interval: delay between retry attempts
Note: WithRetry is compatible with Once(). When both are used:
- Once() restricts the number of successful Start() calls to one
- WithRetry() allows retries within that single Start() call
Example:
je := New(job, Once(), WithRetry(3, 1*time.Second)) je.Start(...) // Will retry up to 3 times on failure je.Start(...) // Will return error "job can only start once" if first call succeeded
func WithTimeout ¶
Click to show internal directories.
Click to hide internal directories.