service_skeleton 0.0.0.49.g47046b9 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.git-blame-ignore-revs +2 -0
- data/.github/workflows/ci.yml +46 -0
- data/.gitignore +0 -7
- data/.rubocop.yml +11 -1
- data/README.md +6 -6
- data/lib/service_skeleton/config.rb +20 -13
- data/lib/service_skeleton/generator.rb +3 -3
- data/lib/service_skeleton/runner.rb +3 -3
- data/lib/service_skeleton/ultravisor_children.rb +4 -1
- data/lib/service_skeleton/ultravisor_loggerstash.rb +9 -1
- data/service_skeleton.gemspec +5 -7
- data/ultravisor/.yardopts +1 -0
- data/ultravisor/Guardfile +9 -0
- data/ultravisor/README.md +404 -0
- data/ultravisor/lib/ultravisor.rb +216 -0
- data/ultravisor/lib/ultravisor/child.rb +481 -0
- data/ultravisor/lib/ultravisor/child/call.rb +21 -0
- data/ultravisor/lib/ultravisor/child/call_receiver.rb +14 -0
- data/ultravisor/lib/ultravisor/child/cast.rb +16 -0
- data/ultravisor/lib/ultravisor/child/cast_receiver.rb +11 -0
- data/ultravisor/lib/ultravisor/child/process_cast_call.rb +39 -0
- data/ultravisor/lib/ultravisor/error.rb +25 -0
- data/ultravisor/lib/ultravisor/logging_helpers.rb +32 -0
- data/ultravisor/spec/example_group_methods.rb +19 -0
- data/ultravisor/spec/example_methods.rb +8 -0
- data/ultravisor/spec/spec_helper.rb +56 -0
- data/ultravisor/spec/ultravisor/add_child_spec.rb +79 -0
- data/ultravisor/spec/ultravisor/child/call_spec.rb +121 -0
- data/ultravisor/spec/ultravisor/child/cast_spec.rb +111 -0
- data/ultravisor/spec/ultravisor/child/id_spec.rb +21 -0
- data/ultravisor/spec/ultravisor/child/new_spec.rb +152 -0
- data/ultravisor/spec/ultravisor/child/restart_delay_spec.rb +40 -0
- data/ultravisor/spec/ultravisor/child/restart_spec.rb +70 -0
- data/ultravisor/spec/ultravisor/child/run_spec.rb +95 -0
- data/ultravisor/spec/ultravisor/child/shutdown_spec.rb +124 -0
- data/ultravisor/spec/ultravisor/child/spawn_spec.rb +107 -0
- data/ultravisor/spec/ultravisor/child/unsafe_instance_spec.rb +55 -0
- data/ultravisor/spec/ultravisor/child/wait_spec.rb +32 -0
- data/ultravisor/spec/ultravisor/new_spec.rb +71 -0
- data/ultravisor/spec/ultravisor/remove_child_spec.rb +49 -0
- data/ultravisor/spec/ultravisor/run_spec.rb +334 -0
- data/ultravisor/spec/ultravisor/shutdown_spec.rb +106 -0
- metadata +48 -29
- 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:
|
4
|
+
version: 1.0.5
|
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:
|
12
|
+
date: 2021-03-04 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: frankenstein
|
@@ -86,20 +87,6 @@ dependencies:
|
|
86
87
|
- - "~>"
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
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
90
|
- !ruby/object:Gem::Dependency
|
104
91
|
name: bundler
|
105
92
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,16 +175,16 @@ dependencies:
|
|
188
175
|
name: rake
|
189
176
|
requirement: !ruby/object:Gem::Requirement
|
190
177
|
requirements:
|
191
|
-
- - "
|
178
|
+
- - ">="
|
192
179
|
- !ruby/object:Gem::Version
|
193
|
-
version: '
|
180
|
+
version: '0'
|
194
181
|
type: :development
|
195
182
|
prerelease: false
|
196
183
|
version_requirements: !ruby/object:Gem::Requirement
|
197
184
|
requirements:
|
198
|
-
- - "
|
185
|
+
- - ">="
|
199
186
|
- !ruby/object:Gem::Version
|
200
|
-
version: '
|
187
|
+
version: '0'
|
201
188
|
- !ruby/object:Gem::Dependency
|
202
189
|
name: redcarpet
|
203
190
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,16 +217,16 @@ dependencies:
|
|
230
217
|
name: rubocop
|
231
218
|
requirement: !ruby/object:Gem::Requirement
|
232
219
|
requirements:
|
233
|
-
- - "
|
220
|
+
- - ">="
|
234
221
|
- !ruby/object:Gem::Version
|
235
|
-
version: '0
|
222
|
+
version: '0'
|
236
223
|
type: :development
|
237
224
|
prerelease: false
|
238
225
|
version_requirements: !ruby/object:Gem::Requirement
|
239
226
|
requirements:
|
240
|
-
- - "
|
227
|
+
- - ">="
|
241
228
|
- !ruby/object:Gem::Version
|
242
|
-
version: '0
|
229
|
+
version: '0'
|
243
230
|
- !ruby/object:Gem::Dependency
|
244
231
|
name: rubocop-discourse
|
245
232
|
requirement: !ruby/object:Gem::Requirement
|
@@ -290,15 +277,16 @@ description: |
|
|
290
277
|
for your services, as well as a collection of helper classes to manage
|
291
278
|
common aspects of a system service.
|
292
279
|
email:
|
293
|
-
-
|
280
|
+
- sam.saffron@discourse.org
|
294
281
|
executables: []
|
295
282
|
extensions: []
|
296
283
|
extra_rdoc_files: []
|
297
284
|
files:
|
298
285
|
- ".editorconfig"
|
286
|
+
- ".git-blame-ignore-revs"
|
287
|
+
- ".github/workflows/ci.yml"
|
299
288
|
- ".gitignore"
|
300
289
|
- ".rubocop.yml"
|
301
|
-
- ".travis.yml"
|
302
290
|
- ".yardopts"
|
303
291
|
- CODE_OF_CONDUCT.md
|
304
292
|
- CONTRIBUTING.md
|
@@ -331,6 +319,37 @@ files:
|
|
331
319
|
- lib/service_skeleton/ultravisor_children.rb
|
332
320
|
- lib/service_skeleton/ultravisor_loggerstash.rb
|
333
321
|
- service_skeleton.gemspec
|
322
|
+
- ultravisor/.yardopts
|
323
|
+
- ultravisor/Guardfile
|
324
|
+
- ultravisor/README.md
|
325
|
+
- ultravisor/lib/ultravisor.rb
|
326
|
+
- ultravisor/lib/ultravisor/child.rb
|
327
|
+
- ultravisor/lib/ultravisor/child/call.rb
|
328
|
+
- ultravisor/lib/ultravisor/child/call_receiver.rb
|
329
|
+
- ultravisor/lib/ultravisor/child/cast.rb
|
330
|
+
- ultravisor/lib/ultravisor/child/cast_receiver.rb
|
331
|
+
- ultravisor/lib/ultravisor/child/process_cast_call.rb
|
332
|
+
- ultravisor/lib/ultravisor/error.rb
|
333
|
+
- ultravisor/lib/ultravisor/logging_helpers.rb
|
334
|
+
- ultravisor/spec/example_group_methods.rb
|
335
|
+
- ultravisor/spec/example_methods.rb
|
336
|
+
- ultravisor/spec/spec_helper.rb
|
337
|
+
- ultravisor/spec/ultravisor/add_child_spec.rb
|
338
|
+
- ultravisor/spec/ultravisor/child/call_spec.rb
|
339
|
+
- ultravisor/spec/ultravisor/child/cast_spec.rb
|
340
|
+
- ultravisor/spec/ultravisor/child/id_spec.rb
|
341
|
+
- ultravisor/spec/ultravisor/child/new_spec.rb
|
342
|
+
- ultravisor/spec/ultravisor/child/restart_delay_spec.rb
|
343
|
+
- ultravisor/spec/ultravisor/child/restart_spec.rb
|
344
|
+
- ultravisor/spec/ultravisor/child/run_spec.rb
|
345
|
+
- ultravisor/spec/ultravisor/child/shutdown_spec.rb
|
346
|
+
- ultravisor/spec/ultravisor/child/spawn_spec.rb
|
347
|
+
- ultravisor/spec/ultravisor/child/unsafe_instance_spec.rb
|
348
|
+
- ultravisor/spec/ultravisor/child/wait_spec.rb
|
349
|
+
- ultravisor/spec/ultravisor/new_spec.rb
|
350
|
+
- ultravisor/spec/ultravisor/remove_child_spec.rb
|
351
|
+
- ultravisor/spec/ultravisor/run_spec.rb
|
352
|
+
- ultravisor/spec/ultravisor/shutdown_spec.rb
|
334
353
|
homepage: https://github.com/discourse/service_skeleton
|
335
354
|
licenses: []
|
336
355
|
metadata: {}
|
@@ -345,11 +364,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
345
364
|
version: 2.5.0
|
346
365
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
347
366
|
requirements:
|
348
|
-
- - "
|
367
|
+
- - ">="
|
349
368
|
- !ruby/object:Gem::Version
|
350
|
-
version:
|
369
|
+
version: '0'
|
351
370
|
requirements: []
|
352
|
-
rubygems_version: 3.
|
371
|
+
rubygems_version: 3.1.4
|
353
372
|
signing_key:
|
354
373
|
specification_version: 4
|
355
374
|
summary: The bare bones of a service
|