aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Lasseter <nathan.je.lasseter@googlemail.com>2011-01-28 22:05:12 +0000
committerNathan Lasseter <nathan.je.lasseter@googlemail.com>2011-01-28 22:05:12 +0000
commit5bc3f93d9d3804af72ade9b4d5cd896f3b432cf4 (patch)
treeafa068156342baf4cc9139044e1c2e0a086b5474
parentd17fe944ccbfb25ff535d04aaee616df6672044b (diff)
Removed Balancer from server. Server responds to requestor.
-rw-r--r--TODO.textile2
-rw-r--r--erlbal.erl12
2 files changed, 6 insertions, 8 deletions
diff --git a/TODO.textile b/TODO.textile
index 2d10dfa..5a67ed4 100644
--- a/TODO.textile
+++ b/TODO.textile
@@ -2,10 +2,8 @@ h1. TODO
h2. Little changes:
-* Remove the Balancer variable from the server
* Add server state
* Remove the argless request call and implement strict listed args
-* Make the server return directly to the requester, not to the balancer
h2. BIG changes:
diff --git a/erlbal.erl b/erlbal.erl
index a3f22ca..5f599dc 100644
--- a/erlbal.erl
+++ b/erlbal.erl
@@ -2,7 +2,7 @@
-export([make_request/1, make_request/2, start_bal/0, stop_bal/1, start_server/3, stop_server/2, list_servers/1]).
start_server(Balancer, Node, Fun) ->
- PID = spawn(Node, fun() -> server_loop(Balancer, Fun) end),
+ PID = spawn(Node, fun() -> server_loop(Fun) end),
Balancer ! {add_node, PID}.
stop_server(Balancer, PID) ->
@@ -13,16 +13,16 @@ list_servers(Balancer) ->
Balancer ! {list_nodes, self()},
receive Nodes -> Nodes end.
-server_loop(Balancer, Fun) ->
+server_loop(Fun) ->
receive
{request, From} ->
Ret = Fun(),
- Balancer ! {response, From, Ret},
- server_loop(Balancer, Fun);
+ From ! Ret,
+ server_loop(Fun);
{request, From, ARGS} ->
Ret = Fun(ARGS),
- Balancer ! {response, From, Ret},
- server_loop(Balancer, Fun);
+ From ! Ret,
+ server_loop(Fun);
die ->
ok
end.