service_skeleton 0.0.0.49.g47046b9 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.git-blame-ignore-revs +2 -0
  3. data/.github/workflows/ci.yml +52 -0
  4. data/.rubocop.yml +11 -1
  5. data/README.md +7 -59
  6. data/lib/service_skeleton/config.rb +20 -13
  7. data/lib/service_skeleton/generator.rb +3 -3
  8. data/lib/service_skeleton/runner.rb +3 -3
  9. data/lib/service_skeleton/ultravisor_children.rb +4 -1
  10. data/service_skeleton.gemspec +6 -16
  11. data/ultravisor/.yardopts +1 -0
  12. data/ultravisor/Guardfile +9 -0
  13. data/ultravisor/README.md +404 -0
  14. data/ultravisor/lib/ultravisor.rb +216 -0
  15. data/ultravisor/lib/ultravisor/child.rb +481 -0
  16. data/ultravisor/lib/ultravisor/child/call.rb +21 -0
  17. data/ultravisor/lib/ultravisor/child/call_receiver.rb +14 -0
  18. data/ultravisor/lib/ultravisor/child/cast.rb +16 -0
  19. data/ultravisor/lib/ultravisor/child/cast_receiver.rb +11 -0
  20. data/ultravisor/lib/ultravisor/child/process_cast_call.rb +39 -0
  21. data/ultravisor/lib/ultravisor/error.rb +25 -0
  22. data/ultravisor/lib/ultravisor/logging_helpers.rb +32 -0
  23. data/ultravisor/spec/example_group_methods.rb +19 -0
  24. data/ultravisor/spec/example_methods.rb +8 -0
  25. data/ultravisor/spec/spec_helper.rb +52 -0
  26. data/ultravisor/spec/ultravisor/add_child_spec.rb +79 -0
  27. data/ultravisor/spec/ultravisor/child/call_spec.rb +121 -0
  28. data/ultravisor/spec/ultravisor/child/cast_spec.rb +111 -0
  29. data/ultravisor/spec/ultravisor/child/id_spec.rb +21 -0
  30. data/ultravisor/spec/ultravisor/child/new_spec.rb +152 -0
  31. data/ultravisor/spec/ultravisor/child/restart_delay_spec.rb +40 -0
  32. data/ultravisor/spec/ultravisor/child/restart_spec.rb +70 -0
  33. data/ultravisor/spec/ultravisor/child/run_spec.rb +95 -0
  34. data/ultravisor/spec/ultravisor/child/shutdown_spec.rb +124 -0
  35. data/ultravisor/spec/ultravisor/child/spawn_spec.rb +107 -0
  36. data/ultravisor/spec/ultravisor/child/unsafe_instance_spec.rb +55 -0
  37. data/ultravisor/spec/ultravisor/child/wait_spec.rb +32 -0
  38. data/ultravisor/spec/ultravisor/new_spec.rb +71 -0
  39. data/ultravisor/spec/ultravisor/remove_child_spec.rb +49 -0
  40. data/ultravisor/spec/ultravisor/run_spec.rb +334 -0
  41. data/ultravisor/spec/ultravisor/shutdown_spec.rb +106 -0
  42. metadata +48 -63
  43. data/.travis.yml +0 -11
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+ require_relative "../spec_helper"
3
+
4
+ require_relative "../../lib/ultravisor"
5
+
6
+ describe Ultravisor do
7
+ let(:args) { {} }
8
+ let(:ultravisor) { Ultravisor.new(**args) }
9
+ let(:mock_thread) { instance_double(Thread) }
10
+
11
+ describe "#shutdown" do
12
+ it "takes the @op_m lock" do
13
+ expect(ultravisor.instance_variable_get(:@op_m)).to receive(:synchronize).and_call_original
14
+
15
+ ultravisor.shutdown
16
+ end
17
+
18
+ context "when the ultravisor isn't running" do
19
+ it "returns itself" do
20
+ expect(ultravisor.shutdown).to eq(ultravisor)
21
+ end
22
+ end
23
+
24
+ context "when the ultravisor is running" do
25
+ before(:each) do
26
+ ultravisor.instance_variable_set(:@running_thread, mock_thread)
27
+ allow(ultravisor.instance_variable_get(:@op_cv))
28
+ .to receive(:wait) do
29
+ ultravisor.instance_variable_set(:@running_thread, nil)
30
+ end
31
+ end
32
+
33
+ it "signals the ultravisor to shutdown" do
34
+ expect(ultravisor.instance_variable_get(:@queue)).to receive(:<<).with(:shutdown)
35
+
36
+ ultravisor.shutdown
37
+ end
38
+
39
+ it "waits until the CV is signalled" do
40
+ expect(ultravisor.instance_variable_get(:@op_cv)).to receive(:wait) do |m|
41
+ expect(m).to eq(ultravisor.instance_variable_get(:@op_m))
42
+ ultravisor.instance_variable_set(:@running_thread, nil)
43
+ nil
44
+ end
45
+
46
+ ultravisor.shutdown
47
+ end
48
+
49
+ context "when asked to not wait" do
50
+ it "doesn't wait on the CV" do
51
+ expect(ultravisor.instance_variable_get(:@op_cv)).to_not receive(:wait)
52
+
53
+ ultravisor.shutdown(wait: false)
54
+ end
55
+ end
56
+
57
+ it "returns itself" do
58
+ expect(ultravisor.shutdown).to eq(ultravisor)
59
+ end
60
+
61
+ context "when forced" do
62
+ before(:each) do
63
+ allow(mock_thread).to receive(:kill)
64
+ end
65
+
66
+ it "kills the thread" do
67
+ expect(mock_thread).to receive(:kill)
68
+
69
+ ultravisor.shutdown(force: true)
70
+ end
71
+
72
+ it "tells everyone waiting for the shutdown that the deed is done" do
73
+ expect(ultravisor.instance_variable_get(:@op_cv)).to receive(:broadcast)
74
+
75
+ ultravisor.shutdown(force: true)
76
+ end
77
+
78
+ it "unsets the running thread" do
79
+ ultravisor.shutdown(force: true)
80
+
81
+ expect(ultravisor.instance_variable_get(:@running_thread)).to be(nil)
82
+ end
83
+
84
+ it "doesn't wait on the CV" do
85
+ expect(ultravisor.instance_variable_get(:@op_cv)).to_not receive(:wait)
86
+
87
+ ultravisor.shutdown(force: true)
88
+ end
89
+
90
+ context "with children" do
91
+ let(:child) { Ultravisor::Child.new(id: :one, klass: Object, method: :to_s) }
92
+
93
+ before(:each) do
94
+ ultravisor.instance_variable_set(:@children, [[:child, child]])
95
+ end
96
+
97
+ it "forcibly shuts down the children" do
98
+ expect(child).to receive(:shutdown).with(force: true)
99
+
100
+ ultravisor.shutdown(force: true)
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: service_skeleton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.49.g47046b9
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
+ - Sam Saffron
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-07-22 00:00:00.000000000 Z
12
+ date: 2021-03-01 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: frankenstein
@@ -28,20 +29,14 @@ dependencies:
28
29
  name: loggerstash
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.0.9
34
- - - "<"
32
+ - - "~>"
35
33
  - !ruby/object:Gem::Version
