Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Commit

Permalink
Handle :closed message on receive, error on :error
Browse files Browse the repository at this point in the history
By handing the unexpected error return in the case statement, the error
would be silently swallowed.

Additional small whitespace cleanup -- couldn't resist.
  • Loading branch information
jtmoulia committed Sep 18, 2015
1 parent 1e89da7 commit fdb318b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions examples/rpc.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ defmodule RPC do
end

defp loop(state) do


# `Spell.cast_call` performs an asyncronous call to the remote procedure, the result will
# be intercepted and parsed by the block `Spell.receive_result`
{:ok, call_id} = Spell.cast_call(state.caller, state.procedure, state.params)
Logger.info("<Caller: #{inspect(state.caller)}> send params: #{inspect(state.params)}")

case Spell.receive_result(state.caller, call_id) do
{:ok, result} -> IO.inspect handle_result(state, result)
{:error, reason} -> {:error, reason}
{:ok, result} -> handle_result(state, result)
{:closed, reason} -> :ok
end

:timer.sleep(1000)
Expand Down

0 comments on commit fdb318b

Please sign in to comment.