You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can find a full example (the same as above plus a more detailed example) in the example folder. In there you'll also find a docker-compose file with the timescaleDB/postgres service that is needed for the running the queuer (it's just postgres with an extension).
55
+
You can find a full example (the same as above plus a more detailed example) in the example folder. In there you'll also find a docker-compose file with the timescaleDB/postgres service that is needed for the running the queuer (it's just postgres with an extension).
56
+
57
+
---
58
+
59
+
## Worker Options
60
+
61
+
The OnError struct defines how a worker should handle errors when processing a job. This allows for configurable retry behavior.
62
+
63
+
```go
64
+
typeOnErrorstruct {
65
+
Timeoutfloat64`json:"timeout"`
66
+
MaxRetriesint`json:"max_retries"`
67
+
RetryDelayfloat64`json:"retry_delay"`
68
+
RetryBackoffstring`json:"retry_backoff"`
69
+
}
70
+
```
71
+
72
+
-`Timeout`: The maximum time (in seconds) allowed for a single attempt of a job. If the job exceeds this duration, it's considered to have timed out.
73
+
-`MaxRetries`: The maximum number of times a job will be retried after a failure.
74
+
-`RetryDelay`: The initial delay (in seconds) before the first retry attempt. This delay can be modified by the `RetryBackoff` strategy.
75
+
-`RetryBackoff`: Specifies the strategy used to increase the delay between subsequent retries.
76
+
77
+
---
78
+
79
+
## Job options
80
+
81
+
Job Options
82
+
The Options struct allows you to define specific behaviors for individual jobs, overriding default worker settings where applicable.
83
+
84
+
```go
85
+
typeOptionsstruct {
86
+
OnError *OnError
87
+
Schedule *Schedule
88
+
}
89
+
```
90
+
91
+
-`OnError`: An optional `OnError` configuration that will override the worker's default error handling for this specific job. This allows you to define unique retry logic per job.
92
+
-`Schedule`: An optional `Schedule` configuration for jobs that need to be executed at recurring intervals.
93
+
94
+
### OnError for jobs
95
+
96
+
OnError for Jobs
97
+
The OnError struct for jobs is identical to the one used for worker options, allowing granular control over error handling for individual jobs.
98
+
99
+
```go
100
+
typeOnErrorstruct {
101
+
Timeoutfloat64`json:"timeout"`
102
+
MaxRetriesint`json:"max_retries"`
103
+
RetryDelayfloat64`json:"retry_delay"`
104
+
RetryBackoffstring`json:"retry_backoff"`
105
+
}
106
+
```
107
+
108
+
#### Retry Backoff Strategies
109
+
110
+
The RetryBackoff constant defines the available strategies for increasing retry delays:
111
+
112
+
```go
113
+
const (
114
+
RETRY_BACKOFF_NONE = "none"
115
+
RETRY_BACKOFF_LINEAR = "linear"
116
+
RETRY_BACKOFF_EXPONENTIAL = "exponential"
117
+
)
118
+
```
119
+
120
+
-`RETRY_BACKOFF_NONE`: No backoff. The RetryDelay remains constant for all retries.
121
+
-`RETRY_BACKOFF_LINEAR`: The retry delay increases linearly with each attempt (e.g., delay, 2*delay, 3*delay).
122
+
-`RETRY_BACKOFF_EXPONENTIAL`: The retry delay increases exponentially with each attempt (e.g., delay, delay*2, delay*2*2).
123
+
124
+
### Schedule
125
+
126
+
The Schedule struct is used to define recurring jobs.
127
+
128
+
```go
129
+
typeSchedulestruct {
130
+
Start time.Time`json:"start"`
131
+
Interval time.Duration`json:"interval"`
132
+
MaxCountint`json:"max_count"`
133
+
}
134
+
```
135
+
136
+
-`Start`: The initial time at which the scheduled job should first run.
137
+
-`Interval`: The duration between consecutive executions of the scheduled job.
138
+
-`MaxCount`: The maximum number of times the job should be executed. A value 0 indicates an indefinite number of repetitions (run forever).
0 commit comments