declare queues on genserver init
This commit is contained in:
parent
080b18c6be
commit
420b693728
@ -6,10 +6,11 @@ defmodule Scrapper.Queue.MatchQueue do
|
|||||||
GenServer.start_link(__MODULE__, {}, name: __MODULE__)
|
GenServer.start_link(__MODULE__, {}, name: __MODULE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec init({}) :: {:ok, {AMQP.Channel.t(), AMQP.Connection.t()}}
|
@spec init({}) :: {:ok, %{channel: AMQP.Channel.t(), connection: AMQP.Connection.t()}}
|
||||||
def init({}) do
|
def init({}) do
|
||||||
{:ok, connection} = AMQP.Connection.open()
|
{:ok, connection} = AMQP.Connection.open()
|
||||||
{:ok, channel} = AMQP.Channel.open(connection)
|
{:ok, channel} = AMQP.Channel.open(connection)
|
||||||
|
AMQP.Queue.declare(channel, "match", durable: true)
|
||||||
{:ok, %{:channel => channel, :connection => connection}}
|
{:ok, %{:channel => channel, :connection => connection}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ defmodule Scrapper.Queue.PlayerQueue do
|
|||||||
def init(_opts) do
|
def init(_opts) do
|
||||||
{:ok, connection} = AMQP.Connection.open()
|
{:ok, connection} = AMQP.Connection.open()
|
||||||
{:ok, channel} = AMQP.Channel.open(connection)
|
{:ok, channel} = AMQP.Channel.open(connection)
|
||||||
|
AMQP.Queue.declare(channel, "player", durable: true)
|
||||||
{:ok, {channel, connection}}
|
{:ok, {channel, connection}}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -18,7 +19,6 @@ defmodule Scrapper.Queue.PlayerQueue do
|
|||||||
nil -> GenServer.call(__MODULE__, {:queue_player, puuid})
|
nil -> GenServer.call(__MODULE__, {:queue_player, puuid})
|
||||||
_ -> :already_processed
|
_ -> :already_processed
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_call({:queue_player, puuid}, _from, {channel, _} = state) do
|
def handle_call({:queue_player, puuid}, _from, {channel, _} = state) do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user