Last active
August 9, 2017 23:10
-
-
Save coline-carle/7891742a01637d36d7297cd0b5b01ab2 to your computer and use it in GitHub Desktop.
This file contains 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 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