PubSubx.Auto (pub_subx v0.2.1)

Provides a macro to automatically generate common PubSubx functionality for a module, including function specifications.

Usage

To use this module, include PubSubx.Auto in your module and provide the :name option:

defmodule MyPubSub do
  use PubSubx.Auto, name: MyPubSub
end

This will create functions such as start_link/0, subscribe/2, publish/2, etc., with specifications that use the provided name for PubSubx operations.

Functions

The following functions are automatically defined in the module:

  • start_link/0: Starts the PubSubx server with the specified name.
  • subscribe/2: Subscribes a given process to a topic.
  • subscribers/1: Retrieves a list of subscribers for a given topic.
  • topics/0: Lists all topics with at least one subscriber.
  • publish/2: Publishes a message to a given topic.
  • unsubscribe/2: Unsubscribes a given process from a topic.