|
61 | 61 | ensure |
62 | 62 | worker_task&.stop |
63 | 63 | end |
64 | | - |
65 | | - it "allows monitors to access state" do |
66 | | - custom_state = {name: "outbox"} |
67 | | - worker = Async::Service::Supervisor::Worker.new( |
68 | | - process_id: ::Process.pid, |
69 | | - endpoint: endpoint, |
70 | | - state: custom_state |
71 | | - ) |
72 | | - worker_task = worker.run |
73 | | - |
74 | | - # Wait for registration via the registration monitor |
75 | | - event = registration_monitor.pop(timeout: 5) |
76 | | - |
77 | | - expect(event).to be_truthy |
78 | | - supervisor_controller = event.supervisor_controller |
79 | | - |
80 | | - # Verify state can be accessed by monitors |
81 | | - expect(supervisor_controller.state[:name]).to be == "outbox" |
82 | | - ensure |
83 | | - worker_task&.stop |
84 | | - end |
85 | 64 | end |
86 | 65 |
|
87 | 66 | with "memory_dump" do |
|
173 | 152 | worker_task&.stop |
174 | 153 | end |
175 | 154 | end |
176 | | - |
177 | | - with "state handling" do |
178 | | - it "stores state on supervisor_controller during registration" do |
179 | | - custom_state = {name: "test-service", version: "1.0"} |
180 | | - worker = Async::Service::Supervisor::Worker.new( |
181 | | - process_id: ::Process.pid, |
182 | | - endpoint: endpoint, |
183 | | - state: custom_state |
184 | | - ) |
185 | | - worker_task = worker.run |
186 | | - |
187 | | - # Wait for registration via the registration monitor |
188 | | - event = registration_monitor.pop(timeout: 5) |
189 | | - |
190 | | - expect(event).to be_truthy |
191 | | - supervisor_controller = event.supervisor_controller |
192 | | - |
193 | | - expect(supervisor_controller.state).to have_keys( |
194 | | - name: be == "test-service", |
195 | | - version: be == "1.0" |
196 | | - ) |
197 | | - ensure |
198 | | - worker_task&.stop |
199 | | - end |
200 | | - |
201 | | - it "defaults to empty state hash" do |
202 | | - worker = Async::Service::Supervisor::Worker.new(process_id: ::Process.pid, endpoint: endpoint) |
203 | | - worker_task = worker.run |
204 | | - |
205 | | - # Wait for registration via the registration monitor |
206 | | - event = registration_monitor.pop(timeout: 5) |
207 | | - |
208 | | - expect(event).to be_truthy |
209 | | - supervisor_controller = event.supervisor_controller |
210 | | - |
211 | | - expect(supervisor_controller.state).to be == {} |
212 | | - ensure |
213 | | - worker_task&.stop |
214 | | - end |
215 | | - |
216 | | - it "allows monitors to access state" do |
217 | | - custom_state = {name: "outbox"} |
218 | | - worker = Async::Service::Supervisor::Worker.new( |
219 | | - process_id: ::Process.pid, |
220 | | - endpoint: endpoint, |
221 | | - state: custom_state |
222 | | - ) |
223 | | - worker_task = worker.run |
224 | | - |
225 | | - # Wait for registration via the registration monitor |
226 | | - event = registration_monitor.pop(timeout: 5) |
227 | | - |
228 | | - expect(event).to be_truthy |
229 | | - supervisor_controller = event.supervisor_controller |
230 | | - |
231 | | - # Verify state can be accessed by monitors |
232 | | - expect(supervisor_controller.state[:name]).to be == "outbox" |
233 | | - ensure |
234 | | - worker_task&.stop |
235 | | - end |
236 | | - end |
237 | | - |
238 | 155 | end |
239 | | - |
0 commit comments