Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoh committed Jan 2, 2025
1 parent 3f83db0 commit c10dfc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 10 additions & 3 deletions packages/duckdb-server-rust/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ async fn handle_post(
query::handle(&state, params).await
}

pub fn app(dp_path: Option<&str>, connection_pool_size: Option<u32>, cache_size: Option<usize>) -> Result<Router> {
pub fn app(
dp_path: Option<&str>,
connection_pool_size: Option<u32>,
cache_size: Option<usize>,
) -> Result<Router> {
// Database and state setup
let db = ConnectionPool::new(dp_path.unwrap_or(":memory:"), connection_pool_size.unwrap_or(10))?;
let db = ConnectionPool::new(
dp_path.unwrap_or(":memory:"),
connection_pool_size.unwrap_or(10),
)?;
let cache = lru::LruCache::new(cache_size.unwrap_or(1000).try_into()?);

let state = Arc::new(AppState {
Expand All @@ -64,4 +71,4 @@ pub fn app(dp_path: Option<&str>, connection_pool_size: Option<u32>, cache_size:
.layer(cors)
.layer(CompressionLayer::new())
.layer(TraceLayer::new_for_http()))
}
}
10 changes: 7 additions & 3 deletions packages/duckdb-server-rust/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use axum_server::tls_rustls::RustlsConfig;
use clap::Parser;
use listenfd::ListenFd;
use std::net::TcpListener;
use std::{net::Ipv4Addr, net::SocketAddr, path::PathBuf};
use tokio::net;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use clap::Parser;

mod app;
mod bundle;
Expand All @@ -30,7 +30,7 @@ struct Args {
#[arg(long, default_value_t = 10)]
connection_pool_size: u32,

/// Max number of cache entries
/// Max number of cache entries
#[arg(long, default_value_t = 1000)]
cache_size: usize,
}
Expand All @@ -50,7 +50,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.init();

// App setup
let app = app::app(Some(&args.database), Some(args.connection_pool_size), Some(args.cache_size))?;
let app = app::app(
Some(&args.database),
Some(args.connection_pool_size),
Some(args.cache_size),
)?;

// TLS configuration
let mut config = RustlsConfig::from_pem_file(
Expand Down

0 comments on commit c10dfc8

Please sign in to comment.