Last active
October 17, 2015 16:22
-
-
Save gjaldon/6e0dfc7700299eaccad4 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
def async_query(pid, statement, params) do | |
message = {:query, statement, params} | |
process = GenServer.whereis(pid) | |
monitor = Process.monitor(process) | |
from = {self(), monitor} | |
:ok = Connection.cast(pid, {message, from}) | |
%Task{ref: monitor} | |
end | |
def handle_cast({{:query, _, _} = command, {_, monitor} = from}, s) do | |
:ok = handle_call(command, from, s) | |
{:no_reply, s} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment