From 6b84578d11a7efb5d1aa527c8e3570f6133d9f60 Mon Sep 17 00:00:00 2001 From: Jiawei Zhao Date: Fri, 13 Nov 2026 22:07:18 +0800 Subject: [PATCH] feat(flight)!: support CloseSession Allow Flight SQL clients to release server sessions and inspect the reported status. Support manual verification with the example server and the CLI close-session command. BREAKING CHANGE: FlightSqlServiceClient::close now returns Result instead of Result<()> and sends a server request instead of succeeding without doing anything. Callers are responsible for handling the returned close status. CloseSession actions now dispatch to do_action_close_session instead of do_action_fallback. Servers that handled CloseSession in the fallback should move that logic to the new method; its default implementation returns Unimplemented. CLOSE #6516 --- arrow-flight/examples/flight_sql_server.rs | 58 +++++--- arrow-flight/src/arrow.flight.protocol.rs | 70 +++++++++ arrow-flight/src/bin/flight_sql_client.rs | 7 + arrow-flight/src/lib.rs | 8 ++ arrow-flight/src/sql/client.rs | 27 ++-- arrow-flight/src/sql/server.rs | 39 +++++- arrow-flight/tests/flight_sql_client.rs | 156 ++++++++++++++++++++- format/Flight.proto | 31 ++++ 8 files changed, 365 insertions(+), 31 deletions(-) diff --git a/arrow-flight/examples/flight_sql_server.rs b/arrow-flight/examples/flight_sql_server.rs index 8419ff8dbc50..922dd9b8d93c 100644 --- a/arrow-flight/examples/flight_sql_server.rs +++ b/arrow-flight/examples/flight_sql_server.rs @@ -12,11 +12,12 @@ use prost::Message; use std::collections::HashSet; use std::pin::Pin; use std::str::FromStr; -use std::sync::{Arc, LazyLock}; +use std::sync::{Arc, LazyLock, Mutex}; use tonic::metadata::MetadataValue; use tonic::transport::Server; use tonic::transport::{Certificate, Identity, ServerTlsConfig}; use tonic::{Request, Response, Status, Streaming}; +use uuid::Uuid; use arrow_array::builder::StringBuilder; use arrow_array::{ArrayRef, RecordBatch}; @@ -39,8 +40,9 @@ use arrow_flight::sql::{ }; use arrow_flight::utils::batches_to_flight_data; use arrow_flight::{ - Action, FlightData, FlightDescriptor, FlightEndpoint, FlightInfo, HandshakeRequest, - HandshakeResponse, IpcMessage, SchemaAsIpc, Ticket, flight_service_server::FlightService, + Action, CloseSessionRequest, CloseSessionResult, FlightData, FlightDescriptor, FlightEndpoint, + FlightInfo, HandshakeRequest, HandshakeResponse, IpcMessage, SchemaAsIpc, Ticket, + close_session_result::Status as CloseSessionStatus, flight_service_server::FlightService, flight_service_server::FlightServiceServer, }; use arrow_ipc::writer::IpcWriteOptions; @@ -52,7 +54,6 @@ macro_rules! status { }; } -const FAKE_TOKEN: &str = "uuid_token"; const FAKE_HANDLE: &str = "uuid_handle"; const FAKE_UPDATE_RESULT: i64 = 1; @@ -94,11 +95,13 @@ static INSTANCE_XBDC_DATA: LazyLock = LazyLock::new(|| { static TABLES: LazyLock> = LazyLock::new(|| vec!["flight_sql.example.table"]); -#[derive(Clone)] -pub struct FlightSqlServiceImpl {} +#[derive(Clone, Default)] +pub struct FlightSqlServiceImpl { + sessions: Arc>>, +} impl FlightSqlServiceImpl { - fn check_token(&self, req: &Request) -> Result<(), Status> { + fn get_token(&self, req: &Request) -> Result { let metadata = req.metadata(); let auth = metadata.get("authorization").ok_or_else(|| { Status::internal(format!("No authorization header! metadata = {metadata:?}")) @@ -111,8 +114,12 @@ impl FlightSqlServiceImpl { if !authorization.starts_with(bearer) { Err(Status::internal("Invalid auth header!"))?; } - let token = authorization[bearer.len()..].to_string(); - if token == FAKE_TOKEN { + Ok(authorization[bearer.len()..].to_string()) + } + + fn check_token(&self, req: &Request) -> Result<(), Status> { + let token = self.get_token(req)?; + if self.sessions.lock().unwrap().contains(&token) { Ok(()) } else { Err(Status::unauthenticated("invalid token ")) @@ -167,14 +174,17 @@ impl FlightSqlService for FlightSqlServiceImpl { Err(Status::unauthenticated("Invalid credentials!"))? } + let session_id = Uuid::new_v4().to_string(); + self.sessions.lock().unwrap().insert(session_id.clone()); + println!("Created session: {session_id}"); let result = HandshakeResponse { protocol_version: 0, - payload: FAKE_TOKEN.into(), + payload: session_id.clone().into(), }; let result = Ok(result); let output = futures::stream::iter(vec![result]); - let token = format!("Bearer {FAKE_TOKEN}"); + let token = format!("Bearer {session_id}"); let mut response: Response + Send>>> = Response::new(Box::pin(output)); response.metadata_mut().append( @@ -661,6 +671,22 @@ impl FlightSqlService for FlightSqlServiceImpl { Ok(res) } + async fn do_action_close_session( + &self, + _query: CloseSessionRequest, + request: Request, + ) -> Result { + let token = self.get_token(&request)?; + if !self.sessions.lock().unwrap().remove(&token) { + println!("CloseSession: NotFound"); + return Err(Status::not_found("Session not found")); + } + println!("CloseSession: Closed"); + Ok(CloseSessionResult { + status: CloseSessionStatus::Closed as i32, + }) + } + async fn do_action_close_prepared_statement( &self, _query: ActionClosePreparedStatementRequest, @@ -735,7 +761,7 @@ async fn main() -> Result<(), Box> { let key = std::fs::read_to_string("arrow-flight/examples/data/server.key")?; let client_ca = std::fs::read_to_string("arrow-flight/examples/data/ca_root.pem")?; - let svc = FlightServiceServer::new(FlightSqlServiceImpl {}); + let svc = FlightServiceServer::new(FlightSqlServiceImpl::default()); let tls_config = ServerTlsConfig::new() .identity(Identity::from_pem(&cert, &key)) .client_ca_root(Certificate::from_pem(&client_ca)); @@ -746,7 +772,7 @@ async fn main() -> Result<(), Box> { .serve(addr) .await?; } else { - let svc = FlightServiceServer::new(FlightSqlServiceImpl {}); + let svc = FlightServiceServer::new(FlightSqlServiceImpl::default()); Server::builder().add_service(svc).serve(addr).await?; } @@ -832,7 +858,7 @@ mod tests { let uds = UnixListener::bind(path.clone()).unwrap(); let stream = UnixListenerStream::new(uds); - let service = FlightSqlServiceImpl {}; + let service = FlightSqlServiceImpl::default(); let serve_future = Server::builder() .add_service(FlightServiceServer::new(service)) .serve_with_incoming(stream); @@ -863,7 +889,7 @@ mod tests { let (incoming, addr) = bind_tcp().await; let uri = format!("http://{}:{}", addr.ip(), addr.port()); - let service = FlightSqlServiceImpl {}; + let service = FlightSqlServiceImpl::default(); let serve_future = Server::builder() .add_service(FlightServiceServer::new(service)) .serve_with_incoming(incoming); @@ -899,7 +925,7 @@ mod tests { let (incoming, addr) = bind_tcp().await; let uri = format!("https://{}:{}", addr.ip(), addr.port()); - let svc = FlightServiceServer::new(FlightSqlServiceImpl {}); + let svc = FlightServiceServer::new(FlightSqlServiceImpl::default()); let serve_future = Server::builder() .tls_config(tls_config) diff --git a/arrow-flight/src/arrow.flight.protocol.rs b/arrow-flight/src/arrow.flight.protocol.rs index 719f967915c9..e5710df18ee7 100644 --- a/arrow-flight/src/arrow.flight.protocol.rs +++ b/arrow-flight/src/arrow.flight.protocol.rs @@ -429,6 +429,76 @@ pub struct PutResult { pub app_metadata: ::prost::bytes::Bytes, } /// +/// Request message for the "Close Session" action. +/// +/// The existing session is referenced via a cookie header. +#[allow(clippy::all)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct CloseSessionRequest {} +/// +/// The result of closing a session. +#[allow(clippy::all)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct CloseSessionResult { + #[prost(enumeration = "close_session_result::Status", tag = "1")] + pub status: i32, +} +/// Nested message and enum types in `CloseSessionResult`. +pub mod close_session_result { + #[allow(clippy::all)] + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum Status { + /// Protobuf deserialization fallback value: The session close status is unknown or + /// not recognized. Servers should avoid using this value (send a NOT_FOUND error if + /// the requested session is not known or expired). Clients can retry the request. + Unspecified = 0, + /// The session close request is complete. Subsequent requests with + /// the same session produce a NOT_FOUND error. + Closed = 1, + /// The session close request is in progress. The client may retry + /// the close request. + Closing = 2, + /// The session is not closeable. The client should not retry the + /// close request. + NotCloseable = 3, + } + impl Status { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "UNSPECIFIED", + Self::Closed => "CLOSED", + Self::Closing => "CLOSING", + Self::NotCloseable => "NOT_CLOSEABLE", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNSPECIFIED" => Some(Self::Unspecified), + "CLOSED" => Some(Self::Closed), + "CLOSING" => Some(Self::Closing), + "NOT_CLOSEABLE" => Some(Self::NotCloseable), + _ => None, + } + } + } +} +/// /// The result of a cancel operation. /// /// This is used by CancelFlightInfoResult.status. diff --git a/arrow-flight/src/bin/flight_sql_client.rs b/arrow-flight/src/bin/flight_sql_client.rs index 59dd5ceb196f..1461f97be379 100644 --- a/arrow-flight/src/bin/flight_sql_client.rs +++ b/arrow-flight/src/bin/flight_sql_client.rs @@ -159,6 +159,8 @@ struct Args { /// Different available commands. #[derive(Debug, Subcommand)] enum Command { + /// Close the current server session. + CloseSession, /// Get catalogs. Catalogs, /// Get db schemas for a catalog. @@ -243,6 +245,11 @@ async fn main() -> Result<()> { .context("setup client")?; let flight_info = match args.cmd { + Command::CloseSession => { + let result = client.close().await.context("close session")?; + println!("{result:?}"); + return Ok(()); + } Command::Catalogs => client.get_catalogs().await.context("get catalogs")?, Command::DbSchemas { catalog, diff --git a/arrow-flight/src/lib.rs b/arrow-flight/src/lib.rs index b804b0f06692..c1a71f8bdb90 100644 --- a/arrow-flight/src/lib.rs +++ b/arrow-flight/src/lib.rs @@ -65,6 +65,12 @@ pub mod flight_descriptor { pub use r#gen::flight_descriptor::DescriptorType; } +/// Defines the status returned when closing a session. +pub mod close_session_result { + use super::r#gen; + pub use r#gen::close_session_result::Status; +} + /// Low Level [tonic] [`FlightServiceClient`](gen::flight_service_client::FlightServiceClient). pub mod flight_service_client { use super::r#gen; @@ -100,6 +106,8 @@ pub use r#gen::BasicAuth; pub use r#gen::CancelFlightInfoRequest; pub use r#gen::CancelFlightInfoResult; pub use r#gen::CancelStatus; +pub use r#gen::CloseSessionRequest; +pub use r#gen::CloseSessionResult; pub use r#gen::Criteria; pub use r#gen::Empty; pub use r#gen::FlightData; diff --git a/arrow-flight/src/sql/client.rs b/arrow-flight/src/sql/client.rs index 3ef5487c594b..e051699aa520 100644 --- a/arrow-flight/src/sql/client.rs +++ b/arrow-flight/src/sql/client.rs @@ -22,6 +22,7 @@ use crate::encode::FlightDataEncoderBuilder; use crate::error::FlightError; use crate::error::Result; use crate::flight_service_client::FlightServiceClient; +use crate::r#gen::CloseSessionRequest; use crate::sql::r#gen::action_end_transaction_request::EndTransaction; use crate::sql::server::{ BEGIN_TRANSACTION, CLOSE_PREPARED_STATEMENT, CREATE_PREPARED_STATEMENT, END_TRANSACTION, @@ -39,8 +40,8 @@ use crate::sql::{ use crate::streams::FallibleRequestStream; use crate::trailers::extract_lazy_trailers; use crate::{ - Action, FlightData, FlightDescriptor, FlightInfo, HandshakeRequest, HandshakeResponse, - IpcMessage, PutResult, Ticket, + Action, CloseSessionResult, FlightData, FlightDescriptor, FlightInfo, HandshakeRequest, + HandshakeResponse, IpcMessage, PutResult, Ticket, }; use arrow_array::RecordBatch; use arrow_schema::{ArrowError, Schema}; @@ -442,15 +443,19 @@ where Ok(()) } - /// Explicitly shut down and clean up the client. - #[expect( - clippy::unused_async, - clippy::unused_async_trait_impl, - reason = "public API: dropping `async` would break callers that `.await` it" - )] - pub async fn close(&mut self) -> Result<()> { - // TODO: consume self instead of &mut self to explicitly prevent reuse? - Ok(()) + /// Close the current server session using the configured request headers. + /// + /// Returns the server's close status for the caller to handle. + pub async fn close(&mut self) -> Result { + let action = Action::new("CloseSession", CloseSessionRequest {}.encode_to_vec()); + let mut results = self.do_action(action).await?; + let result = results.message().await?.ok_or_else(|| { + FlightError::protocol("Server closed the stream without sending a result") + })?; + let result = CloseSessionResult::decode(result.body)?; + while results.message().await?.is_some() {} + + Ok(result) } fn set_request_headers(&self, mut req: tonic::Request) -> Result> { diff --git a/arrow-flight/src/sql/server.rs b/arrow-flight/src/sql/server.rs index ed505b811ca5..53dfec0676fc 100644 --- a/arrow-flight/src/sql/server.rs +++ b/arrow-flight/src/sql/server.rs @@ -21,9 +21,9 @@ use super::{ SqlInfo, TicketStatementQuery, }; use crate::{ - Action, ActionType, Criteria, Empty, FlightData, FlightDescriptor, FlightInfo, - HandshakeRequest, HandshakeResponse, PutResult, SchemaResult, Ticket, - flight_service_server::FlightService, r#gen::PollInfo, + Action, ActionType, CloseSessionRequest, CloseSessionResult, Criteria, Empty, FlightData, + FlightDescriptor, FlightInfo, HandshakeRequest, HandshakeResponse, PutResult, SchemaResult, + Ticket, flight_service_server::FlightService, r#gen::PollInfo, }; use futures::{Stream, StreamExt, stream::Peekable}; use prost::Message; @@ -37,6 +37,7 @@ pub(crate) static END_TRANSACTION: &str = "EndTransaction"; pub(crate) static BEGIN_SAVEPOINT: &str = "BeginSavepoint"; pub(crate) static END_SAVEPOINT: &str = "EndSavepoint"; pub(crate) static CANCEL_QUERY: &str = "CancelQuery"; +pub(crate) static CLOSE_SESSION: &str = "CloseSession"; /// Implements FlightSqlService to handle the flight sql protocol // `async_trait` marks the boxed futures returned by provided methods `#[must_use]` @@ -461,6 +462,22 @@ pub trait FlightSqlService: Sync + Send + Sized + 'static { None } + /// Close the session identified by the request headers. + /// + /// `CloseSession` actions are dispatched to this method instead of + /// [`Self::do_action_fallback`]. Implementations that previously handled + /// `CloseSession` in that fallback should move their session cleanup logic here; + /// request decoding and response encoding are handled by the library. + async fn do_action_close_session( + &self, + _query: CloseSessionRequest, + _request: Request, + ) -> Result { + Err(Status::unimplemented( + "do_action_close_session has no default implementation", + )) + } + /// Create a prepared statement from given SQL statement. async fn do_action_create_prepared_statement( &self, @@ -835,6 +852,13 @@ where Response Message: ActionCancelQueryResult" .into(), }; + let close_session_action_type = ActionType { + r#type: CLOSE_SESSION.to_string(), + description: "Closes the current session.\n + Request Message: CloseSessionRequest\n + Response Message: CloseSessionResult" + .into(), + }; let mut actions: Vec> = vec![ Ok(create_prepared_statement_action_type), Ok(close_prepared_statement_action_type), @@ -844,6 +868,7 @@ where Ok(begin_savepoint_action_type), Ok(end_savepoint_action_type), Ok(cancel_query_action_type), + Ok(close_session_action_type), ]; if let Some(mut custom_actions) = self.list_custom_actions().await { @@ -968,6 +993,14 @@ where body: stmt.as_any().encode_to_vec().into(), })]); return Ok(Response::new(Box::pin(output))); + } else if request.get_ref().r#type == CLOSE_SESSION { + let query = CloseSessionRequest::decode(&*request.get_ref().body) + .map_err(decode_error_to_status)?; + let result = self.do_action_close_session(query, request).await?; + let output = futures::stream::iter(vec![Ok(super::super::r#gen::Result { + body: result.encode_to_vec().into(), + })]); + return Ok(Response::new(Box::pin(output))); } self.do_action_fallback(request).await diff --git a/arrow-flight/tests/flight_sql_client.rs b/arrow-flight/tests/flight_sql_client.rs index cbea67b10e40..417f9c6b1ea9 100644 --- a/arrow-flight/tests/flight_sql_client.rs +++ b/arrow-flight/tests/flight_sql_client.rs @@ -5,9 +5,11 @@ mod common; use crate::common::fixture::TestFixture; +use crate::common::server::TestFlightServer; use crate::common::utils::make_primitive_batch; use arrow_array::RecordBatch; +use arrow_flight::close_session_result::Status as CloseSessionStatus; use arrow_flight::decode::FlightRecordBatchStream; use arrow_flight::encode::FlightDataEncoderBuilder; use arrow_flight::error::FlightError; @@ -19,7 +21,9 @@ use arrow_flight::sql::{ CommandStatementIngest, EndTransaction, FallibleRequestStream, ProstMessageExt, TableDefinitionOptions, TableExistsOption, TableNotExistOption, }; -use arrow_flight::{Action, FlightData, FlightDescriptor}; +use arrow_flight::{ + Action, CloseSessionRequest, CloseSessionResult, Empty, FlightData, FlightDescriptor, +}; use futures::{StreamExt, TryStreamExt}; use prost::Message; use std::collections::{HashMap, HashSet}; @@ -28,6 +32,131 @@ use tokio::sync::Mutex; use tonic::{IntoStreamingRequest, Request, Status}; use uuid::Uuid; +#[tokio::test] +async fn test_close_session_statuses() { + let test_server = TestFlightServer::new(); + let fixture = TestFixture::new(test_server.service()).await; + let mut client = FlightSqlServiceClient::new(fixture.channel().await); + + for status in [ + CloseSessionStatus::Unspecified, + CloseSessionStatus::Closed, + CloseSessionStatus::Closing, + CloseSessionStatus::NotCloseable, + ] { + let response = CloseSessionResult { + status: status as i32, + }; + test_server.set_do_action_response(vec![Ok(arrow_flight::Result::new( + response.encode_to_vec(), + ))]); + assert_eq!(client.close().await.unwrap(), response); + } + + let unknown_status = 99; + let response = CloseSessionResult { + status: unknown_status, + }; + test_server.set_do_action_response(vec![Ok(arrow_flight::Result::new( + response.encode_to_vec(), + ))]); + assert_eq!(client.close().await.unwrap().status, unknown_status); + fixture.shutdown_and_wait().await; +} + +#[tokio::test] +async fn test_close_session_errors() { + let test_server = TestFlightServer::new(); + let fixture = TestFixture::new(test_server.service()).await; + let mut client = FlightSqlServiceClient::new(fixture.channel().await); + + test_server.set_do_action_response(vec![]); + assert!(matches!( + client.close().await, + Err(FlightError::ProtocolError(_)) + )); + + test_server.set_do_action_response(vec![Ok(arrow_flight::Result::new(vec![0xff]))]); + assert!(matches!( + client.close().await, + Err(FlightError::DecodeError(_)) + )); + + let closed = CloseSessionResult { + status: CloseSessionStatus::Closed as i32, + }; + test_server.set_do_action_response(vec![ + Ok(arrow_flight::Result::new(closed.encode_to_vec())), + Err(Status::not_found("Session not found")), + ]); + let err = client.close().await.unwrap_err(); + assert!(matches!(err, FlightError::Tonic(status) if status.code() == tonic::Code::NotFound)); + fixture.shutdown_and_wait().await; +} + +#[tokio::test] +async fn test_close_session_sql_server() { + let test_server = FlightSqlServiceImpl::new(); + let cookie = "arrow_flight_session_id=test-session"; + test_server.sessions.lock().await.insert(cookie.into()); + let fixture = TestFixture::new(test_server.service()).await; + let mut client = FlightSqlServiceClient::new(fixture.channel().await); + client.set_header("cookie", cookie); + client.set_token("test-token".into()); + + let actions: Vec<_> = client + .inner_mut() + .list_actions(Empty {}) + .await + .unwrap() + .into_inner() + .try_collect() + .await + .unwrap(); + assert!(actions.iter().any(|action| action.r#type == "CloseSession")); + + let err = client + .do_action(Action::new("CloseSession", vec![0xff])) + .await + .unwrap_err(); + assert!( + matches!(err, FlightError::Tonic(status) if status.code() == tonic::Code::InvalidArgument) + ); + assert!(test_server.sessions.lock().await.contains(cookie)); + + assert_eq!( + client.close().await.unwrap().status(), + CloseSessionStatus::Closed + ); + assert!(test_server.sessions.lock().await.is_empty()); + + let err = client.close().await.unwrap_err(); + assert!(matches!(err, FlightError::Tonic(status) if status.code() == tonic::Code::NotFound)); + fixture.shutdown_and_wait().await; +} + +#[tokio::test] +async fn test_close_session_unimplemented() { + struct DefaultService; + + #[tonic::async_trait] + impl FlightSqlService for DefaultService { + type FlightService = Self; + } + + let err = arrow_flight::flight_service_server::FlightService::do_action( + &DefaultService, + Request::new(Action::new( + "CloseSession", + CloseSessionRequest {}.encode_to_vec(), + )), + ) + .await + .err() + .unwrap(); + assert_eq!(err.code(), tonic::Code::Unimplemented); +} + #[tokio::test] pub async fn test_begin_end_transaction() { let test_server = FlightSqlServiceImpl::new(); @@ -210,6 +339,7 @@ fn make_ingest_command() -> CommandStatementIngest { #[derive(Clone)] pub struct FlightSqlServiceImpl { + sessions: Arc>>, transactions: Arc>>, ingested_batches: Arc>>, } @@ -217,6 +347,7 @@ pub struct FlightSqlServiceImpl { impl FlightSqlServiceImpl { pub fn new() -> Self { Self { + sessions: Arc::new(Mutex::new(HashSet::new())), transactions: Arc::new(Mutex::new(HashSet::new())), ingested_batches: Arc::new(Mutex::new(Vec::new())), } @@ -240,6 +371,29 @@ impl Default for FlightSqlServiceImpl { impl FlightSqlService for FlightSqlServiceImpl { type FlightService = FlightSqlServiceImpl; + async fn do_action_close_session( + &self, + _query: CloseSessionRequest, + request: Request, + ) -> Result { + assert_eq!( + request.metadata().get("authorization").unwrap(), + "Bearer test-token" + ); + let cookie = request + .metadata() + .get("cookie") + .ok_or_else(|| Status::invalid_argument("Missing session cookie"))? + .to_str() + .map_err(|_| Status::invalid_argument("Invalid session cookie"))?; + if !self.sessions.lock().await.remove(cookie) { + return Err(Status::not_found("Session not found")); + } + Ok(CloseSessionResult { + status: CloseSessionStatus::Closed as i32, + }) + } + async fn do_action_begin_transaction( &self, _query: ActionBeginTransactionRequest, diff --git a/format/Flight.proto b/format/Flight.proto index a8c6e72dbe56..f911eea2585b 100644 --- a/format/Flight.proto +++ b/format/Flight.proto @@ -562,3 +562,34 @@ message FlightData { message PutResult { bytes app_metadata = 1; } + +/* + * Request message for the "Close Session" action. + * + * The existing session is referenced via a cookie header. + */ +message CloseSessionRequest { +} + +/* + * The result of closing a session. + */ +message CloseSessionResult { + enum Status { + // Protobuf deserialization fallback value: The session close status is unknown or + // not recognized. Servers should avoid using this value (send a NOT_FOUND error if + // the requested session is not known or expired). Clients can retry the request. + UNSPECIFIED = 0; + // The session close request is complete. Subsequent requests with + // the same session produce a NOT_FOUND error. + CLOSED = 1; + // The session close request is in progress. The client may retry + // the close request. + CLOSING = 2; + // The session is not closeable. The client should not retry the + // close request. + NOT_CLOSEABLE = 3; + } + + Status status = 1; +}