Skip to content

Commit 03d539f

Browse files
committed
Modernize code.
1 parent 21d71fa commit 03d539f

6 files changed

Lines changed: 69 additions & 51 deletions

File tree

.github/workflows/documentation-coverage.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ permissions:
77

88
env:
99
COVERAGE: PartialSummary
10+
BUNDLE_WITH: maintenance
1011

1112
jobs:
1213
validate:

gems.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2017-2025, by Samuel Williams.
4+
# Copyright, 2017-2026, by Samuel Williams.
55

66
source "https://rubygems.org"
77

@@ -14,13 +14,14 @@
1414

1515
gem "agent-context"
1616

17+
gem "decode"
18+
1719
gem "utopia-project"
1820
end
1921

2022
group :test do
2123
gem "sus"
2224
gem "covered"
23-
gem "decode"
2425

2526
gem "rubocop"
2627
gem "rubocop-socketry"

readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ We welcome contributions to this project.
8282
4. Push to the branch (`git push origin my-new-feature`).
8383
5. Create new Pull Request.
8484

85+
### Running Tests
86+
87+
To run the test suite:
88+
89+
``` shell
90+
bundle exec sus
91+
```
92+
93+
### Making Releases
94+
95+
To make a new release:
96+
97+
``` shell
98+
bundle exec bake gem:release:patch # or minor or major
99+
```
100+
85101
### Developer Certificate of Origin
86102

87103
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.

test/async/container/forked.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2018-2025, by Samuel Williams.
4+
# Copyright, 2018-2026, by Samuel Williams.
55
# Copyright, 2020, by Olle Jonsson.
66

77
require "async/container/best"
@@ -10,61 +10,61 @@
1010

1111
describe Async::Container::Forked do
1212
let(:container) {subject.new}
13-
13+
1414
it_behaves_like Async::Container::AContainer
15-
15+
1616
it "can restart child" do
1717
trigger = IO.pipe
1818
pids = IO.pipe
19-
19+
2020
thread = Thread.new do
2121
container.async(restart: true) do
2222
trigger.first.gets
2323
pids.last.puts Process.pid.to_s
2424
end
25-
25+
2626
container.wait
2727
end
28-
28+
2929
3.times do
3030
trigger.last.puts "die"
3131
_child_pid = pids.first.gets
3232
end
33-
33+
3434
thread.kill
3535
thread.join
36-
36+
3737
expect(container.statistics.spawns).to be == 1
3838
expect(container.statistics.restarts).to be == 2
3939
end
40-
40+
4141
it "can handle interrupts" do
4242
finished = IO.pipe
4343
interrupted = IO.pipe
44-
44+
4545
container.spawn(restart: true) do |instance|
4646
Thread.handle_interrupt(Interrupt => :never) do
4747
instance.ready!
48-
48+
4949
finished.first.gets
5050
rescue ::Interrupt
5151
interrupted.last.puts "incorrectly interrupted"
5252
end
5353
rescue ::Interrupt
5454
interrupted.last.puts "correctly interrupted"
5555
end
56-
56+
5757
container.wait_until_ready
58-
58+
5959
container.group.interrupt
6060
sleep(0.001)
6161
finished.last.puts "finished"
62-
62+
6363
expect(interrupted.first.gets).to be == "correctly interrupted\n"
64-
64+
6565
container.stop
6666
end
67-
67+
6868
it "should be multiprocess" do
6969
expect(subject).to be(:multiprocess?)
7070
end

test/async/container/hybrid.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2019-2025, by Samuel Williams.
4+
# Copyright, 2019-2026, by Samuel Williams.
55

66
require "async/container/hybrid"
77
require "async/container/best"
88
require "async/container/a_container"
99

1010
describe Async::Container::Hybrid do
1111
it_behaves_like Async::Container::AContainer
12-
12+
1313
it "should be multiprocess" do
1414
expect(subject).to be(:multiprocess?)
1515
end

test/async/container/notify.rb

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,36 @@
1212
let(:server) {subject::Server.open}
1313
let(:notify_socket) {server.path}
1414
let(:client) {subject::Socket.new(notify_socket)}
15-
15+
1616
it "can send and receive messages" do
1717
context = server.bind
18-
18+
1919
client.send(hello: "world", count: 42)
20-
20+
2121
message = context.receive
22-
22+
2323
# Custom fields are transmitted as strings per the systemd protocol
2424
expect(message).to be == {hello: "world", count: "42"}
2525
end
26-
26+
2727
with "#ready!" do
2828
it "should send message" do
2929
begin
3030
context = server.bind
31-
31+
3232
pid = fork do
3333
client.ready!
3434
end
35-
35+
3636
messages = []
37-
37+
3838
Sync do
3939
context.receive do |message, address|
4040
messages << message
4141
break
4242
end
4343
end
44-
44+
4545
expect(messages.last).to have_keys(
4646
ready: be == true
4747
)
@@ -51,77 +51,77 @@
5151
end
5252
end
5353
end
54-
54+
5555
with "#healthy!" do
5656
it "sends healthy message" do
5757
context = server.bind
58-
58+
5959
client.healthy!
60-
60+
6161
message = context.receive
62-
62+
6363
expect(message).to have_keys(
6464
healthy: be == true
6565
)
6666
end
67-
67+
6868
it "sends healthy message with additional details" do
6969
context = server.bind
70-
70+
7171
client.healthy!(status: "All systems operational", uptime: 3600)
72-
72+
7373
message = context.receive
74-
74+
7575
expect(message).to have_keys(
7676
healthy: be == true,
7777
status: be == "All systems operational",
7878
uptime: be == "3600"
7979
)
8080
end
8181
end
82-
82+
8383
with "#send" do
8484
it "sends message" do
8585
context = server.bind
86-
86+
8787
client.send(hello: "world")
88-
88+
8989
message = context.receive
90-
90+
9191
expect(message).to be == {hello: "world"}
9292
end
93-
93+
9494
it "fails if the message is too big" do
9595
context = server.bind
96-
96+
9797
expect do
9898
client.send(test: "x" * (subject::Socket::MAXIMUM_MESSAGE_SIZE+1))
9999
end.to raise_exception(ArgumentError, message: be =~ /Message length \d+ exceeds \d+/)
100100
end
101101
end
102-
102+
103103
with "#stopping!" do
104104
it "sends stopping message" do
105105
context = server.bind
106-
106+
107107
client.stopping!
108-
108+
109109
message = context.receive
110-
110+
111111
expect(message).to have_keys(
112112
stopping: be == true
113113
)
114114
end
115115
end
116-
116+
117117
with "#error!" do
118118
it "sends error message" do
119119
context = server.bind
120-
120+
121121
client.error!("Boom!")
122-
122+
123123
message = context.receive
124-
124+
125125
expect(message).to have_keys(
126126
status: be == "Boom!",
127127
errno: be == -1,

0 commit comments

Comments
 (0)