Skip to content

Commit ddf8e4c

Browse files
committed
refactor: accept Arc<SessionContext> for serve
1 parent 26af6f5 commit ddf8e4c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

datafusion-postgres-cli/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::ffi::OsStr;
22
use std::fs;
3+
use std::sync::Arc;
34

45
use datafusion::execution::options::{
56
ArrowReadOptions, AvroReadOptions, CsvReadOptions, NdJsonReadOptions, ParquetReadOptions,
@@ -184,7 +185,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
184185
.with_host(opts.host)
185186
.with_port(opts.port);
186187

187-
serve(session_context, &server_options)
188+
serve(Arc::new(session_context), &server_options)
188189
.await
189190
.map_err(|e| format!("Failed to run server: {}", e))?;
190191

datafusion-postgres/src/handlers.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ pub struct DfSessionService {
6161
}
6262

6363
impl DfSessionService {
64-
pub fn new(session_context: SessionContext) -> DfSessionService {
65-
let session_context = Arc::new(session_context);
64+
pub fn new(session_context: Arc<SessionContext>) -> DfSessionService {
6665
let parser = Arc::new(Parser {
6766
session_context: session_context.clone(),
6867
});

datafusion-postgres/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl Default for ServerOptions {
3737

3838
/// Serve the Datafusion `SessionContext` with Postgres protocol.
3939
pub async fn serve(
40-
session_context: SessionContext,
40+
session_context: Arc<SessionContext>,
4141
opts: &ServerOptions,
4242
) -> Result<(), std::io::Error> {
4343
// Create the handler factory with the session context and catalog name

0 commit comments

Comments
 (0)