Skip to content

Commit

Permalink
Merge pull request #18 from irccloud/master
Browse files Browse the repository at this point in the history
Updated README
  • Loading branch information
uwiger committed Jan 11, 2013
2 parents a7def1a + 58861b2 commit 8c103d8
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,29 @@ dampener and run at full speed again.



Examples
--------
Quickstart
----------

Compile and start a shell:

$ rebar get-deps
$ rebar compile
$ erl -pa ebin/ -pa deps/*/ebin -boot start_sasl

Start the ````jobs```` application:

1> application:start(jobs).

Paste an example from below into the shell.

### A queue that only allows 3 jobs to run concurrently

jobs:add_queue(three_at_once, [{regulators, [{counter, [{limit, 3}]}]}]).
jobs:add_queue(three_at_once, [
{regulators, [{counter, [
{name, three_at_once},
{limit, 3}
]}]}
]).
Task = fun(N) ->
io:format("Task ~p started\n", [N]),
timer:sleep(2000),
Expand All @@ -63,9 +80,18 @@ Examples
end)
end, lists:seq(1,10)).

#### To change the queue from 3-at-once to 2-at-once:

jobs:modify_counter(three_at_once, [{limit,2}]).

### A queue that starts 3 jobs per second, regardless of job duration

jobs:add_queue(three_per_sec, [{regulators, [{rate, [{limit, 3}]}]}]).
jobs:add_queue(three_per_sec, [
{regulators, [{rate, [
{name, three_per_sec},
{limit, 3}
]}]}
]).
Task = fun(N) ->
io:format("Task ~p started\n", [N]),
timer:sleep(2000),
Expand All @@ -78,6 +104,10 @@ Examples
end, lists:seq(1,10)).


#### To change the queue from 3 jobs/sec to 2 jobs/sec:

jobs:modify_regulator(rate, three_per_sec, three_per_sec, [{limit, 2}]).

Prerequisites
-------------
This application requires 'exprecs'.
Expand Down

0 comments on commit 8c103d8

Please sign in to comment.