proletariat 0.0.1 → 0.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 0.0.2
2
+
3
+ Features:
4
+
5
+ - Rake task added
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ Copyright 2014 Sebastian Edwards
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+ All of the files in this project are under the project-wide license
16
+ unless they are otherwise marked.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Lightweight background processing in Ruby powered by RabbitMQ and the excellent concurrent-ruby gem.
4
4
 
5
+ [![Code Climate](https://codeclimate.com/repos/52d75c166956805abe000226/badges/bf98213c1d629072560c/gpa.png)](https://codeclimate.com/repos/52d75c166956805abe000226/feed)
6
+
5
7
  ### Warning!
6
8
 
7
9
  This software is early-alpha, may contain bugs and change considerably in the near future.
@@ -24,7 +26,7 @@ And run:
24
26
 
25
27
  If you aren't using default RabbitMQ connection settings, ensure the `RABBITMQ_URL` env variable is present. Here's how that might look in your `.env` if you use Foreman:
26
28
 
27
- RABBITMQ_URL=amqp://someuser:somepass@127.0.0.1/another_vhost
29
+ RABBITMQ_URL=amqp://someuser:somepass@127.0.0.1/another_vhost
28
30
 
29
31
  ### Setting up a Worker
30
32
 
@@ -35,51 +37,61 @@ Proletariat works exclusively on RabbitMQ Topic exchanges and routing keys can b
35
37
  The `#work` method should return `:ok` on success or `:drop` / `:requeue` on failure.
36
38
 
37
39
  Here's a complete example:
38
-
39
- class SendUserIntroductoryEmail < Proletariat::Worker
40
- listen_on 'user.created'
41
-
42
- def work(message)
43
- params = JSON.parse(message)
44
-
45
- UserMailer.introductory_email(params).deliver!
46
-
47
- publish 'email_sent.user.introductory', {id: params['id']}.to_json
48
-
49
- :ok
50
- end
51
- end
52
-
40
+
41
+ class SendUserIntroductoryEmail < Proletariat::Worker
42
+ listen_on 'user.created'
43
+
44
+ def work(message)
45
+ params = JSON.parse(message)
46
+
47
+ UserMailer.introductory_email(params).deliver!
48
+
49
+ publish 'email_sent.user.introductory', {id: params['id']}.to_json
50
+
51
+ :ok
52
+ end
53
+ end
54
+
53
55
  ### Select your Workers
54
56
 
55
57
  If you are using Rails just create a `proletariat.rb` file in your initializers directory.
56
58
 
57
- Proletariat.configure worker_classes: [SendUserIntroductoryEmail, SomeOtherWorker]
58
- Proletariat.run!
59
-
59
+ Proletariat.configure worker_classes: [SendUserIntroductoryEmail, SomeOtherWorker]
60
+ Proletariat.run!
61
+
60
62
  Or define the `WORKERS` env variable.
61
63
 
62
- WORKERS=SendUserIntroductoryEmail,SomeOtherWorker
63
-
64
+ WORKERS=SendUserIntroductoryEmail,SomeOtherWorker
65
+
66
+ ### Deploying on Heroku
67
+
68
+ It's not recommended to run your background workers in the same process as your main web process. Heroku will shutdown idle `web` processes, killing your background workers in the process. Instead create a new process type for Proletariat by adding the following to your Procfile:
69
+
70
+ workers: bundle exec rake proletariat:run
71
+
72
+ And run:
73
+
74
+ heroku ps:scale workers=1
75
+
64
76
  ### Testing with Cucumber
65
77
 
66
78
  Add the following to your `env.rb`:
67
79
 
68
- require 'proletariat/cucumber'
69
-
80
+ require 'proletariat/cucumber'
81
+
70
82
  Use the provided helpers in your step definitions to synchronize your test suite with your workers without sacrificing the ability to test in production-like environment:
71
83
 
72
- When(/^I submit a valid 'register user' form$/) do
73
- wait_for message.on_topic('email_sent.user.introductory') do
74
- visit ...
75
- fill_in ...
76
- submit ...
77
- end
78
- end
79
-
80
- Then(/^the user should receive an introductory email$/) do
81
- expect(unread_emails_for(new_user_email).size).to eq 1
82
- end
84
+ When(/^I submit a valid 'register user' form$/) do
85
+ wait_for message.on_topic('email_sent.user.introductory') do
86
+ visit ...
87
+ fill_in ...
88
+ submit ...
89
+ end
90
+ end
91
+
92
+ Then(/^the user should receive an introductory email$/) do
93
+ expect(unread_emails_for(new_user_email).size).to eq 1
94
+ end
83
95
 
84
96
  ## FAQ
85
97
 
@@ -90,4 +102,4 @@ I wanted a library which shared one RabbitMQ connection across all of the worker
90
102
  ## TODO
91
103
  - Improve test suite :(
92
104
  - Add command line interface
93
- - Abstract retry strategies
105
+ - Abstract retry strategies
@@ -0,0 +1,16 @@
1
+ require 'proletariat'
2
+
3
+ task :environment
4
+
5
+ namespace :proletariat do
6
+ desc 'Start background processing'
7
+ task run: :environment do
8
+ STDOUT.sync = true
9
+
10
+ Proletariat.run!
11
+
12
+ at_exit { Proletariat.stop }
13
+
14
+ sleep
15
+ end
16
+ end
@@ -1,4 +1,4 @@
1
1
  # Public: Adds a constant for the current version number.
2
2
  module Proletariat
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proletariat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Sebastian Edwards
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-01-16 00:00:00.000000000 Z
12
+ date: 2014-01-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - '='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - '='
25
28
  - !ruby/object:Gem::Version
@@ -27,43 +30,49 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rubocop
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: concurrent-ruby
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - "~>"
51
+ - - ~>
46
52
  - !ruby/object:Gem::Version
47
53
  version: 0.4.0
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - "~>"
59
+ - - ~>
53
60
  - !ruby/object:Gem::Version
54
61
  version: 0.4.0
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: bunny
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - "~>"
67
+ - - ~>
60
68
  - !ruby/object:Gem::Version
61
69
  version: 1.1.0
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - "~>"
75
+ - - ~>
67
76
  - !ruby/object:Gem::Version
68
77
  version: 1.1.0
69
78
  description: Lightweight background processing powered by RabbitMQ
@@ -73,9 +82,11 @@ executables: []
73
82
  extensions: []
74
83
  extra_rdoc_files: []
75
84
  files:
76
- - ".gitignore"
77
- - ".rspec"
85
+ - .gitignore
86
+ - .rspec
87
+ - CHANGELOG.md
78
88
  - Gemfile
89
+ - LICENSE
79
90
  - README.md
80
91
  - Rakefile
81
92
  - lib/proletariat.rb
@@ -86,6 +97,7 @@ files:
86
97
  - lib/proletariat/queue_config.rb
87
98
  - lib/proletariat/runner.rb
88
99
  - lib/proletariat/subscriber.rb
100
+ - lib/proletariat/tasks.rb
89
101
  - lib/proletariat/testing.rb
90
102
  - lib/proletariat/testing/expectation.rb
91
103
  - lib/proletariat/testing/expectation_guarantor.rb
@@ -96,26 +108,27 @@ files:
96
108
  - spec/lib/proletariat_spec.rb
97
109
  homepage: https://github.com/SebastianEdwards/proletariat
98
110
  licenses: []
99
- metadata: {}
100
111
  post_install_message:
101
112
  rdoc_options: []
102
113
  require_paths:
103
114
  - lib
104
115
  required_ruby_version: !ruby/object:Gem::Requirement
116
+ none: false
105
117
  requirements:
106
- - - ">="
118
+ - - ! '>='
107
119
  - !ruby/object:Gem::Version
108
120
  version: '0'
109
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
+ none: false
110
123
  requirements:
111
- - - ">="
124
+ - - ! '>='
112
125
  - !ruby/object:Gem::Version
113
126
  version: '0'
114
127
  requirements: []
115
128
  rubyforge_project:
116
- rubygems_version: 2.2.0
129
+ rubygems_version: 1.8.25
117
130
  signing_key:
118
- specification_version: 4
131
+ specification_version: 3
119
132
  summary: Lightweight background processing powered by RabbitMQ
120
133
  test_files:
121
134
  - spec/lib/proletariat_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: ccf124f3fb011f0dd8f06666daa0f8748c70fe32
4
- data.tar.gz: a601e7e559d77d40b30f91be6824d4d51b13af3b
5
- SHA512:
6
- metadata.gz: 22cd707dcdcbfbefbff38a8c4c4bf74cceefa87c42c30706f9028a89d2039fc0095ac1deff157f5efa9c4e60c881e4fe6cd2b8f10596142ef257cfbb54460cdb
7
- data.tar.gz: 0160aced5ba612299ddb023b8cf19c361a2d02e9212bfb8c2e1d79dfbe2db07d017378ba7b9b029d894e7d18903ee371ec34623cef2941e611e4f80148a34fe6