/oban_notifiers_phoenix

An Oban.Notifier that uses an application's Phoenix.PubSub for notifications.

Primary LanguageElixirApache License 2.0Apache-2.0

Oban.Notifiers.Phoenix

An Oban.Notifier that uses Phoenix.PubSub for notifications.

The Phoenix notifier allows Oban to share a Phoenix application's PubSub for notifications. In addition to centralizing PubSub communications, it opens up the possible transports to all PubSub adapters.

Most importantly, as Oban already provides Postgres and PG notifiers, this package enables Redis notifications via the Phoenix.PubSub.Redis adapter.

Usage

This package currently requires features only available in Oban main. Until Oban v2.17 is published, you can use this package via GitHub:

defp deps do
  [
    {:oban, "~> 2.16", github: "sorentwo/oban"},
    {:oban_notifiers_phoenix, "~> 0.1", github: "sorentwo/oban_notifiers_phoenix"},
    ...
  ]
end

Make note of your application's Phoenix.PubSub instance name from the primary supervision tree:

def start(_type, _args) do
  children = [
    {Phoenix.PubSub, name: MyApp.PubSub},
    ...

Finally, configure Oban to use Oban.Notifiers.Phoenix as the notifier with the PubSub intance name as the :pubusb option:

config :my_app, Oban,
  notifier: {Oban.Notifiers.Phoenix, pubsub: MyApp.PubSub},
...

Contributing

Run mix test.ci locally to ensure changes will pass in CI. That alias executes the following commands:

  • Check formatting (mix format --check-formatted)
  • Check unused deps (mix deps.unlock --check-unused)
  • Lint with Credo (mix credo --strict)
  • Run all tests (mix test --raise)