What is the Reactor library and event-driven architectures in Elixir?
Answer
Reactor is a dynamic, concurrent workflow engine for Elixir, enabling saga patterns and complex business workflows with automatic compensation. Define a workflow: defmodule CheckoutFlow do; use Reactor; step :charge_card, ChargeCardStep; step :create_order, CreateOrderStep, max_retries: 3; step :send_email, SendEmailStep; end. Steps can be run in parallel, with dependencies, retries, and compensation (undo actions on failure). This goes beyond Broadway's linear pipelines to arbitrary DAG (Directed Acyclic Graph) workflows. Event-driven architecture patterns in Elixir: Phoenix PubSub: in-process or cluster-wide pub-sub (built into Phoenix). EventBus: publish-subscribe with filtering and transformation. CQRS with Commanded: event sourcing framework — all state changes as immutable events, projections rebuild read models from event stream. Commanded + EventStore: full event sourcing stack. Elixir's process model makes event-driven architectures particularly natural — each aggregate root can be a process maintaining its own state.
Previous
What are Elixir's process monitoring, tracing, and debugging tools?
Next
How does Elixir's Ecto handle complex queries and associations?
More Elixir Questions
View all →- Advanced What is the Elixir macro system and how does metaprogramming work?
- Advanced What is Elixir's GenServer deep internals and message queue management?
- Advanced What is Broadway in Elixir and how does it handle data pipelines?
- Advanced What is GenStage in Elixir?
- Advanced How does Elixir handle cluster formation and distributed state?