Event-Driven Patterns with Firestone
Firestone's AsyncAPI generation is designed to support common event-driven architecture (EDA) patterns. By configuring your resource schema, you can define the contract for various communication styles.
Supported Patterns:
-
Pub/Sub (Publish/Subscribe):
- Concept: A resource change (e.g.,
OrderCreated) is published to a topic. Multiple subscribers react to it. - Firestone Config: Enable
channels: { resources: true }. This generates a channel for the collection (e.g.,orders). - AsyncAPI Output: Defines a
publishoperation on theorderschannel.
- Concept: A resource change (e.g.,
-
Event Sourcing (State Streaming):
- Concept: Streaming the state changes of a specific entity (e.g.,
StockPriceupdates). - Firestone Config: Enable
channels: { instances: true }. This generates a channel for specific IDs (e.g.,stocks/{symbol}). - AsyncAPI Output: Defines a
subscribeoperation on thestocks/{symbol}channel.
- Concept: Streaming the state changes of a specific entity (e.g.,
-
Attribute-Level Notifications:
- Concept: Notifying only when a specific field changes (e.g.,
DocumentContentupdate). - Firestone Config: Enable
channels: { instance_attrs: true }. - AsyncAPI Output: Generates granular channels like
documents/{id}/content.
- Concept: Notifying only when a specific field changes (e.g.,
For architectural guidance on implementing these patterns in your backend, refer to:
Firestone ensures your event schemas stay strictly synchronized with your resource definitions, preventing "schema drift" between your REST and Async interfaces.