Skip to content

Commit

Permalink
set publication and slot name through start function
Browse files Browse the repository at this point in the history
  • Loading branch information
abc3 committed Feb 3, 2022
1 parent 5807ea0 commit f8b8053
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
21 changes: 0 additions & 21 deletions README.md

This file was deleted.

22 changes: 19 additions & 3 deletions lib/ewalrus.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,28 @@ defmodule Ewalrus do
Start db poller.
"""
@spec start(String.t(), String.t(), String.t(), String.t(), String.t()) ::
@spec start(String.t(), String.t(), String.t(), String.t(), String.t(), String.t(), String.t()) ::
:ok | {:error, :already_started}
def start(scope, host, db_name, db_user, db_pass) do
def start(
scope,
host,
db_name,
db_user,
db_pass,
publication \\ "supabase_multiplayer",
slot_name \\ "supabase_multiplayer_replication_slot"
) do
case :global.whereis_name({:supervisor, scope}) do
:undefined ->
opts = [id: scope, db_host: host, db_name: db_name, db_user: db_user, db_pass: db_pass]
opts = [
id: scope,
db_host: host,
db_name: db_name,
db_user: db_user,
db_pass: db_pass,
publication: publication,
slot_name: slot_name
]

{:ok, pid} =
DynamicSupervisor.start_child(Ewalrus.RlsSupervisor, %{
Expand Down
4 changes: 2 additions & 2 deletions lib/ewalrus/db_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ defmodule Ewalrus.DbSupervisor do
backoff_min: 100,
backoff_max: 120_000,
replication_poll_interval: 1000,
publication: "supabase_multiplayer",
slot_name: "supabase_multiplayer_replication_slot",
publication: args[:publication],
slot_name: args[:slot_name],
max_record_bytes: 1_048_576
]

Expand Down

0 comments on commit f8b8053

Please sign in to comment.