queue_dispatcher 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +20 -18
- data/lib/queue_dispatcher/version.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -6,13 +6,20 @@ Background tasks will be executed by persistent workers.
|
|
6
6
|
== Install
|
7
7
|
|
8
8
|
Inside your Gemfile:
|
9
|
-
|
10
9
|
gem "queue_dispatcher"
|
11
10
|
|
12
11
|
and then run:
|
12
|
+
bundle install
|
13
|
+
|
14
|
+
To install the queue_worker_dispatcher script, which starts all workers, execute the following rake command:
|
15
|
+
rake queue_dispatcher:sync
|
16
|
+
|
17
|
+
=== Database Setup
|
13
18
|
|
14
|
-
|
15
|
-
|
19
|
+
Use
|
20
|
+
rails g queue_dispatcher:migration
|
21
|
+
|
22
|
+
This will create a database migration for the models Task and TaskQueues.
|
16
23
|
|
17
24
|
=== Gem Dependencies
|
18
25
|
|
@@ -24,31 +31,26 @@ Please check if all those requirements are satisfied on your environment.
|
|
24
31
|
|
25
32
|
== Inside your application
|
26
33
|
|
27
|
-
To enqueue a long running task, simple call a method through enque
|
34
|
+
To enqueue a long running task, simple call a method through enque.
|
28
35
|
E.g.:
|
29
|
-
|
36
|
+
Assume, you have a long running job:
|
30
37
|
LongRunningMailJob.send_mail
|
31
38
|
|
32
|
-
|
39
|
+
Now we'd like to execute it in the background by simply calling:
|
33
40
|
task = LongRunningMailJob.enqueue.send_mail
|
34
41
|
|
35
|
-
|
42
|
+
If you like to put the job in a queue, you can do this by execute it the following way:
|
36
43
|
task = LongRunningMailJob.enqueue(queue: 'queue_name').send_mail
|
37
44
|
|
38
|
-
|
45
|
+
Jobs inside a queue are executed serialized, not in parallel. You can define dependencies. A task is then executed only after all dependent tasks are finished. The dependencies could also be in another queue. This way you could ensure, that a task is only executed when another task from another queue is successfully finished. Code to add Task dependencies:
|
39
46
|
task.dependent_tasks = another_task
|
40
47
|
|
41
|
-
|
48
|
+
=== Queue Worker Dispatcher
|
49
|
+
The QueueWorkerDispatcher-script starts the workers (default are 10 workers). A worker waits for a new queue and executes all tasks of this queue. Start the QueueWorkerDispatcher by executing the following command:
|
50
|
+
script/queue_worker_dispatcher
|
42
51
|
|
43
|
-
|
44
|
-
|
45
|
-
=== Database Setup
|
46
|
-
|
47
|
-
Use
|
48
|
-
|
49
|
-
rails g queue_dispatcher:migration
|
50
|
-
|
51
|
-
This will create a database migration for the models Task and TaskQueues.
|
52
|
+
To start the QueueWorkerDispatcher as a daemon, use the option -b.
|
53
|
+
-b, --background work in background mode
|
52
54
|
|
53
55
|
== Copyright
|
54
56
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue_dispatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sys-proctable
|