proletariat 0.0.2 → 0.0.3
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.
- checksums.yaml +7 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +12 -0
- data/README.md +1 -2
- data/lib/proletariat/concurrency/actor.rb +71 -0
- data/lib/proletariat/concurrency/supervisor.rb +31 -0
- data/lib/proletariat/configuration.rb +131 -0
- data/lib/proletariat/cucumber.rb +6 -2
- data/lib/proletariat/manager.rb +20 -66
- data/lib/proletariat/publisher.rb +27 -51
- data/lib/proletariat/queue_config.rb +1 -5
- data/lib/proletariat/runner.rb +10 -106
- data/lib/proletariat/subscriber.rb +6 -8
- data/lib/proletariat/testing/expectation_guarantor.rb +5 -9
- data/lib/proletariat/testing.rb +1 -1
- data/lib/proletariat/util/worker_description_parser.rb +37 -0
- data/lib/proletariat/version.rb +1 -1
- data/lib/proletariat/worker.rb +17 -41
- data/lib/proletariat.rb +24 -51
- data/spec/lib/configuration_spec.rb +85 -0
- data/spec/lib/proletariat_spec.rb +5 -4
- data/spec/lib/publisher_spec.rb +36 -0
- data/spec/lib/queue_config_spec.rb +12 -0
- data/spec/lib/testing/expectation_guarantor_spec.rb +55 -0
- data/spec/lib/testing/expectation_spec.rb +15 -0
- data/spec/lib/util/worker_description_parser_spec.rb +42 -0
- data/spec/lib/worker_spec.rb +83 -0
- metadata +34 -25
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'proletariat/worker'
|
2
|
+
|
3
|
+
module Proletariat
|
4
|
+
describe Worker do
|
5
|
+
let(:logger) { double }
|
6
|
+
|
7
|
+
before do
|
8
|
+
allow(Proletariat).to receive(:logger).and_return(logger)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#started' do
|
12
|
+
it 'should log status' do
|
13
|
+
expect(logger).to receive(:info).with /online/
|
14
|
+
Worker.new.started
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#stopped' do
|
19
|
+
it 'should log status' do
|
20
|
+
expect(logger).to receive(:info).with /offline/
|
21
|
+
Worker.new.stopped
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#stopping' do
|
26
|
+
it 'should log status' do
|
27
|
+
expect(logger).to receive(:info).with /graceful shutdown/
|
28
|
+
Worker.new.stopping
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#work' do
|
33
|
+
it 'should raise NotImplementedError' do
|
34
|
+
expect { Worker.new.work('message') }.to \
|
35
|
+
raise_exception NotImplementedError
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#log' do
|
40
|
+
context 'when message is provided' do
|
41
|
+
it 'should log the message directly' do
|
42
|
+
expect(logger).to receive(:info).with 'message to log'
|
43
|
+
Worker.new.log 'message to log'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when no message is provided' do
|
48
|
+
it 'should return the logger instance' do
|
49
|
+
expect(Worker.new.log).to eq logger
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#publish' do
|
55
|
+
it 'should forward the message to the publisher' do
|
56
|
+
expect(Proletariat).to receive(:publish).with('topic', 'message')
|
57
|
+
Worker.new.publish 'topic', 'message'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should have a blank default message' do
|
61
|
+
expect(Proletariat).to receive(:publish).with('topic', '')
|
62
|
+
Worker.new.publish 'topic'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '.listen_on' do
|
67
|
+
it 'should add the given keys to routing_keys' do
|
68
|
+
Worker.listen_on 'topic1', 'topic2'
|
69
|
+
expect(Worker.routing_keys).to eq %w(topic1 topic2)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '.routing_keys' do
|
74
|
+
before do
|
75
|
+
Worker.instance_variable_set :@routing_keys, nil
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should return an empty array by default' do
|
79
|
+
expect(Worker.routing_keys).to eq []
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proletariat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sebastian Edwards
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,49 +27,43 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rubocop
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: concurrent-ruby
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 0.4.0
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 0.4.0
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: bunny
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: 1.1.0
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 1.1.0
|
78
69
|
description: Lightweight background processing powered by RabbitMQ
|
@@ -82,8 +73,9 @@ executables: []
|
|
82
73
|
extensions: []
|
83
74
|
extra_rdoc_files: []
|
84
75
|
files:
|
85
|
-
- .gitignore
|
86
|
-
- .rspec
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".rubocop.yml"
|
87
79
|
- CHANGELOG.md
|
88
80
|
- Gemfile
|
89
81
|
- LICENSE
|
@@ -91,6 +83,9 @@ files:
|
|
91
83
|
- Rakefile
|
92
84
|
- lib/proletariat.rb
|
93
85
|
- lib/proletariat/concerns/logging.rb
|
86
|
+
- lib/proletariat/concurrency/actor.rb
|
87
|
+
- lib/proletariat/concurrency/supervisor.rb
|
88
|
+
- lib/proletariat/configuration.rb
|
94
89
|
- lib/proletariat/cucumber.rb
|
95
90
|
- lib/proletariat/manager.rb
|
96
91
|
- lib/proletariat/publisher.rb
|
@@ -102,33 +97,47 @@ files:
|
|
102
97
|
- lib/proletariat/testing/expectation.rb
|
103
98
|
- lib/proletariat/testing/expectation_guarantor.rb
|
104
99
|
- lib/proletariat/testing/fixnum_extension.rb
|
100
|
+
- lib/proletariat/util/worker_description_parser.rb
|
105
101
|
- lib/proletariat/version.rb
|
106
102
|
- lib/proletariat/worker.rb
|
107
103
|
- proletariat.gemspec
|
104
|
+
- spec/lib/configuration_spec.rb
|
108
105
|
- spec/lib/proletariat_spec.rb
|
106
|
+
- spec/lib/publisher_spec.rb
|
107
|
+
- spec/lib/queue_config_spec.rb
|
108
|
+
- spec/lib/testing/expectation_guarantor_spec.rb
|
109
|
+
- spec/lib/testing/expectation_spec.rb
|
110
|
+
- spec/lib/util/worker_description_parser_spec.rb
|
111
|
+
- spec/lib/worker_spec.rb
|
109
112
|
homepage: https://github.com/SebastianEdwards/proletariat
|
110
113
|
licenses: []
|
114
|
+
metadata: {}
|
111
115
|
post_install_message:
|
112
116
|
rdoc_options: []
|
113
117
|
require_paths:
|
114
118
|
- lib
|
115
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
-
none: false
|
117
120
|
requirements:
|
118
|
-
- -
|
121
|
+
- - ">="
|
119
122
|
- !ruby/object:Gem::Version
|
120
123
|
version: '0'
|
121
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
125
|
requirements:
|
124
|
-
- -
|
126
|
+
- - ">="
|
125
127
|
- !ruby/object:Gem::Version
|
126
128
|
version: '0'
|
127
129
|
requirements: []
|
128
130
|
rubyforge_project:
|
129
|
-
rubygems_version:
|
131
|
+
rubygems_version: 2.2.0
|
130
132
|
signing_key:
|
131
|
-
specification_version:
|
133
|
+
specification_version: 4
|
132
134
|
summary: Lightweight background processing powered by RabbitMQ
|
133
135
|
test_files:
|
136
|
+
- spec/lib/configuration_spec.rb
|
134
137
|
- spec/lib/proletariat_spec.rb
|
138
|
+
- spec/lib/publisher_spec.rb
|
139
|
+
- spec/lib/queue_config_spec.rb
|
140
|
+
- spec/lib/testing/expectation_guarantor_spec.rb
|
141
|
+
- spec/lib/testing/expectation_spec.rb
|
142
|
+
- spec/lib/util/worker_description_parser_spec.rb
|
143
|
+
- spec/lib/worker_spec.rb
|