Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Some whitespace cleanup for clarity (no semantic changes).

  • Loading branch information...
commit 1411851963959dbca13747b9ce802801a4444a13 1 parent 5580b96
Prashanth Mundkur authored January 19, 2012

Showing 1 changed file with 51 additions and 46 deletions. Show diff stats Hide diff stats

  1. 97  master/src/disco_web.erl
97  master/src/disco_web.erl
... ...
@@ -1,4 +1,3 @@
1  
-
2 1
 -module(disco_web).
3 2
 -export([op/3]).
4 3
 
@@ -63,9 +62,9 @@ getop("load_config_table", _Query) ->
63 62
 
64 63
 getop("joblist", _Query) ->
65 64
     {ok, Jobs} = gen_server:call(event_server, get_jobs),
66  
-    {ok, [[1000000 * MSec + Sec, list_to_binary(atom_to_list(Status)), Name] ||
67  
-        {Name, Status, {MSec, Sec, _USec}, _Pid}
68  
-            <- lists:reverse(lists:keysort(3, Jobs))]};
  65
+    {ok, [[1000000 * MSec + Sec, list_to_binary(atom_to_list(Status)), Name]
  66
+          || {Name, Status, {MSec, Sec, _USec}, _Pid}
  67
+                 <- lists:reverse(lists:keysort(3, Jobs))]};
69 68
 
70 69
 getop("jobinfo", {_Query, JobName}) ->
71 70
     {ok, Active} = disco_server:get_active(JobName),
@@ -88,11 +87,11 @@ getop("jobevents", {Query, Name}) ->
88 87
     {value, {_, NumS}} = lists:keysearch("num", 1, Query),
89 88
     Num = list_to_integer(NumS),
90 89
     Q = case lists:keysearch("filter", 1, Query) of
91  
-        false -> "";
92  
-        {value, {_, F}} -> string:to_lower(F)
93  
-    end,
  90
+            false -> "";
  91
+            {value, {_, F}} -> string:to_lower(F)
  92
+        end,
94 93
     {ok, Ev} = gen_server:call(event_server,
95  
-        {get_job_events, Name, string:to_lower(Q), Num}),
  94
+                               {get_job_events, Name, string:to_lower(Q), Num}),
96 95
     {raw, Ev};
97 96
 
98 97
 getop("nodeinfo", _Query) ->
@@ -128,17 +127,18 @@ getop("nodeinfo", _Query) ->
128 127
 getop("get_blacklist", _Query) ->
129 128
     {ok, Nodes} = disco_server:get_nodeinfo(all),
130 129
     {ok, [list_to_binary(N#nodeinfo.name)
131  
-            || N <- Nodes, N#nodeinfo.blacklisted]};
  130
+          || N <- Nodes, N#nodeinfo.blacklisted]};
132 131
 
133 132
 getop("get_settings", _Query) ->
134 133
     L = [max_failure_rate],
135 134
     {ok, {struct, lists:filter(fun(X) -> is_tuple(X) end,
136  
-        lists:map(fun(S) ->
137  
-            case application:get_env(disco, S) of
138  
-                {ok, V} -> {S, V};
139  
-                _ -> false
140  
-            end
141  
-        end, L))}};
  135
+                               lists:map(
  136
+                                 fun(S) ->
  137
+                                     case application:get_env(disco, S) of
  138
+                                         {ok, V} -> {S, V};
  139
+                                         _ -> false
  140
+                                     end
  141
+                                 end, L))}};
142 142
 
143 143
 getop("get_mapresults", {_Query, Name}) ->
144 144
     case gen_server:call(event_server, {get_map_results, Name}) of
@@ -150,7 +150,8 @@ getop("get_mapresults", {_Query, Name}) ->
150 150
 
151 151
 getop(_, _) -> not_found.
152 152
 
153  
--spec validate_payload(nonempty_string(), json_validator:spec(), term(), fun((term()) -> T)) -> T.
  153
+-spec validate_payload(nonempty_string(), json_validator:spec(),
  154
+                       term(), fun((term()) -> T)) -> T.
154 155
 validate_payload(_Op, Spec, Payload, Fun) ->
155 156
     case json_validator:validate(Spec, Payload) of
156 157
         ok -> Fun(Payload);
@@ -160,25 +161,28 @@ validate_payload(_Op, Spec, Payload, Fun) ->
160 161
     end.
161 162
 
162 163
 postop("kill_job", Json) ->
