djanderson opened a new issue, #5116: URL: https://github.com/apache/arrow-rs/issues/5116
**Which part is this question about** <!-- Is it code base, library api, documentation or some other part? --> https://github.com/apache/arrow-rs/blob/master/arrow-flight/examples/server.rs#L48 **Describe your question** <!-- A clear and concise description of what the question is. --> I've been struggling to understand how to implement something like `list_actions` in a non-trivial way (i.e., with an ObjectStore), but the example is `unimplemented` and the example for `ObjectStore.list` also doesn't give too many clues on how to use it in something like `list_flights`. The issue I'm running into is that I initialize a connection to an ObjectStore and store it in a session context, but I cannot understand how to convert a stream of ObjectMeta from the object store into a steam of FlightInfo as a response to `list_flights`, since the ListFlightsStream has a static lifetime. ```rust #[derive(Clone, Debug)] struct SessionContext { object_store: Arc<dyn ObjectStore>, } pub struct FlightServiceImpl { sessions: Arc<Mutex<HashMap<String, SessionContext>>>, } ``` ```rust #[tonic::async_trait] impl FlightService for FlightServiceImpl { async fn handshake(&self, request: Request<Streaming<HandshakeRequest>>,) -> Result<Response<Self::HandshakeStream>, Status> { // Validate user and initialize an `object_store` with appropriate scope let session_token = self.generate_session_token(); self.sessions.lock().unwrap().insert( session_token, SessionContext { object_store: Arc::new(object_store) }, ); // Complete handshake } async fn list_flights( &self, request: Request<Criteria>, ) -> Result<Response<Self::ListFlightsStream>, Status> { let context = self.check_session_token(&request)?; let prefix = None; // HELP: the response stream is 'static but context.object_store is not let object_meta = context.object_store.list(prefix); let result = object_meta.filter_map(|meta| async move { let Ok(file_meta) = meta else { return None; }; // Build the FlightInfo }); Ok(Response::new(Box::pin(result) as Self::ListFlightsStream)) } ``` But I'm getting the error: ```rust error[E0597]: `context.object_store` does not live long enough --> src/main.rs:164:27 | 162 | let context = self.check_session_token(&request)?; | ------- binding `context` declared here 163 | let prefix = None; 164 | let object_meta = context.object_store.list(prefix); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough ... 196 | Ok(Response::new(Box::pin(result) as Self::ListFlightsStream)) | ------------------------------------------- type annotation requires that `context.object_store` is borrowed for `'static` 197 | } | - `context.object_store` dropped here while still borrowed ``` **Additional context** <!-- Add any other context about the problem here. --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
