Skip to content

Commit

Permalink
Add documentation to invoke a service idempotently
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed Sep 27, 2023
1 parent 0e7bf62 commit 1a910c5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/services/invocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ grpcurl -plaintext <your-restate-runtime-host-port> describe
Restate also natively supports gRPC-web. You can use a [gRPC-web code generator](https://www.npmjs.com/package/grpc-web) and point it directly to Restate, without using a 3rd party proxy to translate gRPC-web to gRPC.
### Invoke a service idempotently

Check failure on line 70 in docs/services/invocation.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/services/invocation.md#L70

[Vale.Spelling] Did you really mean 'idempotently'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'idempotently'?", "location": {"path": "docs/services/invocation.md", "range": {"start": {"line": 70, "column": 22}}}, "severity": "ERROR"}
You can send requests to Restate providing an idempotency key, through the [`Idempotency-Key` header](https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/):
```shell
curl -X POST http://<restate-runtime-host-port>/org.example.Greeter/Greet -H 'idempotency-key: <idempotency-key>' -H 'content-type: application/json' -d '{"name": "Pete"}'
```
After the invocation completes, Restate persists the response for a retention period of 30 minutes.
If you re-invoke the service with the same idempotency key within 30 minutes, Restate sends back the same response and doesn't re-execute the request to the service.

You can tune the retention period by setting the header `idempotency-retention-period: <seconds>`

The `Idempotency-Key` header works with both HTTP and gRPC/gRPC-web.

### Invoke a service without waiting for the response

You can invoke a service without waiting for the response, similar to [one-way calls in the SDK](/services/sdk/service-communication#one-way-calls), by using the Restate built-in `dev.restate.Ingress/Invoke` service method, which can be invoked like any other user service, using gRPC, gRPC-web or Connect.
Expand Down

0 comments on commit 1a910c5

Please sign in to comment.