Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce the Gnat.Supervisor macro #177

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

mmmries
Copy link
Collaborator

@mmmries mmmries commented Oct 19, 2024

This PR is an attempt to create a unified interace as described in #62

It follows a similar pattern to Ecto.Repo by allowing clients of the library to define their own module like this

defmodule MyApp.Gnat do
  use Gnat.Supervisor, otp_app: :my_app
end

Then in their application configurations they can provide configuration like

import Config

config :my_app, MyApp.Gnat,
  connection_settings: [%{host: ~c"localhost", port: 4222, ...}],
  consumers: [
    %{module: MyApp.Server, subscription_topics: [%{topic: "rpc.MyApp.search", queue_group: "rpc.MyApp.search"}]
  ]

Then they can add a single entry to their application supervision tree

children = [MyApp.Gnat]

And we'll start the ConnectionSupervisor, ConsumerSupervisor and other supervisors automatically for them. The user can also call functions like MyApp.Gnat.pub/2 where they don't have to specify the name or pid of the connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants