Skip to content

Commit affaf01

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

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-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

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)