feat: add restate
This commit is contained in:
13
src/restate/.env.example
Normal file
13
src/restate/.env.example
Normal file
@@ -0,0 +1,13 @@
|
||||
# Restate version
|
||||
RESTATE_VERSION=1.5.3
|
||||
|
||||
# Port overrides (host:container)
|
||||
INGRESS_PORT_OVERRIDE=8080
|
||||
ADMIN_PORT_OVERRIDE=9070
|
||||
NODE_PORT_OVERRIDE=5122
|
||||
|
||||
# Timezone
|
||||
TZ=UTC
|
||||
|
||||
# Log level: trace, debug, info, warn, error
|
||||
RESTATE_LOG_FILTER=restate=info
|
||||
122
src/restate/README.md
Normal file
122
src/restate/README.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# Restate Single-Node Server
|
||||
|
||||
Restate is a distributed workflow engine for stateful services that provides durable execution, reliable messaging, and state management out of the box.
|
||||
|
||||
## Features
|
||||
|
||||
- **Durable Execution**: Automatically persist execution state and resume on failures
|
||||
- **Reliable Messaging**: Built-in message delivery guarantees
|
||||
- **State Management**: Strongly consistent state with minimal overhead
|
||||
- **Service Discovery**: Automatic service registration and discovery
|
||||
- **Admin API**: Rich API for monitoring and managing services
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Copy environment file:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2. Start the service:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
3. Verify the service is running:
|
||||
|
||||
```bash
|
||||
curl http://localhost:9070/health
|
||||
```
|
||||
|
||||
## Service Endpoints
|
||||
|
||||
- **Ingress API**: `http://localhost:8080` - Main API for invoking services
|
||||
- **Admin API**: `http://localhost:9070` - Management and monitoring API
|
||||
- **Node Communication**: Port 5122 (internal)
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ----------------------- | -------------- | --------------------------------------- |
|
||||
| `RESTATE_VERSION` | `1.5.3` | Restate server version |
|
||||
| `INGRESS_PORT_OVERRIDE` | `8080` | Ingress API port |
|
||||
| `ADMIN_PORT_OVERRIDE` | `9070` | Admin API port |
|
||||
| `NODE_PORT_OVERRIDE` | `5122` | Node-to-node communication port |
|
||||
| `RESTATE_LOG_FILTER` | `restate=info` | Log level (trace/debug/info/warn/error) |
|
||||
| `TZ` | `UTC` | Timezone |
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Deploy a Service
|
||||
|
||||
```bash
|
||||
# Register a service endpoint
|
||||
curl -X POST http://localhost:9070/deployments \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"uri": "http://my-service:9080"}'
|
||||
```
|
||||
|
||||
### List Deployed Services
|
||||
|
||||
```bash
|
||||
curl http://localhost:9070/services
|
||||
```
|
||||
|
||||
### Invoke a Service
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8080/MyService/myMethod \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"key": "value"}'
|
||||
```
|
||||
|
||||
## Data Persistence
|
||||
|
||||
Restate data is stored in the named volume `restate_data`. The server uses node name `restate-1` for data consistency across restarts.
|
||||
|
||||
To reset the server and start fresh:
|
||||
|
||||
```bash
|
||||
docker compose down -v
|
||||
```
|
||||
|
||||
## Resource Limits
|
||||
|
||||
- CPU: 0.5-2.0 cores
|
||||
- Memory: 512MB-2GB
|
||||
|
||||
Adjust these limits in `docker-compose.yaml` based on your workload.
|
||||
|
||||
## Monitoring
|
||||
|
||||
Check server health:
|
||||
|
||||
```bash
|
||||
curl http://localhost:9070/health
|
||||
```
|
||||
|
||||
View server metrics (Prometheus format):
|
||||
|
||||
```bash
|
||||
curl http://localhost:9070/metrics
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Official Documentation](https://docs.restate.dev/)
|
||||
- [Deployment Guide](https://docs.restate.dev/server/deploy/docker)
|
||||
- [Configuration Reference](https://docs.restate.dev/references/server-config)
|
||||
- [Architecture](https://docs.restate.dev/references/architecture)
|
||||
|
||||
## License
|
||||
|
||||
This configuration is provided under the project's license. Restate is licensed under the [Business Source License 1.1](https://github.com/restatedev/restate/blob/main/LICENSE).
|
||||
|
||||
## Notes
|
||||
|
||||
- For production deployments, consider using a [Restate cluster](../restate-cluster/) for high availability
|
||||
- Ensure the data directory is on durable storage in production
|
||||
- The `--node-name` flag ensures consistent data restoration across restarts
|
||||
- For cluster deployments, see the [restate-cluster](../restate-cluster/) configuration
|
||||
122
src/restate/README.zh.md
Normal file
122
src/restate/README.zh.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# Restate 单节点服务器
|
||||
|
||||
Restate 是一个用于有状态服务的分布式工作流引擎,提供开箱即用的持久化执行、可靠消息传递和状态管理。
|
||||
|
||||
## 特性
|
||||
|
||||
- **持久化执行**:自动持久化执行状态并在失败时恢复
|
||||
- **可靠消息传递**:内置消息传递保证
|
||||
- **状态管理**:具有最小开销的强一致性状态
|
||||
- **服务发现**:自动服务注册和发现
|
||||
- **管理 API**:丰富的监控和管理服务 API
|
||||
|
||||
## 快速开始
|
||||
|
||||
1. 复制环境变量文件:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2. 启动服务:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
3. 验证服务运行:
|
||||
|
||||
```bash
|
||||
curl http://localhost:9070/health
|
||||
```
|
||||
|
||||
## 服务端点
|
||||
|
||||
- **Ingress API**:`http://localhost:8080` - 调用服务的主要 API
|
||||
- **Admin API**:`http://localhost:9070` - 管理和监控 API
|
||||
- **节点通信**:端口 5122(内部)
|
||||
|
||||
## 环境变量
|
||||
|
||||
| 变量 | 默认值 | 说明 |
|
||||
| ----------------------- | -------------- | --------------------------------------- |
|
||||
| `RESTATE_VERSION` | `1.5.3` | Restate 服务器版本 |
|
||||
| `INGRESS_PORT_OVERRIDE` | `8080` | Ingress API 端口 |
|
||||
| `ADMIN_PORT_OVERRIDE` | `9070` | Admin API 端口 |
|
||||
| `NODE_PORT_OVERRIDE` | `5122` | 节点间通信端口 |
|
||||
| `RESTATE_LOG_FILTER` | `restate=info` | 日志级别(trace/debug/info/warn/error) |
|
||||
| `TZ` | `UTC` | 时区 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
### 部署服务
|
||||
|
||||
```bash
|
||||
# 注册服务端点
|
||||
curl -X POST http://localhost:9070/deployments \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"uri": "http://my-service:9080"}'
|
||||
```
|
||||
|
||||
### 列出已部署的服务
|
||||
|
||||
```bash
|
||||
curl http://localhost:9070/services
|
||||
```
|
||||
|
||||
### 调用服务
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:8080/MyService/myMethod \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"key": "value"}'
|
||||
```
|
||||
|
||||
## 数据持久化
|
||||
|
||||
Restate 数据存储在命名卷 `restate_data` 中。服务器使用节点名称 `restate-1` 以确保重启时的数据一致性。
|
||||
|
||||
要重置服务器并重新开始:
|
||||
|
||||
```bash
|
||||
docker compose down -v
|
||||
```
|
||||
|
||||
## 资源限制
|
||||
|
||||
- CPU:0.5-2.0 核心
|
||||
- 内存:512MB-2GB
|
||||
|
||||
根据工作负载在 `docker-compose.yaml` 中调整这些限制。
|
||||
|
||||
## 监控
|
||||
|
||||
检查服务器健康状态:
|
||||
|
||||
```bash
|
||||
curl http://localhost:9070/health
|
||||
```
|
||||
|
||||
查看服务器指标(Prometheus 格式):
|
||||
|
||||
```bash
|
||||
curl http://localhost:9070/metrics
|
||||
```
|
||||
|
||||
## 文档
|
||||
|
||||
- [官方文档](https://docs.restate.dev/)
|
||||
- [部署指南](https://docs.restate.dev/server/deploy/docker)
|
||||
- [配置参考](https://docs.restate.dev/references/server-config)
|
||||
- [架构](https://docs.restate.dev/references/architecture)
|
||||
|
||||
## 许可证
|
||||
|
||||
此配置在项目许可证下提供。Restate 采用 [Business Source License 1.1](https://github.com/restatedev/restate/blob/main/LICENSE) 许可。
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 对于生产部署,考虑使用 [Restate 集群](../restate-cluster/) 以实现高可用性
|
||||
- 在生产环境中确保数据目录位于持久存储上
|
||||
- `--node-name` 参数确保重启时的一致数据恢复
|
||||
- 对于集群部署,请参见 [restate-cluster](../restate-cluster/) 配置
|
||||
43
src/restate/docker-compose.yaml
Normal file
43
src/restate/docker-compose.yaml
Normal file
@@ -0,0 +1,43 @@
|
||||
# Restate Single-Node Server
|
||||
# A distributed workflow engine for stateful services
|
||||
# Documentation: https://docs.restate.dev/
|
||||
|
||||
x-defaults: &defaults
|
||||
restart: unless-stopped
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 100m
|
||||
max-file: "3"
|
||||
|
||||
services:
|
||||
restate:
|
||||
<<: *defaults
|
||||
image: restatedev/restate:${RESTATE_VERSION:-1.5.3}
|
||||
command: ["--node-name=restate-1"]
|
||||
ports:
|
||||
- "${INGRESS_PORT_OVERRIDE:-8080}:8080" # Ingress API
|
||||
- "${ADMIN_PORT_OVERRIDE:-9070}:9070" # Admin API
|
||||
- "${NODE_PORT_OVERRIDE:-5122}:5122" # Node-to-node communication
|
||||
volumes:
|
||||
- restate_data:/restate-data
|
||||
environment:
|
||||
- TZ=${TZ:-UTC}
|
||||
- RESTATE_LOG_FILTER=${RESTATE_LOG_FILTER:-restate=info}
|
||||
healthcheck:
|
||||
test: ["CMD", "sh", "-c", "wget --no-verbose --tries=1 --spider http://localhost:9070/health || exit 1"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '2.00'
|
||||
memory: 2G
|
||||
reservations:
|
||||
cpus: '0.50'
|
||||
memory: 512M
|
||||
|
||||
volumes:
|
||||
restate_data:
|
||||
Reference in New Issue
Block a user