restate
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "restate":https://skillpi.com/zh/skills/deepskill-5e2135afb851c6125913db65c988b5b641a4c5cb936bb6e839dba7ae4e8f0db5。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
使用 Restate 构建弹性分布式应用的持久执行引擎,适用于 TypeScript、Java 和 Go。用于涉及持久执行、弹性工作流、分布式事务、Saga 模式、虚拟对象或作为比 Temporal 更轻量级替代方案的场景,涵盖持久化处理器、虚拟对象、工作流和 Saga 模式的构建。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 适合谁
- 翻译待完成,请参阅来源文档。
- 软件、账号及付费要求
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: restate
description: >-
Build resilient distributed applications with Restate — durable execution
engine for TypeScript/Java/Go. Use when someone asks to "durable execution",
"Restate", "resilient workflows", "distributed transactions", "saga pattern",
"fault-tolerant services", or "replace Temporal with something lighter".
Covers durable handlers, virtual objects, workflows, and sagas.
license: Apache-2.0
compatibility: "TypeScript/Java/Go/Rust/Python. Self-hosted or Restate Cloud."
metadata:
author: terminal-skills
version: "1.0.0"
category: development
tags: ["durable-execution", "restate", "distributed", "workflows", "resilience"]Restate
Overview
Restate is a durable execution engine — your code runs reliably even when things crash. Write normal async functions, and Restate ensures they complete: if a service crashes mid-execution, it resumes exactly where it left off. No lost state, no duplicate side effects. Like Temporal but with a simpler programming model — just annotate your functions, no state machines or DSLs.
When to Use
- Distributed transactions (payment → inventory → shipping)
- Long-running workflows that must complete (onboarding, provisioning)
- Saga pattern with compensating actions (rollback on failure)
- Exactly-once processing of events
- Replacing complex retry/queue logic with durable execution
Instructions
Setup
npm install @restatedev/restate-sdk
# Run Restate server
docker run --name restate -p 8080:8080 -p 9070:9070 docker.io/restatedev/restate:latest
Durable Service
// services/payment.ts — Durable payment service
import * as restate from "@restatedev/restate-sdk";
const paymentService = restate.service({
name: "payments",
handlers: {
// This handler is durable — if it crashes between steps,
// it resumes where it left off without re-executing completed steps
async processPayment(ctx: restate.Context, order: {
orderId: string;
userId: string;
amount: number;
}) {
// Step 1: Reserve inventory (durable — won't re-run if already done)
const reserved = await ctx.run("reserve-inventory", async () => {
return await inventoryApi.reserve(order.orderId);
});
// Step 2: Charge payment
const charge = await ctx.run("charge-payment", async () => {
return await stripeApi.charge(order.userId, order.amount);
});
// Step 3: Confirm order
await ctx.run("confirm-order", async () => {
await orderDb.confirm(order.orderId, charge.id);
});
// Step 4: Send notification (won't duplicate even if retried)
await ctx.run("notify", async () => {
await emailApi.send(order.userId, "Order confirmed!");
});
return { orderId: order.orderId, chargeId: charge.id, status: "completed" };
},
},
});
restate.endpoint().bind(paymentService).listen(9080);
Virtual Objects (Stateful Entities)
// services/cart.ts — Stateful shopping cart (single-writer per key)
const cartObject = restate.object({
name: "cart",
handlers: {
// Only one handler runs per cart ID at a time — no race conditions
async addItem(ctx: restate.ObjectContext, item: { productId: string; quantity: number }) {
// Get current cart state (durable K/V)
const cart = (await ctx.get<CartItem[]>("items")) || [];
cart.push(item);
ctx.set("items", cart);
return { items: cart.length };
},
async checkout(ctx: restate.ObjectContext) {
const items = (await ctx.get<CartItem[]>("items")) || [];
if (items.length === 0) throw new Error("Cart is empty");
// Process payment durably
const result = await ctx.serviceClient(paymentService).processPayment({
orderId: ctx.key,
items,
});
// Clear cart after successful payment
ctx.clear("items");
return result;
},
async getItems(ctx: restate.ObjectSharedContext) {
return (await ctx.get<CartItem[]>("items")) || [];
},
},
});
Saga Pattern (Compensating Actions)
// services/booking.ts — Saga with automatic rollback
const bookingService = restate.service({
name: "booking",
handlers: {
async bookTrip(ctx: restate.Context, trip: TripRequest) {
let flightId: string | null = null;
let hotelId: string | null = null;
try {
// Book flight
flightId = await ctx.run("book-flight", () => flightApi.book(trip.flight));
// Book hotel
hotelId = await ctx.run("book-hotel", () => hotelApi.book(trip.hotel));
// Book car
const carId = await ctx.run("book-car", () => carApi.book(trip.car));
return { flightId, hotelId, carId, status: "confirmed" };
} catch (error) {
// Compensate: cancel what was already booked
if (hotelId) await ctx.run("cancel-hotel", () => hotelApi.cancel(hotelId));
if (flightId) await ctx.run("cancel-flight", () => flightApi.cancel(flightId));
throw error;
}
},
},
});
Examples
Example 1: Reliable payment processing
User prompt: "Build a payment flow that never loses a charge — even if the server crashes between charging the card and updating the database."
The agent will use Restate durable execution to ensure each step (charge, update DB, send receipt) executes exactly once.
Example 2: Distributed saga for e-commerce
User prompt: "Implement an order workflow: reserve inventory → charge payment → ship. If any step fails, roll back everything."
The agent will create a Restate service with the saga pattern, compensating actions for each step, and durable state tracking.
Guidelines
ctx.run()for side effects — makes external calls durable and idempotent- Virtual objects for stateful entities — single-writer guarantee per key
- Sagas with try/catch — compensate in catch block, each compensation is also durable
- No message queues needed — Restate handles delivery and retries
ctx.sleep()for delays — durable timers that survive crashes- Service calls are durable —
ctx.serviceClient(svc).method()retries automatically - Shared handlers — read-only handlers that can run concurrently
- Simple programming model — write normal async functions, not state machines
- Self-hosted — single binary, Postgres or RocksDB for state
- HTTP invocation — trigger handlers via HTTP POST
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 Restate 分布式应用开发能力,解决持久执行、Saga 模式等实际工程问题
- 面向后端开发者,具有高实用价值和技术深度
- 代码示例完整,可直接用于生产环境
亮点
- 触发词覆盖全面且精准,包含核心概念和技术关键词
- 边界清晰,无歧义或重叠风险
亮点
- 结构清晰,分步骤说明完整
- frontmatter 信息完整,包含许可证和兼容性说明
- 提供端到端使用示例
亮点
- 工具来源明确,参数配置正确
- 异常处理机制完善(Saga 补偿模式)
- 提供自托管部署方案
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 37 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
翻译待完成,请参阅来源文档。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。