MCPcopy Create free account
hub / github.com/apache/datafusion / start_postgres

Function start_postgres

datafusion/sqllogictest/bin/postgres_container.rs:110–144  ·  view source on GitHub ↗
(
    in_channel: &Channel<ContainerCommands>,
    host_channel: &Channel<String>,
    port_channel: &Channel<u16>,
    stopped_channel: &Channel<()>,
)

Source from the content-addressed store, hash-verified

108}
109
110async fn start_postgres(
111 in_channel: &Channel<ContainerCommands>,
112 host_channel: &Channel<String>,
113 port_channel: &Channel<u16>,
114 stopped_channel: &Channel<()>,
115) {
116 info!("Starting postgres test container with user postgres/postgres and db test");
117
118 let container = postgres::Postgres::default()
119 .with_user("postgres")
120 .with_password("postgres")
121 .with_db_name("test")
122 .with_mapped_port(16432, 5432.tcp())
123 .with_tag("17-alpine")
124 .start()
125 .await
126 .unwrap();
127 // uncomment this if you are running docker in docker
128 // let host = "host.docker.internal".to_string();
129 let host = container.get_host().await.unwrap().to_string();
130 let port = container.get_host_port_ipv4(5432).await.unwrap();
131
132 let mut rx = in_channel.rx.lock().await;
133 while let Some(command) = rx.recv().await {
134 match command {
135 FetchHost => host_channel.tx.send(host.clone()).unwrap(),
136 FetchPort => port_channel.tx.send(port).unwrap(),
137 ContainerCommands::Stop => {
138 container.stop().await.unwrap();
139 stopped_channel.tx.send(()).unwrap();
140 rx.close();
141 }
142 }
143 }
144}
145
146fn is_pg_uri_set() -> bool {
147 env::var("PG_URI").is_ok()

Callers 1

Calls 7

recvMethod · 0.80
closeMethod · 0.80
startMethod · 0.45
to_stringMethod · 0.45
sendMethod · 0.45
cloneMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…