Browse files

Bump safetyvalve to version 1.0.0.

This is the first version of safetyvalve.
  • Loading branch information...
1 parent 2e6ccdb commit cdd5aba5329cc5611fbfe6c0fdc784000d7151e4 @jlouis committed Dec 19, 2012
Showing with 13 additions and 5 deletions.
  1. +1 −1 eqc_test/worker.erl
  2. +1 −1 src/safetyvalve.app.src
  3. +9 −1 src/sv.erl
  4. +2 −2 test/sv_SUITE.erl
View
2 eqc_test/worker.erl
@@ -14,7 +14,7 @@ do_work(TimePoint) ->
fun () ->
done = manager:doing_work()
end) of
- done -> manager:status(done);
+ {ok, done} -> manager:status(done);
{error, _Reason} = Err -> manager:status(Err)
end.
View
2 src/safetyvalve.app.src
@@ -1,7 +1,7 @@
{application, safetyvalve,
[
{description, "A safety valve for your erlang node"},
- {vsn, "0.1.0"},
+ {vsn, "1.0.0"},
{registered, [safetyvalve_sup]},
{applications, [
kernel,
View
10 src/sv.erl
@@ -11,12 +11,19 @@
%% function will return either the result of `Fun' or an `{error,
%% Reason}' error term, describing the overload situation encountered.</p>
%% @end
+-spec run(Name, TS, Fun) -> {ok, Result} | {error, Reason}
+ when
+ Name :: atom(),
+ TS :: term(), % Timestamp, should be orderable and unique
+ Fun :: fun (() -> term),
+ Result :: term(),
+ Reason :: term().
run(Name, TimePoint, Fun) ->
case sv_queue:ask(Name, TimePoint) of
{go, Ref} ->
Res = Fun(),
sv_queue:done(Name, Ref),
- Res;
+ {ok, Res};
{error, Reason} ->
{error, Reason}
end.
@@ -27,6 +34,7 @@ run(Name, Fun) ->
run(Name, timestamp(), Fun).
%% @doc Construct a timestamp in a canonical way for Safetyvalve.
+-spec timestamp() -> term().
timestamp() ->
%% Timestamps *have* to be unique. Calling erlang:now/0 makes sure
%% this happens. But you can use any ordered term if you want, for instance
View
4 test/sv_SUITE.erl
@@ -57,12 +57,12 @@ ping(_Config) ->
ok.
through(_Config) ->
- ok = sv:run(test_queue_1, fun work/0).
+ {ok, ok} = sv:run(test_queue_1, fun work/0).
many_through(_Config) ->
Parent = self(),
Pids = [spawn_link(fun() ->
- ok = sv:run(test_queue_1, fun work/0),
+ {ok, ok} = sv:run(test_queue_1, fun work/0),
Parent ! {done, self()}
end) || _ <- lists:seq(1, 20)],
ok = collect(Pids).

0 comments on commit cdd5aba

Please sign in to comment.