在 Manus 中运行任何 Skill
一键导入
一键导入
一键在 Manus 中运行任何 Skill
开始使用microservices-design
星标3
分支0
更新时间2026年6月12日 02:14
微服务设计模式,涵盖服务网格、事件驱动架构、Saga 模式和 API 网关
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
微服务设计模式,涵盖服务网格、事件驱动架构、Saga 模式和 API 网关
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
单文件代码审查,6个维度逐项检查。覆盖正确性、安全性、性能、可维护性、测试、无障碍
CI/CD 流水线和容器化部署,覆盖 GitHub Actions、GitLab CI、Docker、测试策略和部署自动化
查询优化、索引策略和数据库性能调优,覆盖 PostgreSQL 和 MySQL
Web 性能优化,涵盖包分析、懒加载、缓存策略和 Core Web Vitals
TypeScript 进阶模式,涵盖泛型、条件类型、映射类型、模板字面量和类型守卫
UI 原型产出技能,根据选定风格生成静态 HTML 原型,作为 Builder 的设计契约
| name | microservices-design |
| description | 微服务设计模式,涵盖服务网格、事件驱动架构、Saga 模式和 API 网关 |
Define services around business capabilities, not technical layers. Each service owns its data store and exposes a clear API contract.
order-service/ -> owns orders table, publishes OrderCreated events
inventory-service/ -> owns inventory table, subscribes to OrderCreated
payment-service/ -> owns payments table, handles payment processing
notification-service -> stateless, subscribes to events, sends emails/SMS
interface DomainEvent {
eventId: string;
eventType: string;
aggregateId: string;
timestamp: string;
version: number;
payload: Record<string, unknown>;
}
const orderCreatedEvent: DomainEvent = {
eventId: crypto.randomUUID(),
eventType: "order.created",
aggregateId: orderId,
timestamp: new Date().toISOString(),
version: 1,
payload: { customerId, items, totalAmount },
};
await broker.publish("orders", orderCreatedEvent);
async function handleOrderCreated(event: DomainEvent) {
const { items } = event.payload as OrderPayload;
for (const item of items) {
await db.inventory.update({
where: { productId: item.productId },
data: { quantity: { decrement: item.quantity } },
});
}
await markEventProcessed(event.eventId);
}
Use idempotency keys (eventId) to handle duplicate deliveries safely.
class OrderSaga {
private steps: SagaStep[] = [
{
name: "reserveInventory",
execute: (ctx) => inventoryService.reserve(ctx.items),
compensate: (ctx) => inventoryService.release(ctx.items),
},
{
name: "processPayment",
execute: (ctx) => paymentService.charge(ctx.customerId, ctx.amount),
compensate: (ctx) => paymentService.refund(ctx.paymentId),
},
{
name: "confirmOrder",
execute: (ctx) => orderService.confirm(ctx.orderId),
compensate: (ctx) => orderService.cancel(ctx.orderId),
},
];
async run(context: SagaContext): Promise<void> {
const completed: SagaStep[] = [];
for (const step of this.steps) {
try {
const result = await step.execute(context);
Object.assign(context, result);
completed.push(step);
} catch (error) {
for (const s of completed.reverse()) {
await s.compensate(context);
}
throw new SagaFailedError(step.name, error);
}
}
}
}
# Kong or similar gateway config
services:
- name: orders
url: http://order-service:3000
routes:
- paths: ["/api/v1/orders"]
methods: [GET, POST]
plugins:
- name: rate-limiting
config:
minute: 100
- name: jwt
- name: correlation-id
- name: users
url: http://user-service:3000
routes:
- paths: ["/api/v1/users"]
plugins:
- name: rate-limiting
config:
minute: 200
app.get("/health", async (req, res) => {
const checks = {
database: await checkDatabase(),
cache: await checkRedis(),
broker: await checkMessageBroker(),
};
const healthy = Object.values(checks).every(c => c.status === "up");
res.status(healthy ? 200 : 503).json({
status: healthy ? "healthy" : "degraded",
checks,
version: process.env.APP_VERSION,
uptime: process.uptime(),
});
});