An event-driven architecture is one in which agents can fire off and act in response to **Events**, which are discrete things that can happen in time. Event-driven architectures are one way of building functional [[Distributed Systems]]. - The mediator/[[Broker]] [[Code Design Patterns#Behavioral]] design pattern would be an example of an event-driven architecture - [[Kafka]] would be useful for an event-driven architecture. I would imagine unanticipated [[Emergent Behavior]] is a common concern in event-driven architectures. For an event-driven architecture you have to have: - **Events** - State changes or other occurrences happening in a system at discrete times - an event could be fired based on a parameter set within a sensor, for example - **Schema Registry** - A registry of event types that can occur - e.g. a taxonomy or [[Ontology]] of event types - **Topics** - Places to put events that *have* occurred - and the event logs (aka "Records") they contain, obviously - **Producers** - agents that can fire off (produce) events - **Consumers** - agents that act in response to events - **Subscriptions** - a capability to have a consumer subscribe to a type of event in a (set of) log(s) - **[[Broker]]** - an intermediary that sits between producers and consumers - Probably common, but also probably not strictly required (as is the case with the simple **observer** pattern) In the case of [[Kafka]], you also have consumer *groups*, which is how consumers are managed by the system to respond to events in an orchestrated way. ## Example: [[Home Assistant]] The [[Home Assistant]] platform is a pretty relatable[^1] example of an event-driven, service-oriented, [[Hub and Spoke Architecture]]. - Hub - Broker - the server running home assistant - Spokes - Producers - sensors hooked into the system - Consumers - actuators (smart devices like smart switches) consume messages generated by the broker stemming from events - Events - sensor thresholds being met, actuators setting their state, etc - Topics - the domains of events, such as temperatures, presence detection, etc **** # More ## Source - grad school - Gemini [^1]: in some circles, I guess