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 (docs) 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.
Private servicesโ
When registering an endpoint, every service is by default reachable via HTTP requests.
You can configure a service as private
, such that you can't invoke it over HTTP, through the Admin API (docs):
curl -X PATCH localhost:9070/services/MyService \ -H 'content-type: application/json' \ -d '{"public": false}'
You can revert it back to public with {"public": true}
.
Private services can still be invoked by other handlers via the SDK.