Optional
abortOptional
asBy default, Restate will consider any error terminal, that is non retryable, if it's an instance of TerminalError
.
By setting this field, you can provide a function to map specific errors in your domain to TerminalError
(or undefined, if the error should be considered retryable). Once TerminalError
, these errors won't be retried.
Note: this will be used both for errors thrown by ctx.run
closures and by errors thrown in restate handlers.
Example:
class MyValidationError extends Error {}
const greeter = restate.service({
name: "greeter",
handlers: {
greet: async (ctx: restate.Context, name: string) => {
if (name.length === 0) {
throw new MyValidationError("Length too short");
}
return `Hello ${name}`;
}
},
options: {
asTerminalError: (err) => {
if (err instanceof MyValidationError) {
// My validation error is terminal
return new restate.TerminalError(err.message, {errorCode: 400})
}
// Any other error is retryable
}
}
});
Optional
idempotencyThe retention duration of idempotent requests to this service.
NOTE: You can set this field only if you register this endpoint against restate-server >= 1.4, otherwise the service discovery will fail.
Optional
inactivityThis timer guards against stalled invocations. Once it expires, Restate triggers a graceful termination by asking the invocation to suspend (which preserves intermediate progress).
The abortTimeout
is used to abort the invocation, in case it doesn't react to the request to
suspend.
This overrides the default inactivity timeout configured in the restate-server for all invocations to this service.
NOTE: You can set this field only if you register this endpoint against restate-server >= 1.4, otherwise the service discovery will fail.
Optional
ingressWhen set to true
this service, with all its handlers, cannot be invoked from the restate-server
HTTP and Kafka ingress, but only from other services.
NOTE: You can set this field only if you register this endpoint against restate-server >= 1.4, otherwise the service discovery will fail.
Optional
journalThe journal retention. When set, this applies to all requests to all handlers of this service.
In case the request has an idempotency key, the idempotencyRetention
caps the journal retention
time.
NOTE: You can set this field only if you register this endpoint against restate-server >= 1.4, otherwise the service discovery will fail.
This timer guards against stalled service/handler invocations that are supposed to terminate. The abort timeout is started after the
inactivityTimeout
has expired and the service/handler invocation has been asked to gracefully terminate. Once the timer expires, it will abort the service/handler invocation.This timer potentially interrupts user code. If the user code needs longer to gracefully terminate, then this value needs to be set accordingly.
This overrides the default abort timeout configured in the restate-server for all invocations to this service.
NOTE: You can set this field only if you register this endpoint against restate-server >= 1.4, otherwise the service discovery will fail.