Skip to content

Instantly share code, notes, and snippets.

@ayrat555
Created September 22, 2018 20:00
Show Gist options
  • Save ayrat555/513a943cfaac81449206ef7c06e47522 to your computer and use it in GitHub Desktop.
Save ayrat555/513a943cfaac81449206ef7c06e47522 to your computer and use it in GitHub Desktop.
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