Observers and Broadcasts
Observers and Broadcasts facilitate event-driven communication within a node, allowing actors to react to environmental data and skill requests without direct, point-to-point coupling.
Observers
An Observer is a powerful annotation that can be attached to an actor. It allows an actor to monitor network activity passively rather than providing the targeted skill itself.
- Passive Monitoring: The actor does not provide the annotated skill. Instead, it "watches" the stream of requests and data for that specific skill within the node.
- Logic Triggering: An observer allows the actor to execute internal logic based on a defined set of parameters within the incoming data stream.
- Stream-Based: Observers are designed to handle continuous streams of data, making them ideal for monitoring state changes or recurring events.
Broadcasts
Technically categorized as a skillset rather than an actor, a Broadcast is the is an usual source for the observation model. It functions exactly as the name implies: a transmission of information to the node.
- Node-Wide Availability: A broadcasted bit of information is made available to the entire node.
- Decoupled Data Flow: A broadcast is usually the "other end" of an observer. The broadcasting entity does not need to know which (if any) actors are observing the data.
Example: Environmental Awareness
Consider a scenario involving a weather-monitoring system:
- The Broadcast: An Ongoing Weather Actor broadcasts current humidity levels to the node at all times. This is defined as a broadcast skillset.
- The Observation: Multiple other actors on the same node use the Observer annotation to monitor that specific humidity broadcast skill.
- The Reaction: These observing actors adjust their operational logic in real-time based on the incoming data. For instance:
- An Irrigation Actor might see high humidity and choose to skip a scheduled watering cycle.
- A Dehumidifier Actor might trigger a "High Power" mode based on the same stream.
In this model, the Weather Actor simply broadcasts, while the observing actors maintain the autonomy to decide how that data impacts their specific functions.