Skip to content

Instantly share code, notes, and snippets.

@coline-carle
Last active August 9, 2017 23:10
Show Gist options
  • Save coline-carle/7891742a01637d36d7297cd0b5b01ab2 to your computer and use it in GitHub Desktop.
Save coline-carle/7891742a01637d36d7297cd0b5b01ab2 to your computer and use it in GitHub Desktop.
defmodule Armory.Worker do
use GenServer
@timeout 5000
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
end
def get(module, fun, args) do
:poolboy.transaction(:armory_pool,
&Genserver.call(&1,
{:get, module, fun, args},
@timeout)
)
end
def init(_) do
{:ok, nil}
end
def handle_call({:get, module, fun, args}, _from, state) do
response = apply(module, fun, args)
{:reply, respone, state}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment