Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. defmodule App1.Calculator do
  2. use GenServer
  3.  
  4. def add( num1, num2 ), do: GenServer.call( App1.Caclculator, {:add, num1, num2})
  5.  
  6. def handle_call({:add, num1, num2}, _from, state) do
  7. {:reply, {:ok, num1+num2}, state}
  8. end
  9. end
  10.  
  11. defmodule App1.Calculator do
  12. use GenServer
  13.  
  14. def handle_call({:add, num1, num2}, _from, state) do
  15. {:reply, {:ok, num1+num2}, state}
  16. end
  17. end
  18.  
  19. defmodule Service.Calculator do
  20. def add(num1, num2), do: GenServer.call(process_name, {:add, num1, num2})
  21.  
  22. # Just an example of how you might have named your node and calculator process
  23. def process_name, do: {:calculator, :"app1@127.0.0.1"}
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement