Skip to content

Commit

Permalink
Added docs for after commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Dec 18, 2024
1 parent 4e6258c commit ef8e32b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/packages/emmett/src/eventStore/eventStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,25 @@ export type DefaultEventStoreOptions<
Store extends EventStore,
HandlerContext = never,
> = {
/**
* Pluggable set of hooks informing about the event store internal behaviour.
*/
hooks?: {
/**
* This hook will be called **AFTER** events were stored in the event store.
* It's designed to handle scenarios where delivery and ordering guarantees do not matter much.
*
* **WARNINGS:**
*
* 1. It will be called **EXACTLY ONCE** if append succeded.
* 2. If the hook fails, its append **will still silently succeed**, and no error will be thrown.
* 3. Wen process crashes after events were committed, but before the hook was called, delivery won't be retried.
* That can lead to state inconsistencies.
* 4. In the case of high concurrent traffic, **race conditions may cause ordering issues**.
* For instance, where the second hook takes longer to process than the first one, ordering won't be guaranteed.
*
* @type {AfterEventStoreCommitHandler<Store, HandlerContext>}
*/
onAfterCommit?: AfterEventStoreCommitHandler<Store, HandlerContext>;
};
};

0 comments on commit ef8e32b

Please sign in to comment.