انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهMID-031-L02

السّاغا (Sagas)

  • الدرس 2 من 8
  • Mid-level
في هذا الدرس 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).
تفاصيل المخطط المبدئي

عرض عملي

StepLocal transactionCompensation
1Create order PENDINGMark CANCELLED
2Reserve stockRelease stock
3Authorize paymentVoid authorization
4Confirm ordernone (final)

اختبر فهمك

Why is a saga not isolated like a database transaction?

أظهر الإجابة

Intermediate states are committed and visible to others.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.