بنقرة واحدة
event-driven-architecture
Event-driven architecture patterns for asynchronous workflows and decoupled services.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Event-driven architecture patterns for asynchronous workflows and decoupled services.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Optimize token usage and context window discipline. Reduce costs and improve response quality through smart context management.
Unified context lifecycle for FlowDeck sessions — ingest, filter, prune, protect, summarize, and persist with telemetry.
Predict affected files, modules, APIs, tests, and DB paths before changes. Returns an impact map for human review.
Map architecture, conventions, and file structure into `.codebase/`. Use when onboarding or before deep feature work.
Plan differently when the agent has low certainty — ask for clarification or narrow scope instead of pretending full understanding.
Protect critical context from pruning during compaction. Preserve active plans, safety files, pending operations, and user intent anchors.
| name | event-driven-architecture |
| description | Event-driven architecture patterns for asynchronous workflows and decoupled services. |
| origin | FlowDeck |
Activate when:
Define what constitutes an "event" in your system:
OrderPlaced, PaymentProcessed)PlaceOrder, ProcessPayment)| Pattern | Use Case | Examples |
|---|---|---|
| Pub/Sub | One-to-many notification | Notifications, audit logs |
| Message Queue | Point-to-point processing | Order processing, email sending |
| Event Streaming | Durable, replayable event log | Event sourcing, analytics |
| Webhooks | External system integration | HTTP callbacks |
interface Event<T> {
id: string; // Unique event identifier (UUID)
type: string; // Event type (e.g., "ORDER_PLACED")
version: string; // Schema version for evolution
timestamp: string; // ISO 8601 timestamp
source: string; // Origin service name
data: T; // Event payload
metadata?: Record<string, unknown>; // Optional tracing/correlation
}
interface OrderEvent {
orderId: string;
customerId: string;
total: number;
items: OrderItem[];
}
class OrderEventPublisher {
private emitter: EventEmitter;
async publishOrderPlaced(event: OrderEvent): Promise<void> {
const message: Event<OrderEvent> = {
id: crypto.randomUUID(),
type: 'ORDER_PLACED',
version: '1.0',
timestamp: new Date().toISOString(),
source: 'order-service',
data: event,
metadata: {
correlationId: event.orderId,
partitionKey: event.customerId
}
};
await this.messageBroker.publish('orders.placed', message);
}
}
class OrderEventConsumer {
async handleOrderPlaced(event: Event<OrderEvent>): Promise<void> {
try {
// Idempotent processing
const existingOrder = await this.orderRepo.findById(event.data.orderId);
if (existingOrder) {
logger.info('Order already processed, skipping', { orderId: event.data.orderId });
return;
}
await this.orderService.processOrder(event.data);
await this.messageBroker.ack(event.id);
} catch (error) {
if (error instanceof TransientError) {
// Requeue with delay for retry
await this.messageBroker.requeue(event.id, { delay: 5000 });
} else {
// Send to dead letter queue
await this.messageBroker.sendToDlq(event, error);
}
}
}
}
// contracts/order-events.ts
export const OrderPlacedEventSchema = {
type: 'object',
required: ['orderId', 'customerId', 'total', 'items'],
properties: {
orderId: { type: 'string', format: 'uuid' },
customerId: { type: 'string', format: 'uuid' },
total: { type: 'number', minimum: 0 },
items: {
type: 'array',
items: {
type: 'object',
required: ['productId', 'quantity', 'price'],
properties: {
productId: { type: 'string' },
quantity: { type: 'number', minimum: 1 },
price: { type: 'number', minimum: 0 }
}
}
}
}
};