Skip to content

Commit

Permalink
config: add typespec for WalEx config options
Browse files Browse the repository at this point in the history
  • Loading branch information
DaemonSnake committed May 28, 2024
1 parent 0b88ca1 commit 8a5c97a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/walex/config/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ defmodule WalEx.Config do
@allowed_config_value ~w(database hostname name password port publication username webhook_signing_secret slot_name durable_slot message_middleware)a
@allowed_config_values ~w(destinations event_relay modules subscriptions)a

@type destinations_t :: [
{:modules, [module]} | {:webhooks, [binary]} | {:event_relay_topic, binary}
]

@type start_opts :: [
{:database, binary}
| {:hostname, binary}
| {:name, binary}
| {:password, binary}
| {:port, binary}
| {:publication, binary}
| {:username, binary}
| {:webhook_signing_secret, binary}
| {:slot_name, binary}
| {:durable_slot, boolean}
| {:message_middleware, (term, term -> :ok)}
| {:destinations, destinations_t()}
| {:event_relay, keyword()}
| {:modules, [module]}
| {:subscriptions, [binary()]}
]

@spec start_link(opts :: start_opts()) :: Agent.on_start()
def start_link(opts) do
configs =
opts
Expand Down
1 change: 1 addition & 0 deletions lib/walex/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule WalEx.Supervisor do
alias WalEx.Replication.Supervisor, as: ReplicationSupervisor
alias WalExConfig.Registry, as: WalExRegistry

@spec start_link(opts :: WalExConfig.start_opts()) :: Supervisor.on_start()
def start_link(opts) do
app_name = Keyword.get(opts, :name)
module_names = build_module_names(app_name, opts)
Expand Down

0 comments on commit 8a5c97a

Please sign in to comment.