Merge pull request #1869 from swuecho/patch-2

fix: example to show cron binding usage
This commit is contained in:
greenie-msft 2021-11-04 14:22:28 -07:00 committed by GitHub
commit 99a5b20ce9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -59,6 +59,20 @@ For ease of use, the Dapr cron binding also supports few shortcuts:
* `@every 15s` where `s` is seconds, `m` minutes, and `h` hours
* `@daily` or `@hourly` which runs at that period from the time the binding is initialized
## Listen to the cron binding
After setting up the cron binding, all you need to do is listen on an endpoint that matches the name of your component. Assume the [NAME] is `scheduled`. This will be made as a HTTP `POST` request. The below example shows how a simple Node.js Express application can receive calls on the `/scheduled` endpoint and write a message to the console.
```js
app.post('/scheduled', async function(req, res){
console.log("scheduled endpoint called", req.body)
res.status(200).send()
});
```
When running this code, note that the `/scheduled` endpoint is called every five minutes by the Dapr sidecar.
## Binding support
This component supports both **input and output** binding interfaces.