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

Method new

src/pgtest/src/lib.rs:115–140  ·  view source on GitHub ↗
(
        addr: &str,
        user: &'a str,
        timeout: Duration,
        verbose: bool,
        mut options: Vec<(&'a str, &'a str)>,
    )

Source from the content-addressed store, hash-verified

113
114impl PgConn {
115 fn new<'a>(
116 addr: &str,
117 user: &'a str,
118 timeout: Duration,
119 verbose: bool,
120 mut options: Vec<(&'a str, &'a str)>,
121 ) -> anyhow::Result<Self> {
122 let mut conn = Self {
123 stream: TcpStream::connect(addr)?,
124 recv_buf: BytesMut::new(),
125 send_buf: BytesMut::new(),
126 timeout,
127 verbose,
128 };
129
130 conn.stream.set_read_timeout(Some(timeout))?;
131 options.insert(0, ("user", user));
132 options.insert(0, ("welcome_message", "off"));
133 conn.send(|buf| frontend::startup_message(options, buf).unwrap())?;
134 match conn.recv()?.1 {
135 Message::AuthenticationOk => {}
136 _ => bail!("expected AuthenticationOk"),
137 };
138 conn.until(vec!["ReadyForQuery"], vec!['C', 'S', 'M'], BTreeSet::new())?;
139 Ok(conn)
140 }
141
142 fn send<F: FnOnce(&mut BytesMut)>(&mut self, f: F) -> anyhow::Result<()> {
143 self.send_buf.clear();

Callers

nothing calls this directly

Calls 9

unwrapMethod · 0.80
is_someMethod · 0.80
connectFunction · 0.50
insertMethod · 0.45
sendMethod · 0.45
recvMethod · 0.45
untilMethod · 0.45
cloneMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected