Foundationপ্রথম নীতি থেকে
LEVEL 9 · Distributed Systems

Event Sourcing

ইভেন্ট সোর্সিং

State নয়, state গড়ার event-গুলোই source of truth — বর্তমান state হলো replay-এর ফল।

also: event-store

events : AccountOpened → Deposited(100) → Withdrawn(40)
state  = fold(events) = balance 60

state নষ্ট? events আবার fold — এইজন্যই event immutable
  • Free audit log — প্রতিটা পরিবর্তনের who/when/why চিরদিন আছে; finance, inventory, collaboration history-তে অমূল্য
  • খরচও সৎভাবে: schema evolution (পুরনো event নতুন code-এ), snapshotting (fold shortcut), event idempotency (replay-এ duplicate নয়)
  • Message broker + consumer offset-এর সঙ্গে ঘনিষ্ঠ — log storage, ordered replay ধারণা একই, শুধু ভূমিকা database vs queue