silo_events (faber_neuroevolution v1.2.4)
View SourceSilo Event Publishing for Liquid Conglomerate.
Part of the Liquid Conglomerate v2 event-driven architecture. This module provides topic definitions and publishing helpers for cross-silo communication.
Event-Driven Architecture
Instead of direct lc_cross_silo:emit() calls (imperative push), silos now publish events to topics. Interested parties subscribe and react.
Topic Hierarchy
silo.SILONAME.signals - Cross-silo signals from a specific silo silo.SILONAME.lifecycle - Silo lifecycle events (activated, deactivated) silo.aggregated.signals - Aggregated view from lc_cross_silo
Summary
Functions
Get all silo names in the Liquid Conglomerate.
Get the lifecycle topic for a silo.
Publish a silo lifecycle event.
Publish recommendations from a silo.
Publish a single signal from a silo.
Publish multiple signals from a silo.
Get the recommendations topic for a silo.
Get the signal topic for a silo.
Subscribe the calling process to signals from all silos.
Subscribe a specific process to signals from all silos.
Subscribe the calling process to recommendations from a specific silo.
Subscribe a specific process to recommendations from a silo.
Subscribe the calling process to signals from a specific silo.
Subscribe a specific process to signals from a silo.
Unsubscribe from a specific silo's recommendations.
Unsubscribe from a specific silo's signals.
Types
-type lifecycle_event() :: activated | deactivated | config_changed.
-type signal_name() :: atom().
-type signal_value() :: number().
-type silo_name() ::
task | resource | distribution | temporal | competitive | social | cultural | ecological |
morphological | developmental | regulatory | economic | communication.
Functions
-spec all_silo_names() -> [silo_name()].
Get all silo names in the Liquid Conglomerate.
Get the lifecycle topic for a silo.
Returns: binary "silo.NAME.lifecycle"
-spec publish_lifecycle(silo_name(), lifecycle_event()) -> ok.
Publish a silo lifecycle event.
Used for silo activation, deactivation, and configuration changes.
Publish recommendations from a silo.
Used for event-driven read models. Silos publish their recommendations whenever they change, and consumers cache the latest values locally. This replaces blocking get_recommendations() calls with cached lookups.
Event format (map with keys): event_type - binary "silo_recommendations" timestamp - millisecond timestamp silo - silo name atom recommendations - map of recommendation data
Silo usage: Call publish_recommendations/2 when recommendations change.
Consumer usage: Subscribe via subscribe_to_recommendations/1, then handle {silo_recommendations, SiloName, Recs} messages in handle_info.
-spec publish_signal(silo_name(), signal_name(), signal_value()) -> ok.
Publish a single signal from a silo.
Event format (map with keys): event_type - binary "silo_signal" timestamp - millisecond timestamp from - source silo name signal - signal name atom value - numeric signal value
-spec publish_signals(silo_name(), #{signal_name() => signal_value()}) -> ok.
Publish multiple signals from a silo.
More efficient than multiple single publishes. Event format (map with keys): event_type - binary "silo_signals" timestamp - millisecond timestamp from - source silo name signals - map of signal_name to value
Get the recommendations topic for a silo.
Returns: binary "silo.NAME.recommendations"
Get the signal topic for a silo.
Returns: binary "silo.NAME.signals"
-spec subscribe_to_all_silos() -> ok.
Subscribe the calling process to signals from all silos.
-spec subscribe_to_all_silos(pid()) -> ok.
Subscribe a specific process to signals from all silos.
-spec subscribe_to_recommendations(silo_name()) -> ok.
Subscribe the calling process to recommendations from a specific silo.
Events are delivered as: {silo_recommendations, SiloName, RecommendationsMap}
Subscribe a specific process to recommendations from a silo.
-spec subscribe_to_silo(silo_name()) -> ok.
Subscribe the calling process to signals from a specific silo.
Subscribe a specific process to signals from a silo.
-spec unsubscribe_from_recommendations(silo_name()) -> ok.
Unsubscribe from a specific silo's recommendations.
-spec unsubscribe_from_silo(silo_name()) -> ok.
Unsubscribe from a specific silo's signals.