async-container 0.16.1 → 0.16.6

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/lib/async/container/controller.rb +16 -10
  3. data/lib/async/container/generic.rb +14 -5
  4. data/lib/async/container/group.rb +5 -12
  5. data/lib/async/container/hybrid.rb +11 -2
  6. data/lib/async/container/notify.rb +3 -1
  7. data/{spec/async/container/notify_spec.rb → lib/async/container/notify/console.rb} +37 -23
  8. data/lib/async/container/notify/pipe.rb +4 -19
  9. data/lib/async/container/notify/server.rb +1 -1
  10. data/lib/async/container/process.rb +1 -7
  11. data/lib/async/container/thread.rb +3 -6
  12. data/lib/async/container/version.rb +1 -1
  13. metadata +31 -73
  14. data/.editorconfig +0 -6
  15. data/.github/workflows/development.yml +0 -36
  16. data/.gitignore +0 -21
  17. data/.rspec +0 -3
  18. data/.travis.yml +0 -21
  19. data/.yardopts +0 -1
  20. data/Gemfile +0 -19
  21. data/Guardfile +0 -14
  22. data/README.md +0 -140
  23. data/Rakefile +0 -8
  24. data/async-container.gemspec +0 -34
  25. data/examples/async.rb +0 -22
  26. data/examples/channel.rb +0 -45
  27. data/examples/channels/client.rb +0 -104
  28. data/examples/container.rb +0 -33
  29. data/examples/isolate.rb +0 -36
  30. data/examples/minimal.rb +0 -94
  31. data/examples/test.rb +0 -51
  32. data/examples/threads.rb +0 -25
  33. data/examples/title.rb +0 -13
  34. data/examples/udppipe.rb +0 -35
  35. data/spec/async/container/controller_spec.rb +0 -95
  36. data/spec/async/container/forked_spec.rb +0 -61
  37. data/spec/async/container/hybrid_spec.rb +0 -36
  38. data/spec/async/container/notify/notify.rb +0 -19
  39. data/spec/async/container/notify/pipe_spec.rb +0 -48
  40. data/spec/async/container/shared_examples.rb +0 -80
  41. data/spec/async/container/threaded_spec.rb +0 -35
  42. data/spec/async/container_spec.rb +0 -41
  43. data/spec/spec_helper.rb +0 -15
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
-
23
- require 'async/container/hybrid'
24
- require 'async/container/best'
25
-
26
- require_relative 'shared_examples'
27
-
28
- RSpec.describe Async::Container::Hybrid, if: Async::Container.fork? do
29
- subject {described_class.new}
30
-
31
- it_behaves_like Async::Container
32
-
33
- it "should be multiprocess" do
34
- expect(described_class).to be_multiprocess
35
- end
36
- end
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative '../../../../lib/async/container'
5
-
6
- class MyController < Async::Container::Controller
7
- def setup(container)
8
- container.run(restart: false) do |instance|
9
- sleep(rand)
10
-
11
- instance.ready!
12
-
13
- sleep(rand)
14
- end
15
- end
16
- end
17
-
18
- controller = MyController.new
19
- controller.run
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
-
23
- require "async/container/controller"
24
-
25
- RSpec.describe Async::Container::Notify::Pipe do
26
- let(:notify_script) {File.expand_path("notify.rb", __dir__)}
27
-
28
- it "receives notification of child status" do
29
- container = Async::Container.new
30
-
31
- container.spawn(restart: false) do |instance|
32
- instance.exec(
33
- "bundle", "exec", "--keep-file-descriptors",
34
- notify_script, ready: false
35
- )
36
- end
37
-
38
- # Wait for the state to be updated by the child process:
39
- container.sleep
40
-
41
- child, state = container.state.first
42
- expect(state).to be == {status: "Initializing..."}
43
-
44
- container.wait
45
-
46
- expect(container.statistics).to have_attributes(failures: 0)
47
- end
48
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
-
23
- require 'async/rspec/reactor'
24
-
25
- RSpec.shared_examples_for Async::Container do
26
- it "can run concurrently" do
27
- input, output = IO.pipe
28
-
29
- subject.async do
30
- output.write "Hello World"
31
- end
32
-
33
- subject.wait
34
-
35
- output.close
36
- expect(input.read).to be == "Hello World"
37
- end
38
-
39
- it "can run concurrently" do
40
- subject.async(name: "Sleepy Jerry") do |task, instance|
41
- 3.times do |i|
42
- instance.name = "Counting Sheep #{i}"
43
-
44
- sleep 0.01
45
- end
46
- end
47
-
48
- subject.wait
49
- end
50
-
51
- describe '#sleep' do
52
- it "can sleep for a short time" do
53
- subject.spawn do
54
- sleep(0.2)
55
- raise "Boom"
56
- end
57
-
58
- subject.sleep(0.1)
59
- expect(subject.statistics).to have_attributes(failures: 0)
60
-
61
- subject.wait
62
-
63
- expect(subject.statistics).to have_attributes(failures: 1)
64
- end
65
- end
66
-
67
- describe '#stop' do
68
- it 'can stop the child process' do
69
- subject.spawn do
70
- sleep(1)
71
- end
72
-
73
- is_expected.to be_running
74
-
75
- subject.stop
76
-
77
- is_expected.to_not be_running
78
- end
79
- end
80
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
-
23
- require "async/container/threaded"
24
-
25
- require_relative 'shared_examples'
26
-
27
- RSpec.describe Async::Container::Threaded do
28
- subject {described_class.new}
29
-
30
- it_behaves_like Async::Container
31
-
32
- it "should not be multiprocess" do
33
- expect(described_class).to_not be_multiprocess
34
- end
35
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
-
23
- require "async/container"
24
-
25
- RSpec.describe Async::Container do
26
- it "can get processor count" do
27
- expect(Async::Container.processor_count).to be >= 1
28
- end
29
-
30
- it "can get best container class" do
31
- expect(Async::Container.best_container_class).to_not be_nil
32
- end
33
-
34
- subject {Async::Container.new}
35
-
36
- it "can get best container class" do
37
- expect(subject).to_not be_nil
38
-
39
- subject.stop
40
- end
41
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'covered/rspec'
4
-
5
- # Shared rspec helpers:
6
- require "async/rspec"
7
-
8
- RSpec.configure do |config|
9
- # Enable flags like --only-failures and --next-failure
10
- config.example_status_persistence_file_path = ".rspec_status"
11
-
12
- config.expect_with :rspec do |c|
13
- c.syntax = :expect
14
- end
15
- end