|
|
@ -6,7 +6,7 @@ defmodule Explorer.Chain.Events.Listener do |
|
|
|
use GenServer |
|
|
|
use GenServer |
|
|
|
|
|
|
|
|
|
|
|
alias Postgrex.Notifications |
|
|
|
alias Postgrex.Notifications |
|
|
|
import Explorer.Chain, only: [extract_db_name: 1] |
|
|
|
import Explorer.Chain, only: [extract_db_name: 1, extract_db_host: 1] |
|
|
|
|
|
|
|
|
|
|
|
def start_link(_) do |
|
|
|
def start_link(_) do |
|
|
|
GenServer.start_link(__MODULE__, "chain_event", name: __MODULE__) |
|
|
|
GenServer.start_link(__MODULE__, "chain_event", name: __MODULE__) |
|
|
@ -22,6 +22,7 @@ defmodule Explorer.Chain.Events.Listener do |
|
|
|
{:ok, pid} = |
|
|
|
{:ok, pid} = |
|
|
|
explorer_repo |
|
|
|
explorer_repo |
|
|
|
|> Keyword.put(:database, extract_db_name(db_url)) |
|
|
|
|> Keyword.put(:database, extract_db_name(db_url)) |
|
|
|
|
|
|
|
|> Keyword.put(:hostname, extract_db_host(db_url)) |
|
|
|
|> Notifications.start_link() |
|
|
|
|> Notifications.start_link() |
|
|
|
|
|
|
|
|
|
|
|
ref = Notifications.listen!(pid, channel) |
|
|
|
ref = Notifications.listen!(pid, channel) |
|
|
|