36
34
  version: '1'
37
35
  type: :runtime
38
36
  prerelease: false
39
37
  version_requirements: !ruby/object:Gem::Requirement
40
38
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 0.0.9
44
- - - "<"
39
+ - - "~>"
45
40
  - !ruby/object:Gem::Version
46
41
  version: '1'
47
42
  - !ruby/object:Gem::Dependency
@@ -86,20 +81,6 @@ dependencies:
86
81
  - - "~>"
87
82
  - !ruby/object:Gem::Version
88
83
  version: '0.2'
89
- - !ruby/object:Gem::Dependency
90
- name: ultravisor
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: 0.a
96
- type: :runtime
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: 0.a
103
84
  - !ruby/object:Gem::Dependency
104
85
  name: bundler
105
86
  requirement: !ruby/object:Gem::Requirement
@@ -115,7 +96,7 @@ dependencies:
115
96
  - !ruby/object:Gem::Version
116
97
  version: '0'
117
98
  - !ruby/object:Gem::Dependency
118
- name: github-release
99
+ name: guard-rspec
119
100
  requirement: !ruby/object:Gem::Requirement
120
101
  requirements:
121
102
  - - ">="
@@ -129,7 +110,7 @@ dependencies:
129
110
  - !ruby/object:Gem::Version
