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 1212module Async
1313 module Container
1414 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+
1534 AServer = Sus ::Shared ( "a server" ) do
1635 include Sus ::Fixtures ::Async ::SchedulerContext
1736
@@ -25,7 +44,9 @@ def around(&block)
2544 end
2645 end
2746
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 ) }
2950
3051 before do
3152 @bound_endpoint = endpoint . bound
Original file line number Diff line number Diff line change @@ -69,7 +69,6 @@ def run
6969
7070 task . children &.each ( &:wait )
7171 ensure
72- Console . info ( self , "Stopping..." )
7372 task . stop
7473 end
7574 end
Original file line number Diff line number Diff line change 44# Copyright, 2025, by Samuel Williams.
55
66require "async"
7+ require "async/service/generic"
78require "io/endpoint/bound_endpoint"
89
910module Async
Original file line number Diff line number Diff line change @@ -23,12 +23,11 @@ def to_json(...)
2323 client = Async ::Container ::Supervisor ::Client . new ( instance , endpoint )
2424 connection = client . connect
2525
26- sleep ( 0.001 ) until server . registered . any?
26+ sleep ( 0.001 ) until registration_monitor . registrations . any?
2727
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
3231 )
3332 end
3433end
You can’t perform that action at this time.
0 commit comments