qe 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ *.sqlite3
3
+ *.rdb
4
+ pkg
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format documentation --order random
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -0,0 +1,100 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ qe (0.1.3)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ activemodel (3.2.8)
10
+ activesupport (= 3.2.8)
11
+ builder (~> 3.0.0)
12
+ activerecord (3.2.8)
13
+ activemodel (= 3.2.8)
14
+ activesupport (= 3.2.8)
15
+ arel (~> 3.0.2)
16
+ tzinfo (~> 0.3.29)
17
+ activesupport (3.2.8)
18
+ i18n (~> 0.6)
19
+ multi_json (~> 1.0)
20
+ arel (3.0.2)
21
+ awesome_print (1.1.0)
22
+ backburner (0.2.5)
23
+ beaneater (~> 0.1.2)
24
+ dante (~> 0.1.5)
25
+ beaneater (0.1.2)
26
+ builder (3.0.4)
27
+ celluloid (0.12.3)
28
+ facter (>= 1.6.12)
29
+ timers (>= 1.0.0)
30
+ coderay (1.0.8)
31
+ connection_pool (0.9.2)
32
+ dante (0.1.5)
33
+ delayed_job (3.0.3)
34
+ activesupport (~> 3.0)
35
+ delayed_job_active_record (0.3.3)
36
+ activerecord (>= 2.1.0, < 4)
37
+ delayed_job (~> 3.0)
38
+ diff-lcs (1.1.3)
39
+ facter (1.6.14)
40
+ i18n (0.6.1)
41
+ method_source (0.8.1)
42
+ multi_json (1.3.7)
43
+ pry (0.9.10)
44
+ coderay (~> 1.0.5)
45
+ method_source (~> 0.8)
46
+ slop (~> 3.3.1)
47
+ qu (0.2.0)
48
+ multi_json
49
+ rack (1.4.1)
50
+ rack-protection (1.2.0)
51
+ rack
52
+ redis (3.0.2)
53
+ redis-namespace (1.2.1)
54
+ redis (~> 3.0.0)
55
+ resque (1.23.0)
56
+ multi_json (~> 1.0)
57
+ redis-namespace (~> 1.0)
58
+ sinatra (>= 0.9.2)
59
+ vegas (~> 0.1.2)
60
+ rspec (2.11.0)
61
+ rspec-core (~> 2.11.0)
62
+ rspec-expectations (~> 2.11.0)
63
+ rspec-mocks (~> 2.11.0)
64
+ rspec-core (2.11.1)
65
+ rspec-expectations (2.11.3)
66
+ diff-lcs (~> 1.1.3)
67
+ rspec-mocks (2.11.3)
68
+ sidekiq (2.5.2)
69
+ celluloid (~> 0.12.0)
70
+ connection_pool (~> 0.9.2)
71
+ multi_json (~> 1)
72
+ redis (~> 3)
73
+ redis-namespace
74
+ sinatra (1.3.3)
75
+ rack (~> 1.3, >= 1.3.6)
76
+ rack-protection (~> 1.2)
77
+ tilt (~> 1.3, >= 1.3.3)
78
+ slop (3.3.3)
79
+ sqlite3 (1.3.6)
80
+ tilt (1.3.3)
81
+ timers (1.0.1)
82
+ tzinfo (0.3.35)
83
+ vegas (0.1.11)
84
+ rack (>= 1.0.0)
85
+
86
+ PLATFORMS
87
+ ruby
88
+
89
+ DEPENDENCIES
90
+ activerecord
91
+ awesome_print
92
+ backburner
93
+ delayed_job_active_record
94
+ pry
95
+ qe!
96
+ qu
97
+ resque
98
+ rspec
99
+ sidekiq
100
+ sqlite3
@@ -0,0 +1,144 @@
1
+ # Qe
2
+
3
+ A simple interface over several background job libraries like Resque, Sidekiq and DelayedJob.
4
+
5
+ ## Usage
6
+
7
+ In this wild world where a new asynchronous job processing
8
+ library is released every once in a while, Qe tries to keep a unified
9
+ interface that works with the most famous libraries:
10
+
11
+ * [Sidekiq](http://mperham.github.com/sidekiq/)
12
+ * [Resque](https://github.com/defunkt/resque/)
13
+ * [DelayedJob](https://github.com/collectiveidea/delayed_job)
14
+ * [Qu](https://github.com/bkeepers/qu)
15
+ * [Beanstalk](https://github.com/kr/beanstalkd)/[Backburner](http://nesquena.github.com/backburner/)
16
+
17
+ To set the adapter, just load the file according to your adapter:
18
+
19
+ ``` ruby
20
+ require "qe/resque"
21
+ require "qe/qu"
22
+ require "qe/delayed_job"
23
+ require "qe/beanstalk"
24
+ ```
25
+
26
+ You also need to require the library you're going to use. If you're using Rails with Bundler, you can simple require the correct file and dependency.
27
+
28
+ ``` ruby
29
+ source :rubygems
30
+ gem "rails", "3.2.8"
31
+
32
+ gem "sidekiq"
33
+ gem "qe", :require => "qe/sidekiq"
34
+
35
+ gem "resque"
36
+ gem "qe", :require => "qe/resque"
37
+
38
+ gem "qu"
39
+ gem "qe", :require => "qe/qu"
40
+
41
+ gem "backburner"
42
+ gem "qe", :require => "qe/beanstalk"
43
+ ```
44
+
45
+ Create a worker that will send e-mails through `ActionMailer`.
46
+
47
+ ``` ruby
48
+ class MailerWorker
49
+ include Qe::Worker
50
+
51
+ def perform
52
+ Mailer.public_send(options[:mail], options).deliver
53
+ end
54
+ end
55
+ ```
56
+
57
+ Define our `Mailer` class.
58
+
59
+ ``` ruby
60
+ class Mailer < ActionMailer::Base
61
+ def welcome(options)
62
+ @options = options
63
+ mail :to => options[:email]
64
+ end
65
+ end
66
+ ```
67
+
68
+ Enqueue a job to be processed asynchronously.
69
+
70
+ ``` ruby
71
+ MailerWorker.enqueue({
72
+ :mail => :welcome,
73
+ :email => "john@example.org",
74
+ :name => "John Doe"
75
+ })
76
+ ```
77
+
78
+ ## Development support
79
+
80
+ Qe comes with development support. Instead of starting up workers on development environment, you can use the `Qe::Immediate` adapter, which executes your worker right away!
81
+
82
+ ``` ruby
83
+ Qe.adapter = Qe::Immediate
84
+ ```
85
+
86
+ If you're using Rails, you can add the line above to your `config/environments/development.rb` file.
87
+
88
+ ## Testing support
89
+
90
+ Qe also comes with testing support. Just require the `qe/testing.rb` file
91
+ and a fake queuing adapter will be used. All enqueued jobs will be stored
92
+ at `Qe.jobs`. Note that this method is only available on testing mode.
93
+
94
+ ``` ruby
95
+ require "qe/testing"
96
+ Qe.adapter = Qe::Testing
97
+ ```
98
+
99
+ If you"re using RSpec, you can require the `qe/testing/rspec.rb` file
100
+ instead. This will reset `Qe.jobs` before every spec and will add a
101
+ `enqueue` matcher.
102
+
103
+ ``` ruby
104
+ # Add the following like to your spec_helper.rb file
105
+ require "qe/testing/rspec"
106
+
107
+ describe "Enqueuing a job" do
108
+ it "enqueues job" do
109
+ expect {
110
+ # do something
111
+ }.to enqueue(MailerWorker).with(:email => "john@example.org")
112
+ end
113
+ end
114
+ ```
115
+
116
+
117
+ Maintainer
118
+ ----------
119
+
120
+ * Nando Vieira (<http://nandovieira.com.br>)
121
+
122
+ License:
123
+ --------
124
+
125
+ (The MIT License)
126
+
127
+ Permission is hereby granted, free of charge, to any person obtaining
128
+ a copy of this software and associated documentation files (the
129
+ "Software"), to deal in the Software without restriction, including
130
+ without limitation the rights to use, copy, modify, merge, publish,
131
+ distribute, sublicense, and/or sell copies of the Software, and to
132
+ permit persons to whom the Software is furnished to do so, subject to
133
+ the following conditions:
134
+
135
+ The above copyright notice and this permission notice shall be
136
+ included in all copies or substantial portions of the Software.
137
+
138
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
139
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
140
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
141
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
142
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
143
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
144
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,5 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rspec/core/rake_task"
5
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,3 @@
1
+ QUEUES="mail,default"
2
+ QUEUE="mail,default"
3
+ BEANSTALK_URL="beanstalk://localhost/"
@@ -0,0 +1,14 @@
1
+ source :rubygems
2
+
3
+ gem "sidekiq"
4
+ gem "backburner"
5
+ gem "beanstalkd_view"
6
+ gem "rake"
7
+ gem "thin"
8
+ gem "resque"
9
+ gem "activerecord"
10
+ gem "delayed_job_active_record"
11
+ gem "sqlite3"
12
+ gem "daemons"
13
+ gem "qu-redis"
14
+ gem "slim"
@@ -0,0 +1,119 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.2.8)
5
+ activesupport (= 3.2.8)
6
+ builder (~> 3.0.0)
7
+ activerecord (3.2.8)
8
+ activemodel (= 3.2.8)
9
+ activesupport (= 3.2.8)
10
+ arel (~> 3.0.2)
11
+ tzinfo (~> 0.3.29)
12
+ activesupport (3.2.8)
13
+ i18n (~> 0.6)
14
+ multi_json (~> 1.0)
15
+ arel (3.0.2)
16
+ backburner (0.2.0)
17
+ beaneater (~> 0.1.2)
18
+ dante (~> 0.1.5)
19
+ backports (2.6.5)
20
+ beaneater (0.1.2)
21
+ beanstalkd_view (1.1.0)
22
+ beaneater (~> 0.1.0)
23
+ json
24
+ sinatra (>= 1.3.0)
25
+ sinatra-assetpack (>= 0.0.11)
26
+ sinatra-contrib (>= 1.3.0)
27
+ vegas (~> 0.1.2)
28
+ builder (3.0.4)
29
+ celluloid (0.12.3)
30
+ facter (>= 1.6.12)
31
+ timers (>= 1.0.0)
32
+ connection_pool (0.9.2)
33
+ daemons (1.1.9)
34
+ dante (0.1.5)
35
+ delayed_job (3.0.3)
36
+ activesupport (~> 3.0)
37
+ delayed_job_active_record (0.3.3)
38
+ activerecord (>= 2.1.0, < 4)
39
+ delayed_job (~> 3.0)
40
+ eventmachine (1.0.0)
41
+ facter (1.6.14)
42
+ i18n (0.6.1)
43
+ jsmin (1.0.1)
44
+ json (1.7.5)
45
+ multi_json (1.3.7)
46
+ qu (0.2.0)
47
+ multi_json
48
+ qu-redis (0.2.0)
49
+ qu (= 0.2.0)
50
+ redis-namespace
51
+ simple_uuid
52
+ rack (1.4.1)
53
+ rack-protection (1.2.0)
54
+ rack
55
+ rack-test (0.6.2)
56
+ rack (>= 1.0)
57
+ rake (0.9.2.2)
58
+ redis (3.0.2)
59
+ redis-namespace (1.2.1)
60
+ redis (~> 3.0.0)
61
+ resque (1.23.0)
62
+ multi_json (~> 1.0)
63
+ redis-namespace (~> 1.0)
64
+ sinatra (>= 0.9.2)
65
+ vegas (~> 0.1.2)
66
+ sidekiq (2.5.2)
67
+ celluloid (~> 0.12.0)
68
+ connection_pool (~> 0.9.2)
69
+ multi_json (~> 1)
70
+ redis (~> 3)
71
+ redis-namespace
72
+ simple_uuid (0.2.0)
73
+ sinatra (1.3.3)
74
+ rack (~> 1.3, >= 1.3.6)
75
+ rack-protection (~> 1.2)
76
+ tilt (~> 1.3, >= 1.3.3)
77
+ sinatra-assetpack (0.0.11)
78
+ jsmin
79
+ rack-test
80
+ sinatra
81
+ tilt (>= 1.3.0)
82
+ sinatra-contrib (1.3.2)
83
+ backports (>= 2.0)
84
+ eventmachine
85
+ rack-protection
86
+ rack-test
87
+ sinatra (~> 1.3.0)
88
+ tilt (~> 1.3)
89
+ slim (1.3.3)
90
+ temple (~> 0.5.5)
91
+ tilt (~> 1.3.3)
92
+ sqlite3 (1.3.6)
93
+ temple (0.5.5)
94
+ thin (1.5.0)
95
+ daemons (>= 1.0.9)
96
+ eventmachine (>= 0.12.6)
97
+ rack (>= 1.0.0)
98
+ tilt (1.3.3)
99
+ timers (1.0.1)
100
+ tzinfo (0.3.35)
101
+ vegas (0.1.11)
102
+ rack (>= 1.0.0)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ activerecord
109
+ backburner
110
+ beanstalkd_view
111
+ daemons
112
+ delayed_job_active_record
113
+ qu-redis
114
+ rake
115
+ resque
116
+ sidekiq
117
+ slim
118
+ sqlite3
119
+ thin
@@ -0,0 +1,20 @@
1
+ redis: redis-server redis.conf
2
+ # beanstalkd: beanstalkd
3
+
4
+ # Uncomment the following lines to enable Sidekiq
5
+ sidekiq: bundle exec sidekiq -r ./workers.rb -q default -q mail
6
+ sidekiq_web: bundle exec thin -R sidekiq.ru -p 9292 -V start
7
+
8
+ # Uncomment the following lines to enable Beanstalk/Backburner
9
+ # backburner: bundle exec rake backburner:work
10
+ # beanstalkd_view: bundle exec thin -R beanstalkd.ru -p 9292 -V start
11
+
12
+ # Uncomment the following line to enable DelayedJob
13
+ # delayed_job: bundle exec rake jobs:work
14
+
15
+ # Uncomment the following line to enable Qu
16
+ # qu: bundle exec rake qu:work
17
+
18
+ # Uncomment the following lines to enable Resque
19
+ # resque: bundle exec rake resque:work
20
+ # resque_web: bundle exec thin -R resque.ru -p 9292 -V start
@@ -0,0 +1,9 @@
1
+ # Running examples
2
+
3
+ 1. First, start processes with `$ foreman start`
4
+ 2. Then execute `$ ruby sample.rb`
5
+ 3. Go back to the Foreman's terminal and watch the output
6
+
7
+ Tweak the `Procfile` to enable different libraries and web panels.
8
+
9
+ You'll need to install Redis and/or Beanstalkd.
@@ -0,0 +1,14 @@
1
+ require "backburner/tasks"
2
+ require "resque/tasks"
3
+ require "delayed/tasks"
4
+ require "qu/tasks"
5
+
6
+ task :environment do #=> required by Backburner
7
+ require "./workers"
8
+
9
+ Backburner.configure do |config|
10
+ config.logger = Logger.new(STDOUT)
11
+ end
12
+ end
13
+
14
+ task "resque:setup" => :environment