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

Method do_handshake

datafusion-examples/examples/flight/sql_server.rs:218–245  ·  view source on GitHub ↗
(
        &self,
        _request: Request<Streaming<HandshakeRequest>>,
    )

Source from the content-addressed store, hash-verified

216 type FlightService = FlightSqlServiceImpl;
217
218 async fn do_handshake(
219 &self,
220 _request: Request<Streaming<HandshakeRequest>>,
221 ) -> Result<
222 Response<Pin<Box<dyn Stream<Item = Result<HandshakeResponse, Status>> + Send>>>,
223 Status,
224 > {
225 info!("do_handshake");
226 // no authentication actually takes place here
227 // see Ballista implementation for example of basic auth
228 // in this case, we simply accept the connection and create a new SessionContext
229 // the SessionContext will be re-used within this same connection/session
230 let token = self.create_ctx().await?;
231
232 let result = HandshakeResponse {
233 protocol_version: 0,
234 payload: token.as_bytes().to_vec().into(),
235 };
236 let result = Ok(result);
237 let output = futures::stream::iter(vec![result]);
238 let str = format!("Bearer {token}");
239 let mut resp: Response<Pin<Box<dyn Stream<Item = Result<_, _>> + Send>>> =
240 Response::new(Box::pin(output));
241 let md = MetadataValue::try_from(str)
242 .map_err(|_| Status::invalid_argument("authorization not parsable"))?;
243 resp.metadata_mut().insert("authorization", md);
244 Ok(resp)
245 }
246
247 async fn do_get_fallback(
248 &self,

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
create_ctxMethod · 0.80
to_vecMethod · 0.80
intoMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected