@@ -103,7 +103,7 @@ async fn sdam_pool_management() {
103
103
. build ( )
104
104
. await ;
105
105
106
- let mut subscriber = client. events . subscribe_all ( ) ;
106
+ let mut subscriber = client. events . stream_all ( ) ;
107
107
108
108
if !VersionReq :: parse ( ">= 4.2.9" )
109
109
. unwrap ( )
@@ -116,14 +116,14 @@ async fn sdam_pool_management() {
116
116
}
117
117
118
118
subscriber
119
- . wait_for_event ( Duration :: from_millis ( 500 ) , |event| {
119
+ . next_match ( Duration :: from_millis ( 500 ) , |event| {
120
120
matches ! ( event, Event :: Cmap ( CmapEvent :: PoolReady ( _) ) )
121
121
} )
122
122
. await
123
123
. expect ( "should see pool ready event" ) ;
124
124
125
125
subscriber
126
- . wait_for_event ( Duration :: from_millis ( 500 ) , |event| {
126
+ . next_match ( Duration :: from_millis ( 500 ) , |event| {
127
127
matches ! ( event, Event :: Sdam ( SdamEvent :: ServerHeartbeatSucceeded ( _) ) )
128
128
} )
129
129
. await
@@ -143,9 +143,7 @@ async fn sdam_pool_management() {
143
143
144
144
// Since there is no deterministic ordering, simply collect all the events and check for their
145
145
// presence.
146
- let events = subscriber
147
- . collect_events ( Duration :: from_secs ( 1 ) , |_| true )
148
- . await ;
146
+ let events = subscriber. collect ( Duration :: from_secs ( 1 ) , |_| true ) . await ;
149
147
assert ! ( events
150
148
. iter( )
151
149
. any( |e| matches!( e, Event :: Sdam ( SdamEvent :: ServerHeartbeatFailed ( _) ) ) ) ) ;
@@ -186,7 +184,7 @@ async fn hello_ok_true() {
186
184
187
185
let buffer = EventBuffer :: new ( ) ;
188
186
189
- let mut subscriber = buffer. subscribe ( ) ;
187
+ let mut event_stream = buffer. stream ( ) ;
190
188
191
189
let mut options = setup_client_options. clone ( ) ;
192
190
options. sdam_event_handler = Some ( buffer. handler ( ) ) ;
@@ -195,8 +193,8 @@ async fn hello_ok_true() {
195
193
let _client = Client :: with_options ( options) . expect ( "client creation should succeed" ) ;
196
194
197
195
// first heartbeat should be legacy hello but contain helloOk
198
- subscriber
199
- . wait_for_event ( Duration :: from_millis ( 2000 ) , |event| {
196
+ event_stream
197
+ . next_match ( Duration :: from_millis ( 2000 ) , |event| {
200
198
if let Event :: Sdam ( SdamEvent :: ServerHeartbeatSucceeded ( e) ) = event {
201
199
assert_eq ! ( e. reply. get_bool( "helloOk" ) , Ok ( true ) ) ;
202
200
assert ! ( e. reply. get( LEGACY_HELLO_COMMAND_NAME_LOWERCASE ) . is_some( ) ) ;
@@ -210,8 +208,8 @@ async fn hello_ok_true() {
210
208
211
209
// subsequent heartbeats should just be hello
212
210
for _ in 0 ..3 {
213
- subscriber
214
- . wait_for_event ( Duration :: from_millis ( 2000 ) , |event| {
211
+ event_stream
212
+ . next_match ( Duration :: from_millis ( 2000 ) , |event| {
215
213
if let Event :: Sdam ( SdamEvent :: ServerHeartbeatSucceeded ( e) ) = event {
216
214
assert ! ( e. reply. get( "isWritablePrimary" ) . is_some( ) ) ;
217
215
assert ! ( e. reply. get( LEGACY_HELLO_COMMAND_NAME_LOWERCASE ) . is_none( ) ) ;
@@ -270,13 +268,13 @@ async fn removed_server_monitor_stops() -> crate::error::Result<()> {
270
268
let hosts = options. hosts . clone ( ) ;
271
269
let set_name = options. repl_set_name . clone ( ) . unwrap ( ) ;
272
270
273
- let mut subscriber = buffer. subscribe ( ) ;
271
+ let mut event_stream = buffer. stream ( ) ;
274
272
let topology = Topology :: new ( options) ?;
275
273
276
274
// Wait until all three monitors have started.
277
275
let mut seen_monitors = HashSet :: new ( ) ;
278
- subscriber
279
- . wait_for_event ( Duration :: from_millis ( 500 ) , |event| {
276
+ event_stream
277
+ . next_match ( Duration :: from_millis ( 500 ) , |event| {
280
278
if let Event :: Sdam ( SdamEvent :: ServerHeartbeatStarted ( e) ) = event {
281
279
seen_monitors. insert ( e. server_address . clone ( ) ) ;
282
280
}
@@ -315,13 +313,13 @@ async fn removed_server_monitor_stops() -> crate::error::Result<()> {
315
313
) )
316
314
. await ;
317
315
318
- subscriber . wait_for_event ( Duration :: from_secs ( 1 ) , |event| {
316
+ event_stream . next_match ( Duration :: from_secs ( 1 ) , |event| {
319
317
matches ! ( event, Event :: Sdam ( SdamEvent :: ServerClosed ( e) ) if e. address == hosts[ 2 ] )
320
318
} ) . await . expect ( "should see server closed event" ) ;
321
319
322
320
// Capture heartbeat events for 1 second. The monitor for the removed server should stop
323
321
// publishing them.
324
- let events = subscriber . collect_events ( Duration :: from_secs ( 1 ) , |event| {
322
+ let events = event_stream . collect ( Duration :: from_secs ( 1 ) , |event| {
325
323
matches ! ( event, Event :: Sdam ( SdamEvent :: ServerHeartbeatStarted ( e) ) if e. server_address == hosts[ 2 ] )
326
324
} ) . await ;
327
325
0 commit comments