BCUtils.PubSubManager (bc_utils v0.14.0)
Manages Phoenix.PubSub startup to avoid conflicts when multiple applications in the same VM try to start the same PubSub instance.
This module provides utilities to:
- Check if a PubSub instance is already running
 - Conditionally start PubSub only if needed
 - Provide graceful fallbacks for shared PubSub instances
 - Health check existing PubSub instances
 
Usage
In your supervision tree:
children = [
  BCUtils.PubSubManager.maybe_child_spec(:my_pubsub),
  # other children...
]
|> Enum.filter(& &1)  # Remove nil entriesDependencies
This module requires phoenix_pubsub to be available at runtime.
Add it to your mix.exs:
{:phoenix_pubsub, "~> 2.1"}
    Summary
Functions
Returns a child spec for Phoenix.PubSub if not already started, otherwise nil.
Functions
Returns a child spec for Phoenix.PubSub if not already started, otherwise nil.
This is the recommended way to use this module in supervision trees.
Examples
# Will start PubSub if not running
BCUtils.PubSubManager.maybe_child_spec(:my_pubsub)
# Will return nil if already running
BCUtils.PubSubManager.maybe_child_spec(:my_pubsub)
# Usage in supervision tree
children = [
  BCUtils.PubSubManager.maybe_child_spec(:ex_esdb_pubsub),
  # other children...
]
|> Enum.filter(& &1)  # Remove nil entriesParameters
pubsub_name- The atom name for the PubSub instance, or nilopts- Additional options to pass to Phoenix.PubSub (default: [])
Returns
{Phoenix.PubSub, keyword()}- Child spec if PubSub needs to be startednil- If PubSub is already running or pubsub_name is nil