MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / into_future

Method into_future

src/environmentd/src/test_util.rs:1212–1250  ·  view source on GitHub ↗
(mut self)

Source from the content-addressed store, hash-verified

1210 type IntoFuture = BoxFuture<'static, Self::Output>;
1211
1212 fn into_future(mut self) -> Self::IntoFuture {
1213 Box::pin(async move {
1214 assert!(
1215 self.pg_config.get_ports().is_empty(),
1216 "specifying multiple ports is not supported"
1217 );
1218 self.pg_config.port(self.port);
1219
1220 let (client, mut conn) = self.pg_config.connect(self.tls).await?;
1221 let mut notice_callback = self.notice_callback.take();
1222
1223 let handle = task::spawn(|| "connect", async move {
1224 while let Some(msg) = std::future::poll_fn(|cx| conn.poll_message(cx)).await {
1225 match msg {
1226 Ok(AsyncMessage::Notice(notice)) => {
1227 if let Some(callback) = notice_callback.as_mut() {
1228 callback(notice);
1229 }
1230 }
1231 Ok(msg) => {
1232 tracing::debug!(?msg, "Dropping message from database");
1233 }
1234 Err(e) => {
1235 // tokio_postgres::Connection docs say:
1236 // > Return values of None or Some(Err(_)) are “terminal”; callers
1237 // > should not invoke this method again after receiving one of those
1238 // > values.
1239 tracing::info!("connection error: {e}");
1240 break;
1241 }
1242 }
1243 }
1244 tracing::info!("connection closed");
1245 });
1246
1247 let output = H::transform_result(client, handle);
1248 Ok(output)
1249 })
1250 }
1251}
1252
1253/// A running instance of `environmentd`, that exposes blocking/synchronous test helpers.

Callers 1

test_auth_deduplicationFunction · 0.45

Calls 5

spawnFunction · 0.85
portMethod · 0.45
connectMethod · 0.45
takeMethod · 0.45
as_mutMethod · 0.45

Tested by

no test coverage detected