Better document dueTime and period (#343)

* Better document dueTime and period

* add for timer

Co-authored-by: Aman Bhardwaj <amanbha@users.noreply.github.com>
This commit is contained in:
Leon Mai 2020-02-10 17:09:42 -08:00 committed by GitHub
parent 8e8ba51e4e
commit 8975281d67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 86 additions and 2 deletions

View File

@ -76,7 +76,23 @@ You can create a timer for an actor by calling the Http/gRPC request to Dapr.
POST,PUT http://localhost:3500/v1.0/actors/<actorType>/<actorId>/timers/<name>
```
You can provide the timer due time and callback in the request body.
The timer due time and callback are specified in the request body. The due time represents when the timer will first fire after registration. The period represents how often the timer will fire after that. A due time of 0 means to fire immediately. Negative due times and periods are invalid.
The following request body configures a timer with a `dueTime` of 9 seconds and a `period` of 3 seconds. This means it will first fire after 9 seconds, then every 3 seconds after that.
```json
{
"dueTime":"0h0m9s0ms",
"period":"0h0m3s0ms"
}
```
The following request body configures a timer with a `dueTime` 0 seconds and a `period` of 3 seconds. This means it will fire immediately after registration, then every 3 seconds after that.
```json
{
"dueTime":"0h0m0s0ms",
"period":"0h0m3s0ms"
}
```
You can remove the actor timer by calling
@ -96,7 +112,31 @@ You can create a persistent reminder for an actor by calling the Http/gRPC reque
POST,PUT http://localhost:3500/v1.0/actors/<actorType>/<actorId>/reminders/<name>
```
You can provide the reminder due time and period in the request body.
The reminder due time and callback can be specified in the request body. The due time represents when the reminder will first fire after registration. The period represents how often the reminder will fire after that. A due time of 0 means to fire immediately. Negative due times and periods are invalid. To register a reminder that fires only once, set the period to an empty string.
The following request body configures a reminder with a `dueTime` 9 seconds and a `period` of 3 seconds. This means it will first fire after 9 seconds, then every 3 seconds after that.
```json
{
"dueTime":"0h0m9s0ms",
"period":"0h0m3s0ms"
}
```
The following request body configures a reminder with a `dueTime` 0 seconds and a `period` of 3 seconds. This means it will fire immediately after registration, then every 3 seconds after that.
```json
{
"dueTime":"0h0m0s0ms",
"period":"0h0m3s0ms"
}
```
The following request body configures a reminder with a `dueTime` 15 seconds and a `period` of empty string. This means it will first fire after 15 seconds, then never fire again.
```json
{
"dueTime":"0h0m15s0ms",
"period":""
}
```
#### Retrieve Actor Reminder

View File

@ -147,6 +147,32 @@ Creates a persistent reminder for an actor.
POST,PUT http://localhost:<daprPort>/v1.0/actors/<actorType>/<actorId>/reminders/<name>
```
Body:
The following specifies a `dueTime` of 3 seconds and a period of 7 seconds.
```json
{
"dueTime":"0h0m3s0ms",
"period":"0h0m7s0ms"
}
```
A `dueTime` of 0 means to fire immediately. The following body means to fire immediately, then every 9 seconds.
```json
{
"dueTime":"0h0m0s0ms",
"period":"0h0m9s0ms"
}
```
To configure the reminder to fire once only, the period should be set to empty string. The following specifies a `dueTime` of 3 seconds with a period of empty string, which means the reminder will fire in 3 seconds and then never fire again.
```json
{
"dueTime":"0h0m3s0ms",
"period":""
}
```
#### HTTP Response Codes
Code | Description
@ -258,6 +284,24 @@ Creates a timer for an actor.
POST,PUT http://localhost:<daprPort>/v1.0/actors/<actorType>/<actorId>/timers/<name>
```
Body:
The following specifies a `dueTime` of 3 seconds and a period of 7 seconds.
```json
{
"dueTime":"0h0m3s0ms",
"period":"0h0m7s0ms"
}
```
A `dueTime` of 0 means to fire immediately. The following body means to fire immediately, then every 9 seconds.
```json
{
"dueTime":"0h0m0s0ms",
"period":"0h0m9s0ms"
}
```
#### HTTP Response Codes
Code | Description