130
111
  version: '0'
131
112
  - !ruby/object:Gem::Dependency
132
- name: git-version-bump
113
+ name: guard-rubocop
133
114
  requirement: !ruby/object:Gem::Requirement
134
115
  requirements:
135
116
  - - ">="
@@ -143,7 +124,7 @@ dependencies:
143
124
  - !ruby/object:Gem::Version
144
125
  version: '0'
145
126
  - !ruby/object:Gem::Dependency
146
- name: guard-rspec
127
+ name: rack-test
147
128
  requirement: !ruby/object:Gem::Requirement
148
129
  requirements:
149
130
  - - ">="
@@ -157,7 +138,7 @@ dependencies:
157
138
  - !ruby/object:Gem::Version
158
139
  version: '0'
159
140
  - !ruby/object:Gem::Dependency
160
- name: guard-rubocop
141
+ name: rake
161
142
  requirement: !ruby/object:Gem::Requirement
162
143
  requirements:
163
144
  - - ">="
@@ -171,7 +152,7 @@ dependencies:
171
152
  - !ruby/object:Gem::Version
172
153
  version: '0'
173
154
  - !ruby/object:Gem::Dependency
174
- name: rack-test
155
+ name: redcarpet
175
156
  requirement: !ruby/object:Gem::Requirement
176
157
  requirements:
177
158
  - - ">="
@@ -185,21 +166,7 @@ dependencies:
185
166
  - !ruby/object:Gem::Version
186
167
  version: '0'
187
168
  - !ruby/object:Gem::Dependency
188
- name: rake
189
- requirement: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - "~>"
192
- - !ruby/object:Gem::Version
193
- version: '12.0'
194
- type: :development
195
- prerelease: false
196
- version_requirements: !ruby/object:Gem::Requirement
197
- requirements:
198
- - - "~>"
199
- - !ruby/object:Gem::Version
200
- version: '12.0'
201
- - !ruby/object:Gem::Dependency
202
- name: redcarpet
169
+ name: rspec
203
170
  requirement: !ruby/object:Gem::Requirement
204
171
  requirements:
205
172
  - - ">="
@@ -213,7 +180,7 @@ dependencies:
213
180
  - !ruby/object:Gem::Version
214
181
  version: '0'
215
182
  - !ruby/object:Gem::Dependency
216
- name: rspec
183
+ name: rubocop
217
184
  requirement: !ruby/object:Gem::Requirement
218
185
  requirements:
219
186
  - - ">="
@@ -226,20 +193,6 @@ dependencies:
226
193
  - - ">="
227
194
  - !ruby/object:Gem::Version
228
195
  version: '0'
229
- - !ruby/object:Gem::Dependency
230
- name: rubocop
231
- requirement: !ruby/object:Gem::Requirement
232
- requirements:
233
- - - "~>"
234
- - !ruby/object:Gem::Version
235
- version: '0.79'
236
- type: :development
237
- prerelease: false
238
- version_requirements: !ruby/object:Gem::Requirement
239
- requirements:
240
- - - "~>"
241
- - !ruby/object:Gem::Version
242
- version: '0.79'
243
196
  - !ruby/object:Gem::Dependency
244
197
  name: rubocop-discourse
