Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 5 files changed
  • 0 comments
  • 1 contributor
Dec 19, 2012
Jesper Louis Andersen Bump safetyvalve to version 1.0.0.
This is the first version of safetyvalve.
cdd5aba
Jesper Louis Andersen Bump README. 85a1691
Dec 23, 2012
Jesper Louis Andersen Merge branch 'correct-call'
Conflicts:
	src/safetyvalve.app.src
f2d723a
15  README.md
Source Rendered
@@ -5,6 +5,21 @@ Erlang systems. It provides queueing facilities for tasks to be
5 5
 executed so their concurrency and rate can be limited on a running
6 6
 system.
7 7
 
  8
+# Using
  9
+
  10
+This project uses semantic versioning. Tags are declared like `vX.Y.Z`
  11
+(do note the `v`). The meaning is:
  12
+
  13
+* X changes: There have been backwards-incompatible changes to the `sv` API functions which are meant to be the only functions exported. Or there has been changes to the way the configuration file format is specified.
  14
+* Y changes: These are additions to the API, but existing functionality has not been broken.
  15
+* Z changes: Bug fixes.
  16
+
  17
+# Changes
  18
+
  19
+### v0.1.0 -> v1.0.0
  20
+
  21
+The return value of `sv:run/3` changed from `Res | {error, Reason}` to `{ok, Res} | {error, Reason}`. This better reflects the system and we can distinguish between an error term from the function we run and safetyvalve itself.
  22
+
8 23
 # Inspiration
9 24
 
10 25
 Safetyvalve owes its inspiration to Ulf Wigers `jobs` framework, but
2  eqc_test/worker.erl
@@ -14,7 +14,7 @@ do_work(TimePoint) ->
14 14
                 fun () ->
15 15
                             done = manager:doing_work()
16 16
                 end) of
17  
-        done -> manager:status(done);
  17
+        {ok, done} -> manager:status(done);
18 18
         {error, _Reason} = Err -> manager:status(Err)
19 19
     end.
20 20
 
2  src/safetyvalve.app.src
... ...
@@ -1,7 +1,7 @@
1 1
 {application, safetyvalve,
2 2
  [
3 3
   {description, "A safety valve for your erlang node"},
4  
-  {vsn, "0.1.1"},
  4
+  {vsn, "1.0.0"},
5 5
   {registered, [safetyvalve_sup]},
6 6
   {applications, [
7 7
                   kernel,
10  src/sv.erl
@@ -11,12 +11,19 @@
11 11
 %% function will return either the result of `Fun' or an `{error,
12 12
 %% Reason}' error term, describing the overload situation encountered.</p>
13 13
 %% @end
  14
+-spec run(Name, TS, Fun) -> {ok, Result} | {error, Reason}
  15
+    when
  16
+      Name :: atom(),
  17
+      TS :: term(), % Timestamp, should be orderable and unique
  18
+      Fun :: fun (() -> term),
  19
+      Result :: term(),
  20
+      Reason :: term().
14 21
 run(Name, TimePoint, Fun) ->
15 22
     case sv_queue:ask(Name, TimePoint) of
16 23
         {go, Ref} ->
17 24
             Res = Fun(),
18 25
             sv_queue:done(Name, Ref),
19  
-            Res;
  26
+            {ok, Res};
20 27
         {error, Reason} ->
21 28
             {error, Reason}
22 29
     end.
@@ -27,6 +34,7 @@ run(Name, Fun) ->
27 34
 	run(Name, timestamp(), Fun).
28 35
 
29 36
 %% @doc Construct a timestamp in a canonical way for Safetyvalve.
  37
+-spec timestamp() -> term().
30 38
 timestamp() ->
31 39
 	%% Timestamps *have* to be unique. Calling erlang:now/0 makes sure
32 40
 	%% this happens. But you can use any ordered term if you want, for instance
4  test/sv_SUITE.erl
@@ -57,12 +57,12 @@ ping(_Config) ->
57 57
     ok.
58 58
 
59 59
 through(_Config) ->
60  
-    ok = sv:run(test_queue_1, fun work/0).
  60
+    {ok, ok} = sv:run(test_queue_1, fun work/0).
61 61
 
62 62
 many_through(_Config) ->
63 63
     Parent = self(),
64 64
     Pids = [spawn_link(fun() ->
65  
-                               ok = sv:run(test_queue_1, fun work/0),
  65
+                               {ok, ok} = sv:run(test_queue_1, fun work/0),
66 66
                                Parent ! {done, self()}
67 67
                        end) || _ <- lists:seq(1, 20)],
68 68
     ok = collect(Pids).

No commit comments for this range

Something went wrong with that request. Please try again.