Skip to content

Commit

Permalink
Service endpoint -> Deployments (#229)
Browse files Browse the repository at this point in the history
Co-authored-by: Till Rohrmann <[email protected]>
  • Loading branch information
slinkydeveloper and tillrohrmann authored Dec 20, 2023
1 parent 1f26daf commit bc16e2a
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 104 deletions.
20 changes: 10 additions & 10 deletions docs/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ docker run --name restate_dev --rm -d --network=host docker.io/restatedev/restat
Register the service:

Now, we need to tell Restate where the service is running.
We do this by sending a request to the endpoint of the runtime at `http://localhost:8081/endpoints`
and providing it with the endpoint of the service `http://localhost:8080`.
We do this by sending a request to the endpoint of the runtime at `http://localhost:8081/deployments`
and providing it with the deployment endpoint of the service `http://localhost:8080`.
```shell
curl -X POST http://localhost:9070/endpoints -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}'
curl -X POST http://localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}'
```
Restate then sends a request to the service endpoint to ask which services and methods
are running behind this endpoint and will keep track of these (including of the method signatures).
Restate then sends a request to the service deployment to ask which services and methods
are running behind this deployment and will keep track of these (including of the method signatures).
After executing this curl request, you should see the discovered services and methods printed to your terminal.


Expand All @@ -129,13 +129,13 @@ docker run --name restate_dev --rm -d -p 8080:8080 -p 9070:9070 -p 9071:9071 doc
Register the services:

Now, we need to tell Restate where the service is running.
We do this by sending a request to the endpoint of the runtime at `http://localhost:8081/endpoints`
and providing it with the endpoint of the service `http://host.docker.internal:8080`.
We do this by sending a request to the endpoint of the runtime at `http://localhost:8081/deployments`
and providing it with the deployment endpoint of the service `http://host.docker.internal:8080`.
```shell
curl -X POST http://localhost:9070/endpoints -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:9080"}'
curl -X POST http://localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:9080"}'
```
Restate then sends a request to the service endpoint to ask which services and methods
are running behind this endpoint and will keep track of these (including of the method signatures).
Restate then sends a request to the service deployment to ask which services and methods
are running behind this deployment and will keep track of these (including of the method signatures).
After executing this curl request, you should see the discovered services and methods printed to your terminal.

</TabItem>
Expand Down
58 changes: 29 additions & 29 deletions docs/references/restate-sql-introspection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,38 @@ The schema of these tables is described in the following.

## Table: `sys_status`

| Column name | Type | Description | Example |
|----------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|
| `partition_key` | `UInt64` | Internal column that is used for partitioning the services invocations. Can be ignored. | |
| `service` | `Utf8` | The name for the invoked service. | `foo.bar.Greeter` |
| `method` | `Utf8` | The invoked RPC method. | `greet` |
| `service_key` | `Utf8` | The service key. | `bob` |
| `status` | `Utf8` | Enum value: `invoked` or `suspended`. | |
| `id` | `Utf8` | [Invocation ID](/services/invocation#invocation-identifier), an opaque token that can be used to cancel an invocation of a service with the [admin API](/references/admin-api). | |
| `invoked_by` | `Utf8` | Enum describing the invoker of this service: `ingress` = invoked externally / `service` = invoked by a service. | |
| `invoked_by_service` | `Utf8` | The name of the invoking service. Or `null` if invoked via the ingress. | `com.example.Greeter` |
| `invoked_by_id` | `Utf8` | The Invocation ID of the service that triggered this invocation. Or `null` if invoked externally. | |
| `pinned_endpoint_id` | `Utf8` | The opaque service endpoint ID that has been committed for this invocation; this is set after the first journal entry is stored for this invocation. | |
| `trace_id` | `Utf8` | The ID of the trace that is assigned to this invocation. Only relevant when tracing is enabled. | |
| `journal_size` | `UInt32` | The number of journal entries durably logged for this invocation. | |
| `created_at` | `Date64` | Timestamp indicating the start of this invocation. | |
| `modified_at` | `Date64` | Timestamp indicating the last state transition. For example, last time the status changed from `invoked` to `suspended`. | |
| Column name | Type | Description | Example |
|------------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|
| `partition_key` | `UInt64` | Internal column that is used for partitioning the services invocations. Can be ignored. | |
| `service` | `Utf8` | The name for the invoked service. | `foo.bar.Greeter` |
| `method` | `Utf8` | The invoked RPC method. | `greet` |
| `service_key` | `Utf8` | The service key. | `bob` |
| `status` | `Utf8` | Enum value: `invoked` or `suspended`. | |
| `id` | `Utf8` | [Invocation ID](/services/invocation#invocation-identifier), an opaque token that can be used to cancel an invocation of a service with the [admin API](/references/admin-api). | |
| `invoked_by` | `Utf8` | Enum describing the invoker of this service: `ingress` = invoked externally / `service` = invoked by a service. | |
| `invoked_by_service` | `Utf8` | The name of the invoking service. Or `null` if invoked via the ingress. | `com.example.Greeter` |
| `invoked_by_id` | `Utf8` | The Invocation ID of the service that triggered this invocation. Or `null` if invoked externally. | |
| `pinned_deployment_id` | `Utf8` | The opaque service deployment ID that has been committed for this invocation; this is set after the first journal entry is stored for this invocation. | |
| `trace_id` | `Utf8` | The ID of the trace that is assigned to this invocation. Only relevant when tracing is enabled. | |
| `journal_size` | `UInt32` | The number of journal entries durably logged for this invocation. | |
| `created_at` | `Date64` | Timestamp indicating the start of this invocation. | |
| `modified_at` | `Date64` | Timestamp indicating the last state transition. For example, last time the status changed from `invoked` to `suspended`. | |

## Table: `sys_invocation_state`

| Column name | Type | Description | Example |
|----------------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|
| `partition_key` | `UInt64` | Internal column that is used for partitioning the services invocations. Can be ignored. | |
| `service` | `Utf8` | The name for the invoked service. | `foo.bar.Greeter` |
| `service_key` | `Utf8` | The service key. | `bob` |
| `id` | `Utf8` | [Invocation ID](/services/invocation#invocation-identifier), an opaque token that can be used to cancel an invocation of a service with the [admin API](/references/admin-api). | |
| `in_flight` | `Boolean` | Indicates whether there is currently an attempt running for this invocation. | |
| `retry_count` | `UInt64` | The number of attempts since the last successful attempt of this invocation. Increments on start, so 2 or more means a failure occurred. | |
| `last_start_at` | `Date64` | Timestamp indicating the start of the most recent attempt of this invocation. | |
| `last_attempt_endpoint_id` | `Utf8` | The opaque service endpoint ID that was used in the most recent attempt of this invocation; this will be set before a journal entry is stored, but can change later. | |
| `next_retry_at` | `Date64` | Timestamp indicating the start of the next attempt of this invocation. | |
| `last_failure` | `Utf8` | An error message describing the most recent failed attempt of this invocation, if any. | |
| `last_error_code` | `Utf8` | The [error code](./errors) of the most recent failed attempt of this invocation, if any. | |
| Column name | Type | Description | Example |
|------------------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|
| `partition_key` | `UInt64` | Internal column that is used for partitioning the services invocations. Can be ignored. | |
| `service` | `Utf8` | The name for the invoked service. | `foo.bar.Greeter` |
| `service_key` | `Utf8` | The service key. | `bob` |
| `id` | `Utf8` | [Invocation ID](/services/invocation#invocation-identifier), an opaque token that can be used to cancel an invocation of a service with the [admin API](/references/admin-api). | |
| `in_flight` | `Boolean` | Indicates whether there is currently an attempt running for this invocation. | |
| `retry_count` | `UInt64` | The number of attempts since the last successful attempt of this invocation. Increments on start, so 2 or more means a failure occurred. | |
| `last_start_at` | `Date64` | Timestamp indicating the start of the most recent attempt of this invocation. | |
| `last_attempt_deployment_id` | `Utf8` | The opaque service deployment ID that was used in the most recent attempt of this invocation; this will be set before a journal entry is stored, but can change later. | |
| `next_retry_at` | `Date64` | Timestamp indicating the start of the next attempt of this invocation. | |
| `last_failure` | `Utf8` | An error message describing the most recent failed attempt of this invocation, if any. | |
| `last_error_code` | `Utf8` | The [error code](./errors) of the most recent failed attempt of this invocation, if any. | |

## Table: `sys_journal`

Expand Down
2 changes: 1 addition & 1 deletion docs/restate/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It exposes three services by default, each on different ports:
| Name | Port | Description | Protocol |
|----------|------|--------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| Ingress | 8080 | Acts as an API gateway for all services registered with Restate | gRPC + [Connect Protocol](https://connect.build/) |
| Admin | 9070 | Allows for CRUD operations on service/endpoint metadata, eg for service registration | REST |
| Admin | 9070 | Allows for CRUD operations on service/service deployment metadata, eg for service registration | REST |
| Postgres | 9071 | Exposes Restate RocksDB read-only storage operations using the Postgres protocol. See [Introspection](/services/introspection) | Postgres |

It will store metadata and RocksDB data in the relative directory of /target under the current working directory of the process.
Expand Down
4 changes: 2 additions & 2 deletions docs/restate/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ The following components are producing relevant logs:

* `restate_ingress_grpc`: The component ingesting gRPC/Connect HTTP requests inside Restate
* `restate_meta`: The component responsible for holding the metadata informations and executing service discovery
* `restate_invoker`: The component interacting with deployed service endpoints
* `restate_worker::partition::effects`: The state machine effects
* `restate_invoker`: The component interacting with deployed service deployments
* `restate_worker::partition::state_machine`: The state machine effects
* `restate_storage`: Restate storage layer
* `hyper`: The HTTP library

Expand Down
5 changes: 3 additions & 2 deletions docs/restate/managed_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A Restate meta endpoint, which can be used to register Restate Lambda functions
[TypeScript](/services/deployment/lambda/lambda-typescript#discovering-the-services-behind-the-lambda-endpoint) and [Java](/services/deployment/lambda/lambda-java#discovering-the-services-behind-the-lambda-endpoint),
with a bearer token set.
```bash
curl -H "Authorization: Bearer $(cat /token)" https://yourcluster.dev.restate.cloud:8081/endpoints -H 'content-type: application/json' -d '{"uri": "https://<lambda-function-endpoint>/default/my-greeter", "additional_headers": {"x-api-key": "your-api-key"} }'
curl -H "Authorization: Bearer $(cat /token)" https://yourcluster.dev.restate.cloud:8081/deployments -H 'content-type: application/json' -d '{"uri": "https://<lambda-function-endpoint>/default/my-greeter", "additional_headers": {"x-api-key": "your-api-key"} }'
```

### Invoking services (9090)
Expand Down Expand Up @@ -134,6 +134,7 @@ Resource Policies, or you can create a role per account - Restate can assume a d

Once you have a role that has permission to call the Lambda, and allows Restate to assume it, you just need to discover
the Lambda:

```shell
curl -X POST http://<your-restate-runtime-endpoint>:9070/endpoints -H 'content-type: application/json' -d '{"arn": "<lambda-function-arn>", "assume_role_arn": "<role-arn>" }'
curl -X POST http://<your-restate-runtime-endpoint>:9070/deployments -H 'content-type: application/json' -d '{"arn": "<lambda-function-arn>", "assume_role_arn": "<role-arn>" }'
```
Loading

0 comments on commit bc16e2a

Please sign in to comment.