163  
-    validate_payload("kill_job", string, Json, fun(J) ->
164  
-                                           JobName = binary_to_list(J),
165  
-                                           disco_server:kill_job(JobName),
166  
-                                           {ok, <<>>}
167  
-                                   end);
  164
+    validate_payload("kill_job", string, Json,
  165
+                     fun(J) ->
  166
+                             JobName = binary_to_list(J),
  167
+                             disco_server:kill_job(JobName),
  168
+                             {ok, <<>>}
  169
+                     end);
168 170
 
169 171
 postop("purge_job", Json) ->
170  
-    validate_payload("purge_job", string, Json, fun(J) ->
171  
-                                           JobName = binary_to_list(J),
172  
-                                           disco_server:purge_job(JobName),
173  
-                                           {ok, <<>>}
174  
-                                   end);
  172
+    validate_payload("purge_job", string, Json,
  173
+                     fun(J) ->
  174
+                             JobName = binary_to_list(J),
  175
+                             disco_server:purge_job(JobName),
  176
+                             {ok, <<>>}
  177
+                     end);
175 178
 
176 179
 postop("clean_job", Json) ->
177  
-    validate_payload("clean_job", string, Json, fun(J) ->
178  
-                                           JobName = binary_to_list(J),
179  
-                                           disco_server:clean_job(JobName),
180  
-                                           {ok, <<>>}
181  
-                                   end);
  180
+    validate_payload("clean_job", string, Json,
  181
+                     fun(J) ->
  182
+                             JobName = binary_to_list(J),
  183
+                             disco_server:clean_job(JobName),
  184
+                             {ok, <<>>}
  185
+                     end);
182 186
 
183 187
 postop("get_results", Json) ->
184 188
     Results = fun(N) -> gen_server:call(event_server, {get_results, N}) end,
@@ -191,18 +195,20 @@ postop("get_results", Json) ->
191 195
                      end);
192 196
 
193 197
 postop("blacklist", Json) ->
194  
-    validate_payload("blacklist", string, Json, fun(J) ->
195  
-                                           Node = binary_to_list(J),
196  
-                                           disco_config:blacklist(Node),
197  
-                                           {ok, <<>>}
198  
-                                   end);
  198
+    validate_payload("blacklist", string, Json,
  199
+                     fun(J) ->
  200
+                             Node = binary_to_list(J),
  201
+                             disco_config:blacklist(Node),
  202
+                             {ok, <<>>}
  203
+                     end);
199 204
 
200 205
 postop("whitelist", Json) ->
201  
-    validate_payload("whitelist", string, Json, fun(J) ->
202  
-                                           Node = binary_to_list(J),
203  
-                                           disco_config:whitelist(Node),
204  
-                                           {ok, <<>>}
205  
-                                   end);
  206
+    validate_payload("whitelist", string, Json,
  207
+                     fun(J) ->
  208
+                             Node = binary_to_list(J),
  209
+                             disco_config:whitelist(Node),
  210
+                             {ok, <<>>}
  211
+                     end);
206 212
 
207 213
 postop("save_config_table", Json) ->
208 214
     validate_payload("save_config_table", {hom_array, {array, [string, string]}},
@@ -228,7 +234,7 @@ job_file(Name, File) ->
228 234
 
229 235
 update_setting(<<"max_failure_rate">>, Val, App) ->
230 236
     ok = application:set_env(App, max_failure_rate,
231  
-        list_to_integer(binary_to_list(Val)));
  237
+                             list_to_integer(binary_to_list(Val)));
232 238
 
233 239
 update_setting(Key, Val, _) ->
234 240
     error_logger:info_report([{"Unknown setting", Key, Val}]).
@@ -291,11 +297,10 @@ wait_jobs(Jobs, Timeout) ->
291 297
     case [erlang:monitor(process, Pid) || {_, {active, Pid}} <- Jobs] of
292 298
         [] -> Jobs;
293 299
         _ ->
294  
-            receive
295  
-                {'DOWN', _, _, _, _} -> ok
  300
+            receive {'DOWN', _, _, _, _} -> ok
296 301
             after Timeout -> ok
297 302
             end,
298 303
             [{N, gen_server:call(event_server,
299  
-                {get_results, binary_to_list(N)})} ||
300  
-                    {N, _} <- Jobs]
  304
+                                 {get_results, binary_to_list(N)})}
  305
+             || {N, _} <- Jobs]
301 306
     end.

0 notes on commit 1411851

Please sign in to comment.
Something went wrong with that request. Please try again.