245
198
  requirement: !ruby/object:Gem::Requirement
@@ -290,15 +243,16 @@ description: |
290
243
  for your services, as well as a collection of helper classes to manage
291
244
  common aspects of a system service.
292
245
  email:
293
- - matt.palmer@discourse.org
246
+ - sam.saffron@discourse.org
294
247
  executables: []
295
248
  extensions: []
296
249
  extra_rdoc_files: []
297
250
  files:
298
251
  - ".editorconfig"
252
+ - ".git-blame-ignore-revs"
253
+ - ".github/workflows/ci.yml"
299
254
  - ".gitignore"
300
255
  - ".rubocop.yml"
301
- - ".travis.yml"
302
256
  - ".yardopts"
303
257
  - CODE_OF_CONDUCT.md
304
258
  - CONTRIBUTING.md
@@ -331,6 +285,37 @@ files:
331
285
  - lib/service_skeleton/ultravisor_children.rb
332
286
  - lib/service_skeleton/ultravisor_loggerstash.rb
333
287
  - service_skeleton.gemspec
288
+ - ultravisor/.yardopts
289
+ - ultravisor/Guardfile
290
+ - ultravisor/README.md
291
+ - ultravisor/lib/ultravisor.rb
292
+ - ultravisor/lib/ultravisor/child.rb
293
+ - ultravisor/lib/ultravisor/child/call.rb
294
+ - ultravisor/lib/ultravisor/child/call_receiver.rb
295
+ - ultravisor/lib/ultravisor/child/cast.rb
296
+ - ultravisor/lib/ultravisor/child/cast_receiver.rb
297
+ - ultravisor/lib/ultravisor/child/process_cast_call.rb
298
+ - ultravisor/lib/ultravisor/error.rb
299
+ - ultravisor/lib/ultravisor/logging_helpers.rb
300
+ - ultravisor/spec/example_group_methods.rb
301
+ - ultravisor/spec/example_methods.rb
302
+ - ultravisor/spec/spec_helper.rb
303
+ - ultravisor/spec/ultravisor/add_child_spec.rb
304
+ - ultravisor/spec/ultravisor/child/call_spec.rb
305
+ - ultravisor/spec/ultravisor/child/cast_spec.rb
306
+ - ultravisor/spec/ultravisor/child/id_spec.rb
307
+ - ultravisor/spec/ultravisor/child/new_spec.rb
308
+ - ultravisor/spec/ultravisor/child/restart_delay_spec.rb
309
+ - ultravisor/spec/ultravisor/child/restart_spec.rb
310
+ - ultravisor/spec/ultravisor/child/run_spec.rb
311
+ - ultravisor/spec/ultravisor/child/shutdown_spec.rb
312
+ - ultravisor/spec/ultravisor/child/spawn_spec.rb
313
+ - ultravisor/spec/ultravisor/child/unsafe_instance_spec.rb
314
+ - ultravisor/spec/ultravisor/child/wait_spec.rb
315
+ - ultravisor/spec/ultravisor/new_spec.rb
316
+ - ultravisor/spec/ultravisor/remove_child_spec.rb
317
+ - ultravisor/spec/ultravisor/run_spec.rb
318
+ - ultravisor/spec/ultravisor/shutdown_spec.rb
334
319
  homepage: https://github.com/discourse/service_skeleton
335
320
  licenses: []
336
321
  metadata: {}
@@ -345,9 +330,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
345
330
  version: 2.5.0
346
331
  required_rubygems_version: !ruby/object:Gem::Requirement
347
332
  requirements:
348
- - - ">"
333
+ - - ">="
349
334
  - !ruby/object:Gem::Version
350
- version: 1.3.1
335
+ version: '0'
351
336
  requirements: []
352
337
  rubygems_version: 3.0.3
353
338
  signing_key:
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
-
5
- rvm:
6
- - 2.5.3
7
- - 2.4.5
8
- - 2.3.8
9
-
10
- gemfile:
11
- - Gemfile