public
Description: A new revision of Fuzed, the Erlang-based frontend for web apps. Check out the mailing list at http://groups.google.com/group/fuzed
Clone URL: git://github.com/KirinDave/fuzed.git
Search Repo:
Making the responder module user-specifiable.
KirinDave (author)
Sun May 11 20:03:17 -0700 2008
commit  0f6b09930784a37191dea47fb2b19559e192e657
tree    59bc030ea33e4f910ac7abbb67d6f62ec63aef78
parent  fc71cc0e7fcfd4e09c6114963835356a9922bc64
...
2
3
4
5
6
 
 
 
 
...
2
3
4
 
 
5
6
7
8
0
@@ -2,6 +2,8 @@
0
 -include("responder_base.erl").
0
 -compile(export_all).
0
 
0
-provide_pool(_A) ->
0
- resource_fountain:best_pool_for_details_match(details()).
0
+% This responder can modify the request, and is obligated to return
0
+% a pool and the request. You can just return it directly if you want.
0
+provide_pool(A, _GC, _SC) ->
0
+ {resource_fountain:best_pool_for_details_match(details()), A}.
...
3
4
5
6
7
8
9
 
 
10
11
12
13
14
 
15
16
17
...
31
32
33
34
 
35
36
37
...
3
4
5
 
 
 
 
6
7
8
 
 
 
 
9
10
11
12
...
26
27
28
 
29
30
31
32
0
@@ -3,15 +3,10 @@
0
 -include("../include/yaws/yaws.hrl").
0
 
0
 
0
-test() ->
0
- ModuleFilePath = code:which(?MODULE),
0
- DirPath = filename:dirname(ModuleFilePath),
0
- yaws_begin_server(yaws_global_configs(9001, DirPath ++ "/../web")).
0
+setup(Port, DocRoot, Responder) ->
0
+ yaws_begin_server(yaws_global_configs(Port, DocRoot, Responder)).
0
 
0
-setup(Port, DocRoot) ->
0
- yaws_begin_server(yaws_global_configs(Port, DocRoot)).
0
-
0
-yaws_global_configs(Port, DocRoot) ->
0
+yaws_global_configs(Port, DocRoot, Responder) ->
0
   Y = yaws_config:yaws_dir(),
0
   GC = #gconf{yaws_dir = Y,
0
               ebin_dir = [],
0
@@ -31,7 +26,7 @@
0
               servername = "xle_responder",
0
               listen = {0,0,0,0},
0
               docroot = DocRoot,
0
- errormod_404 = frontend_responder,
0
+ errormod_404 = Responder,
0
               appmods = []},
0
   {GC,SC}.
0
 
...
22
23
24
 
25
26
27
28
29
30
31
 
32
33
34
...
51
52
53
 
 
 
 
 
 
 
 
...
22
23
24
25
26
27
28
29
30
31
 
32
33
34
35
...
52
53
54
55
56
57
58
59
60
61
62
0
@@ -22,13 +22,14 @@
0
   Master = application:get_env(master),
0
   {ok, DocRoot} = application:get_env(docroot),
0
   {ok, Port} = application:get_env(port),
0
+ ResponderModule = figure_responder(),
0
   case Master of
0
     {ok, MasterNode} ->
0
       ping_master(MasterNode);
0
     undefined ->
0
       MasterNode = node()
0
   end,
0
- frontend_yaws:setup(Port, DocRoot),
0
+ frontend_yaws:setup(Port, DocRoot, ResponderModule),
0
   {ok, {{one_for_one, 10, 600},
0
         [{master_beater,
0
           {master_beater, start_link, [MasterNode, ?GLOBAL_TIMEOUT, ?SLEEP_CYCLE]},
0
@@ -51,4 +52,12 @@
0
       timer:sleep(?SLEEP_CYCLE),
0
       ping_master(Node)
0
   end.
0
+
0
+figure_responder() ->
0
+ case application:get_env(responder) of
0
+ {ok, Module} ->
0
+ Module;
0
+ undefined -> frontend_responder
0
+ end.
0
+
...
3
4
5
6
 
 
7
8
9
10
11
12
...
3
4
5
 
6
7
8
 
 
9
10
11
0
@@ -3,10 +3,9 @@
0
 -include("fuzed.hrl").
0
 -export([out404/3]).
0
 
0
-out404(A, _GC, SC) ->
0
+out404(Arg, GC, SC) ->
0
+ {Pool, A} = provide_pool(Arg, GC, SC),
0
   Parameters = [{request, {struct, parse_arg(A, SC)}}],
0
- io:format("Param restructure:~n~p~n", [Parameters]),
0
- Pool = provide_pool(A),
0
   case node_api:safely_send_call_to_pool_no_lookup(handle_request,
0
                                                    Parameters,
0
                                                    pure,
...
60
61
62
 
 
 
 
63
64
65
...
73
74
75
 
 
 
 
 
76
77
78
...
90
91
92
 
93
94
95
...
60
61
62
63
64
65
66
67
68
69
...
77
78
79
80
81
82
83
84
85
86
87
...
99
100
101
102
103
104
105
0
@@ -60,6 +60,10 @@
0
     options[:port] = dir
0
   end
0
 
0
+ opts.on("-f", "--frontend-responder MODULE", "Module to use for Pool calculation.") do |mod|
0
+ options[:module] = mod
0
+ end
0
+
0
   opts.on("-?", "--help", "Display arguments.") do
0
     puts opts
0
     exit(0)
0
@@ -73,6 +77,11 @@
0
 spec = options[:spec] || "kind=normal"
0
 details = details_from_string(spec)
0
 port = options[:port] || "8080"
0
+mod = if options[:module]
0
+ "-fuzed_frontend responder #{options[:module]}"
0
+ else
0
+ ""
0
+ end
0
 
0
 if master !~ /@/
0
   abort "Please specify fully qualified master node name e.g. -m master@fuzed.tools.powerset.com"
0
@@ -90,6 +99,7 @@
0
              -fuzed_frontend details #{details} \
0
              -fuzed_frontend docroot '"#{docroot}"' \
0
              -fuzed_frontend port #{port} \
0
+ #{mod} \
0
              -config '#{FUZED_ROOT}/conf/fuzed_base' \
0
              -run fuzed_frontend start}.squeeze(' ')
0
 puts cmd

Comments

    No one has commented yet.