Skip to content

Commit 05f7c29

Browse files
authored
Failure Policy: Adds FailurePolicy API field to Job (#52)
* Failure Policy: Adds FailurePolicy API field to Job Based of dapr/proposals#66 Adds a `FailurePolicy` option to the `Job` API to allow re-triggering job which are marked as failed by the caller. Adds two types of policy; `Drop` and `Constant`. `Drop` has no retry policy, `Constant` will constantly retry the job trigger for a configurable delay, up to a configurable maximum number of retries (which could be infinite). Note that the failure policy retry cadence has no effect on the actual Job schedule, meaning if a job was to be retired and eventually succeeded, the Job would continue to trigger at the origin configured schedule. By default, all Jobs will have a `Constant` policy with a delay of 1s. Signed-off-by: joshvanl <[email protected]> * Linter Signed-off-by: joshvanl <[email protected]> * Rename `Constant` FailurePolicy `delay` to `interval` Signed-off-by: joshvanl <[email protected]> --------- Signed-off-by: joshvanl <[email protected]>
1 parent 6af5f2a commit 05f7c29

33 files changed

+2074
-262
lines changed

.golangci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ linters:
1919
- funlen
2020
- maintidx
2121
- containedctx
22+
- mnd
23+
- contextcheck
24+
- err113
2225
linters-settings:
2326
goimports:
2427
local-prefixes: github.com/diagridio

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ func main() {
2727
TriggerFn: func(context.Context, *api.TriggerRequest) bool {
2828
// Do something with your trigger here.
2929
// Return true if the trigger was successful, false otherwise.
30-
// Note, returning false will cause the job to be retried *immediately*.
30+
// Note, returning false will cause the job to be retried according to
31+
// the Jobs configurable FailurePolicy.
3132
return true
3233
},
3334
})
@@ -70,6 +71,11 @@ A Job itself is made up of the following fields:
7071
Optional.
7172
- `Payload`: A protobuf Any message that can be used to store the main payload of the job which will be passed to the trigger function.
7273
Optional.
74+
- `FailurePolicy` Controls whether the Job should be retired if the trigger
75+
function returns false. `Drop` doesn't retry the job, `Constant `Constant` will
76+
constantly retry the job trigger for a configurable internal, up to a configurable
77+
maximum number of retries (which could be infinite). By default, Jobs have a
78+
`Constant` policy, with a 1s interval and 3 maximum retries.
7379

7480
A job must have *at least* either a `Schedule` or a `DueTime` set.
7581

api/failurepolicy.pb.go

Lines changed: 340 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)