Registration
After deploying an endpoint, you need to register it with Restate. That way Restate knows where it runs and can invoke it.
Registering deployments
- CLI
- curl
Register a service endpoint URI as follows:
restate deployments register localhost:9080
Output
❯ SERVICES THAT WILL BE ADDED:- CheckoutServiceType: ServiceHANDLER INPUT TYPE OUTPUT TYPEhandle one of "empty or value of content-type */*" value with content-type "application/json"- CartObjectType: VirtualObject ⬅️ 🚶🚶🚶HANDLER INPUT TYPE OUTPUT TYPEaddTicket one of "empty or value of content-type */*" value with content-type "application/json"expireTicket one of "empty or value of content-type */*" value with content-type "application/json"checkout one of "empty or value of content-type */*" value with content-type "application/json"- TicketObjectType: VirtualObject ⬅️ 🚶🚶🚶HANDLER INPUT TYPE OUTPUT TYPEreserve one of "empty or value of content-type */*" value with content-type "application/json"markAsSold one of "empty or value of content-type */*" value with content-type "application/json"unreserve one of "empty or value of content-type */*" value with content-type "application/json"✔ Are you sure you want to apply those changes? · yes✅ DEPLOYMENT:SERVICE REVTicketObject 1CheckoutService 1CartObject 1
Or you can use the shorthand restate dp add
.
Register a service endpoint URI with the Restate Admin API) as follows:
curl localhost:9070/deployments -H 'content-type: application/json' \-d '{"uri": "http://localhost:9080"}'
Output
{"id": "dp_11pXug0mWsff2NOoRBZbOcV","services": [{"name": "CartObject","handlers": [{"name": "checkout","ty": "Exclusive","input_description": "one of \"empty or value of content-type */*\"","output_description": "value with content-type \"application/json\""},{"name": "expireTicket","ty": "Exclusive","input_description": "one of \"empty or value of content-type */*\"","output_description": "value with content-type \"application/json\""},{"name": "addTicket","ty": "Exclusive","input_description": "one of \"empty or value of content-type */*\"","output_description": "value with content-type \"application/json\""}],"ty": "VirtualObject","deployment_id": "dp_11pXug0mWsff2NOoRBZbOcV","revision": 3,"public": true,"idempotency_retention": "1day"},{"name": "CheckoutService","handlers": [{"name": "handle","ty": "Shared","input_description": "one of \"empty or value of content-type */*\"","output_description": "value with content-type \"application/json\""}],"ty": "Service","deployment_id": "dp_11pXug0mWsff2NOoRBZbOcV","revision": 3,"public": true,"idempotency_retention": "1day"}]}
To register a Lambda handler, replace http://localhost:9080
by the ARN of the Lambda function, for example arn:aws:lambda:my-region:123456789101:function:my-function:my-version
.
When running Restate in a Docker, replace localhost
with host.docker.internal
.
A service can be registered only once. Subsequent registration requests to the same deployment will fail. For more details on how to update services, check the versioning docs.
When developing locally, you can forcefully overwrite an existing deployment:
- CLI
- curl
restate deployments register --force localhost:9080
curl localhost:9070/deployments -H 'content-type: application/json' \-d '{"uri": "localhost:9080", "force": true}'
This will forcefully overwrite the existing service deployment with the same URI, forcing the discovery process again. It will also remove services that were served by that deployment and are not available anymore.
Forcing a deployment registration is a feature designed to simplify local Restate service development, and should never be used in a production Restate deployment, as it potentially breaks all the in-flight invocations to that deployment.
After registration, services can also be marked as 'private' to prevent them from being invoked through the ingress. See the Security docs for more information.