Skip to content

introduce the Gnat.Supervisor macro#177

Draft
mmmries wants to merge 1 commit into
mainfrom
unified_interface
Draft

introduce the Gnat.Supervisor macro#177
mmmries wants to merge 1 commit into
mainfrom
unified_interface

Conversation

@mmmries

@mmmries mmmries commented Oct 19, 2024

Copy link
Copy Markdown
Collaborator

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.

@mmmries
mmmries requested a review from autodidaddict October 19, 2024 04:45
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