ExESDB.PubSubIntegration (ex_esdb v0.11.0)
Helper module for consistent pubsub integration across ExESDB modules.
This module provides standardized functions for broadcasting events to the ExESDBGater pubsub system, with built-in error handling and optional enablement/disablement of pubsub features.
This module now uses ExESDB.OperationalMessageHelpers to ensure consistent node tracking fields, millisecond-precision timestamps, and message validation across all operational message types.
Configuration
Add to your config to enable pubsub integration:
config :ex_esdb,
pubsub_integration: true,
health_broadcast_interval: 30_000,
metrics_broadcast_interval: 60_000
Usage Examples
# System lifecycle events with standardized nodes and timestamps
ExESDB.PubSubIntegration.broadcast_system_lifecycle(:started, :ex_esdb, "1.0.0")
# Health updates with consistent node tracking
ExESDB.PubSubIntegration.broadcast_health_update(:store_worker, :healthy, %{store_id: "main"})
# Metrics with precise timestamps
ExESDB.PubSubIntegration.broadcast_metrics(:persistence, %{operations: 100, errors: 0})
# Alerts with ExESDBGater compatibility
ExESDB.PubSubIntegration.broadcast_alert(:node_failure, :critical, "Node down", %{node: :node1})
Summary
Functions
Broadcast critical alerts and notifications.
Broadcast audit trail events for compliance and tracking.
Broadcast multiple events in a batch for efficiency.
Broadcast cluster-wide health status.
Broadcast diagnostic information for debugging and troubleshooting.
Legacy function for backward compatibility - broadcasts to component_health topic.
Broadcast process and node lifecycle events.
Broadcast component performance metrics.
Broadcast store-specific component health updates using store_id for topic generation.
Broadcast system configuration changes.
Broadcast system lifecycle events (startup, shutdown, config changes).
Disable pubsub integration at runtime.
Enable pubsub integration at runtime.
Check if pubsub integration is enabled.
Get the configured health broadcast interval.
Get the configured metrics broadcast interval.
Validate messaging compatibility between ExESDB and ExESDBGater.
Functions
Broadcast critical alerts and notifications.
Broadcast audit trail events for compliance and tracking.
Broadcast multiple events in a batch for efficiency.
Broadcast cluster-wide health status.
Broadcast diagnostic information for debugging and troubleshooting.
Legacy function for backward compatibility - broadcasts to component_health topic.
Broadcast process and node lifecycle events.
Broadcast component performance metrics.
Broadcast store-specific component health updates using store_id for topic generation.
Broadcast system configuration changes.
Broadcast system lifecycle events (startup, shutdown, config changes).
Disable pubsub integration at runtime.
Enable pubsub integration at runtime.
Check if pubsub integration is enabled.
Get the configured health broadcast interval.
Get the configured metrics broadcast interval.
Validate messaging compatibility between ExESDB and ExESDBGater.
This function tests that operational messages can be created and validated using both systems' message patterns.