add example of parseduration

Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>
This commit is contained in:
Hannah Hunter 2023-05-22 11:07:26 -04:00
parent 9b32d44a6c
commit 01678000b1
1 changed files with 29 additions and 1 deletions

View File

@ -20,7 +20,35 @@ You can modify the default Dapr actor runtime behavior using the following confi
| `entitiesConfig` | Configure each actor type individually with an array of configurations. Any entity specified in the individual entity configurations must also be specified in the top level `entities` field. | N/A |
{{% alert title="Note" color="primary" %}}
Timeouts and intervals use [Go's ParseDuration](https://pkg.go.dev/time#ParseDuration) format.
Actor timeouts and intervals use [Go's ParseDuration](https://pkg.go.dev/time#ParseDuration) format. For example, to set a timeout of 30 seconds with intervals of 5 minutes:
```go
func main() {
timeout := "30s"
interval := "5m"
// Parsing timeout
timeoutDuration, err := time.ParseDuration(timeout)
if err != nil {
fmt.Printf("Error parsing timeout duration: %v\n", err)
return
}
// Parsing interval
intervalDuration, err := time.ParseDuration(interval)
if err != nil {
fmt.Printf("Error parsing interval duration: %v\n", err)
return
}
}
```
You can use various string formats to represent durations, including:
- `1h30m` or `1.5h`: A duration of 1 hour and 30 minutes
- `1d12h`: A duration of 1 day and 12 hours
- `500ms`: A duration of 500 milliseconds
- `-30m`: A negative duration of 30 minutes
{{% /alert %}}
## Examples