السّاغا (Sagas)
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
model a process as local transactions plus compensations.
الموضوعات المخطط لها
- A saga is a sequence of local transactions; each publishes the trigger for the next.
- If a step fails, earlier steps are undone by compensating transactions.
- Sagas give no isolation: others can see intermediate states (for example stock reserved but unpaid).
- Some steps cannot be undone (email sent); put those last or make them semantic ("send apology").
- Each step and compensation must be idempotent (MID-029).
تفاصيل المخطط المبدئي
عرض عملي
| Step | Local transaction | Compensation |
|---|---|---|
| 1 | Create order PENDING | Mark CANCELLED |
| 2 | Reserve stock | Release stock |
| 3 | Authorize payment | Void authorization |
| 4 | Confirm order | none (final) |
اختبر فهمك
Why is a saga not isolated like a database transaction?
أظهر الإجابة
Intermediate states are committed and visible to others.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.