Skip to content

Commit 17442bc

Browse files
committed
chore: Add documentation for the jobs failure policy
Signed-off-by: Albert Callarisa <albert@diagrid.io>
1 parent 8f633fe commit 17442bc

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

daprdocs/content/en/developing-applications/building-blocks/jobs/jobs-features-concepts.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ weight: 2000
66
description: "Learn more about the Dapr Jobs features and concepts"
77
---
88

9-
Now that you've learned about the [jobs building block]({{< ref jobs-overview.md >}}) at a high level, let's deep dive
9+
Now that you've learned about the [jobs building block]({{< ref jobs-overview.md >}}) at a high level, let's deep dive
1010
into the features and concepts included with Dapr Jobs and the various SDKs. Dapr Jobs:
1111
- Provides a robust and scalable API for scheduling operations to be triggered in the future.
1212
- Exposes several capabilities which are common across all supported languages.
@@ -15,8 +15,8 @@ into the features and concepts included with Dapr Jobs and the various SDKs. Dap
1515

1616
## Job identity
1717

18-
All jobs are registered with a case-sensitive job name. These names are intended to be unique across all services
19-
interfacing with the Dapr runtime. The name is used as an identifier when creating and modifying the job as well as
18+
All jobs are registered with a case-sensitive job name. These names are intended to be unique across all services
19+
interfacing with the Dapr runtime. The name is used as an identifier when creating and modifying the job as well as
2020
to indicate which job a triggered invocation is associated with.
2121

2222
Only one job can be associated with a name at any given time. Any attempt to create a new job using the same name
@@ -27,8 +27,8 @@ A job can be scheduled using any of the following mechanisms:
2727
- Intervals using Cron expressions, duration values, or period expressions
2828
- Specific dates and times
2929

30-
For all time-based schedules, if a timestamp is provided with a time zone via the RFC3339 specification, that
31-
time zone is used. When not provided, the time zone used by the server running Dapr is used.
30+
For all time-based schedules, if a timestamp is provided with a time zone via the RFC3339 specification, that
31+
time zone is used. When not provided, the time zone used by the server running Dapr is used.
3232
In other words, do **not** assume that times run in UTC time zone, unless otherwise specified when scheduling
3333
the job.
3434

@@ -48,7 +48,7 @@ fields spanning the values specified in the table below:
4848

4949
### Schedule using a duration value
5050
You can schedule jobs using [a Go duration string](https://pkg.go.dev/time#ParseDuration), in which
51-
a string consists of a (possibly) signed sequence of decimal numbers, each with an optional fraction and a unit suffix.
51+
a string consists of a (possibly) signed sequence of decimal numbers, each with an optional fraction and a unit suffix.
5252
Valid time units are `"ns"`, `"us"`, `"ms"`, `"s"`, `"m"`, or `"h"`.
5353

5454
#### Example 1
@@ -70,7 +70,7 @@ The following period expressions are supported. The "@every" expression also acc
7070
| @hourly | Run once an hour at the beginning of the hour | 0 0 * * * * |
7171

7272
### Schedule using a specific date/time
73-
A job can also be scheduled to run at a particular point in time by providing a date using the
73+
A job can also be scheduled to run at a particular point in time by providing a date using the
7474
[RFC3339 specification](https://www.rfc-editor.org/rfc/rfc3339).
7575

7676
#### Example 1
@@ -107,15 +107,16 @@ In this setup, you have full control over how triggered jobs are received and pr
107107
through this gRPC method.
108108

109109
### HTTP
110-
If a gRPC server isn't registered with Dapr when the application starts up, Dapr instead triggers jobs by making a
110+
If a gRPC server isn't registered with Dapr when the application starts up, Dapr instead triggers jobs by making a
111111
POST request to the endpoint `/job/<job-name>`. The body includes the following information about the job:
112112
- `Schedule`: When the job triggers occur
113113
- `RepeatCount`: An optional value indicating how often the job should repeat
114114
- `DueTime`: An optional point in time representing either the one time when the job should execute (if not recurring)
115115
or the not-before time from which the schedule should take effect
116116
- `Ttl`: An optional value indicating when the job should expire
117117
- `Payload`: A collection of bytes containing data originally stored when the job was scheduled
118+
- `FailurePolicy`: An optional failure policy for the job.
118119

119120
The `DueTime` and `Ttl` fields will reflect an RC3339 timestamp value reflective of the time zone provided when the job was
120121
originally scheduled. If no time zone was provided, these values indicate the time zone used by the server running
121-
Dapr.
122+
Dapr.

daprdocs/content/en/reference/api/jobs_api.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Parameter | Description
3737
`dueTime` | An optional time at which the job should be active, or the "one shot" time, if other scheduling type fields are not provided. Accepts a "point in time" string in the format of RFC3339, Go duration string (calculated from creation time), or non-repeating ISO8601.
3838
`repeats` | An optional number of times in which the job should be triggered. If not set, the job runs indefinitely or until expiration.
3939
`ttl` | An optional time to live or expiration of the job. Accepts a "point in time" string in the format of RFC3339, Go duration string (calculated from job creation time), or non-repeating ISO8601.
40+
`failure_policy` | An optional failure policy for the job. Details of the format are below.
4041

4142
#### schedule
4243
`schedule` accepts both systemd timer-style cron expressions, as well as human readable '@' prefixed period strings, as defined below.
@@ -62,6 +63,37 @@ Entry | Description | Equivalent
6263
@daily (or @midnight) | Run once a day, midnight | 0 0 0 * * *
6364
@hourly | Run once an hour, beginning of hour | 0 0 * * * *
6465

66+
#### failure_policy
67+
68+
`failure_policy` specifies how the job should handle failures.
69+
70+
It can be set to `constant` or `drop`.
71+
- The `constant` policy will retry the job up to `max_retries` times, with a delay of `interval` between retries.
72+
- The `drop` policy will drop the job after the first failure, without retrying.
73+
74+
##### Example 1
75+
76+
```json
77+
{
78+
//...
79+
"failure_policy": {
80+
"constant": {
81+
"max_retries": 3,
82+
"interval": "10s"
83+
}
84+
}
85+
}
86+
```
87+
##### Example 2
88+
89+
```json
90+
{
91+
//...
92+
"failure_policy": {
93+
"drop": {}
94+
}
95+
}
96+
```
6597

6698
### Request body
6799

0 commit comments

Comments
 (0)