Skip to content

Commit 4537e5d

Browse files
committed
Make client task transient.
1 parent 5f9651b commit 4537e5d

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

lib/async/container/supervisor/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def connect
4545

4646
# Run the client in a loop, reconnecting if necessary.
4747
def run
48-
Async do
48+
Async(annotation: "Supervisor Client", transient: true) do
4949
loop do
5050
connection = connect!
5151

releases.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## Unreleased
4+
5+
- Make client task (in supervised worker) transient, so that it doesn't keep the reactor alive unnecessarily. It also won't be stopped by default when SIGINT is received, so that the worker will remain connected to the supervisor until the worker is completely terminated.
6+
37
## v0.6.3
48

59
- Add agent context documentation.

test/async/container/client.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2025, by Samuel Williams.
5+
6+
require "async/container/supervisor/a_server"
7+
require "sus/fixtures/console/captured_logger"
8+
9+
describe Async::Container::Supervisor::Client do
10+
include Async::Container::Supervisor::AServer
11+
include Sus::Fixtures::Console::CapturedLogger
12+
13+
let(:client) {subject.new(endpoint: endpoint)}
14+
15+
with "#connect" do
16+
it "can connect to a server" do
17+
client.connect do |connection|
18+
expect(connection).to be_a(Async::Container::Supervisor::Connection)
19+
end
20+
end
21+
end
22+
23+
with "#run" do
24+
it "can run the client" do
25+
connected = Async::Promise.new
26+
expect(client).to receive(:connected!){|connection| connected.resolve(true)}
27+
28+
client_task = client.run
29+
30+
expect(client_task).to be(:transient?)
31+
expect(connected.wait).to be == true
32+
33+
client_task.stop
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)