File tree Expand file tree Collapse file tree 4 files changed +27
-7
lines changed
fixtures/async/container/supervisor
lib/async/container/supervisor Expand file tree Collapse file tree 4 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 12
12
module Async
13
13
module Container
14
14
module Supervisor
15
+ class RegistrationMonitor
16
+ def initialize
17
+ @registrations = [ ]
18
+ end
19
+
20
+ attr :registrations
21
+
22
+ def run
23
+ end
24
+
25
+ def register ( connection )
26
+ @registrations << connection
27
+ end
28
+
29
+ def remove ( connection )
30
+ @registrations . delete ( connection )
31
+ end
32
+ end
33
+
15
34
AServer = Sus ::Shared ( "a server" ) do
16
35
include Sus ::Fixtures ::Async ::SchedulerContext
17
36
@@ -25,7 +44,9 @@ def around(&block)
25
44
end
26
45
end
27
46
28
- let ( :server ) { Async ::Container ::Supervisor ::Server . new ( @bound_endpoint ) }
47
+ let ( :registration_monitor ) { RegistrationMonitor . new }
48
+ let ( :monitors ) { [ registration_monitor ] }
49
+ let ( :server ) { Async ::Container ::Supervisor ::Server . new ( @bound_endpoint , monitors : monitors ) }
29
50
30
51
before do
31
52
@bound_endpoint = endpoint . bound
Original file line number Diff line number Diff line change @@ -69,7 +69,6 @@ def run
69
69
70
70
task . children &.each ( &:wait )
71
71
ensure
72
- Console . info ( self , "Stopping..." )
73
72
task . stop
74
73
end
75
74
end
Original file line number Diff line number Diff line change 4
4
# Copyright, 2025, by Samuel Williams.
5
5
6
6
require "async"
7
+ require "async/service/generic"
7
8
require "io/endpoint/bound_endpoint"
8
9
9
10
module Async
Original file line number Diff line number Diff line change @@ -23,12 +23,11 @@ def to_json(...)
23
23
client = Async ::Container ::Supervisor ::Client . new ( instance , endpoint )
24
24
connection = client . connect
25
25
26
- sleep ( 0.001 ) until server . registered . any?
26
+ sleep ( 0.001 ) until registration_monitor . registrations . any?
27
27
28
- registration = server . registered . first
29
- expect ( registration . last ) . to have_keys (
30
- action : be == "register" ,
31
- instance : be == instance . as_json ,
28
+ registration = registration_monitor . registrations . first
29
+ expect ( registration . state ) . to have_keys (
30
+ process_id : be == ::Process . pid
32
31
)
33
32
end
34
33
end
You can’t perform that action at this time.
0 commit comments