When designing and implementing web interfaces to ensure they are usable by everyone.
中文简介正在准备中。当前显示原文说明。
When designing loosely coupled systems that react to state changes asynchronously.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Tightly coupled systems break and scale poorly. Event-driven architectures decouple producers from consumers by using immutable, timestamped facts as the communication mechanism. This enables systems to evolve independently, scale horizontally, and handle distributed failures gracefully.
OrderPlaced, UserRegistered, PaymentProcessed)OrderPlaced not PlaceOrder)SendEmailEvent) rather than facts (UserCreated)❌ Anti-pattern (Commands as events, synchronous coupling, no idempotency):
// WRONG: Command not event
publishEvent('SendEmail', { userId, subject });
// WRONG: Synchronous dependency
async function handleOrderPlaced(event) {
const order = await orderService.fetch(event.orderId); // Blocks on external service
await emailService.send(order.email); // Fails if service is down
}
// WRONG: No idempotency tracking - processes duplicate
async function handleUserCreated(event) {
await database.createUser(event); // Processes same event twice = duplicate user
}
✅ Correct pattern (Events, async, idempotent):
// CORRECT: Past-tense event with minimal payload
publishEvent({
type: 'UserCreated',
id: uuid(),
timestamp: new Date(),
payload: {
userId: event.userId,
email: event.email
}
});
// CORRECT: Asynchronous, idempotent consumer
async function handleUserCreated(event) {
// 1. Track processed events (idempotency)
const alreadyProcessed = await cache.get(`processed:${event.id}`);
if (alreadyProcessed) return; // Skip duplicate
// 2. Process without waiting for external services
await emailQueue.enqueue({
email: event.payload.email,
template: 'welcome'
});
// 3. Mark as processed
await cache.set(`processed:${event.id}`, true, { ttl: 86400 });
}
// 4. Dead Letter Queue for failed events
async function handleFailedEvent(event, error) {
await dlq.store({
originalEvent: event,
error: error.message,
timestamp: new Date(),
retryCount: 0
});
}
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
When designing and implementing web interfaces to ensure they are usable by everyone.
中文简介正在准备中。当前显示原文说明。
When creating or extending an HTTP API for client consumption.
中文简介正在准备中。当前显示原文说明。
When improving read performance and reducing database load.
中文简介正在准备中。当前显示原文说明。
When configuring automated build, test, and deployment workflows for a repository.
中文简介正在准备中。当前显示原文说明。
When asynchronously reviewing peer code before merging into the main branch.
中文简介正在准备中。当前显示原文说明。
When addressing slow application endpoints, high database CPU usage, or standardizing data access patterns.
中文简介正在准备中。当前显示原文说明。