Created
September 22, 2018 20:00
-
-
Save ayrat555/513a943cfaac81449206ef7c06e47522 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule QuotesBot.Bot.Server do | |
use GenServer | |
alias QuotesBot.{Bot.Logic, Config} | |
def start_link(_) do | |
GenServer.start_link(__MODULE__, nil, []) | |
end | |
def handle_cast({:reply, update}, _state) do | |
update_id = Logic.reply(update) | |
{:noreply, update_id} | |
end | |
### Client | |
def reply(update) do | |
:poolboy.transaction( | |
:worker, | |
fn pid -> GenServer.cast(pid, {:reply, update}) end, | |
Config.poolboy_timeout | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment