Skip to content

Commit e94d9a1

Browse files
Add http entry point
1 parent 9402048 commit e94d9a1

5 files changed

Lines changed: 38 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ version = "0.2.2"
1717
arrow-flight = { version = "54.1.0", features = [
1818
"flight-sql-experimental",
1919
], optional = true }
20-
axum = "0.8.1"
20+
axum = { version = "0.8.1", optional = true }
2121
clap = { version = "4.5.27", features = ["derive"] }
2222
color-eyre = "0.6.3"
2323
crossterm = { version = "0.28.1", features = ["event-stream"] }
@@ -75,6 +75,7 @@ flightsql = [
7575
]
7676
functions-json = ["datafusion-app/functions-json"]
7777
functions-parquet = ["datafusion-app/functions-parquet"]
78+
http = ["axum"]
7879
hudi = ["datafusion-app/hudi"]
7980
huggingface = ["datafusion-app/huggingface"]
8081
iceberg = ["datafusion-app/iceberg"]

src/args.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ impl DftArgs {
120120

121121
#[derive(Clone, Debug, Subcommand)]
122122
pub enum Command {
123+
/// Start a HTTP server
124+
ServeHttp {
125+
#[clap(short, long)]
126+
config: Option<String>,
127+
},
123128
/// Start a FlightSQL server
124129
ServeFlightSql {
125130
#[clap(short, long)]

src/http_server/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
use crate::{args::DftArgs, config::AppConfig};
19+
use color_eyre::Result;
20+
21+
pub async fn try_run(cli: DftArgs, config: AppConfig) -> Result<()> {
22+
Ok(())
23+
}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ pub mod config;
44
pub mod execution;
55
#[cfg(feature = "flightsql")]
66
pub mod flightsql_server;
7+
#[cfg(feature = "http")]
8+
pub mod http_server;
79
pub mod telemetry;
810
pub mod test_utils;
911
pub mod tui;

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use clap::Parser;
1919
use color_eyre::Result;
2020
#[cfg(feature = "flightsql")]
21-
use datafusion_dft::{args::Command, flightsql_server};
21+
use datafusion_dft::{args::Command, flightsql_server, http_server};
2222
use datafusion_dft::{args::DftArgs, cli, config::create_config, tui};
2323

2424
fn main() -> Result<()> {
@@ -58,6 +58,11 @@ async fn app_entry_point(cli: DftArgs) -> Result<()> {
5858
if let Some(Command::ServeFlightSql { .. }) = cli.command {
5959
flightsql_server::try_run(cli.clone(), cfg.clone()).await?;
6060
}
61+
#[cfg(feature = "http")]
62+
if let Some(Command::ServeHttp { .. }) = cli.command {
63+
http_server::try_run(cli.clone(), cfg.clone()).await?;
64+
}
65+
6166
if !cli.files.is_empty() || !cli.commands.is_empty() {
6267
cli::try_run(cli, cfg).await?;
6368
} else {

0 commit comments

Comments
 (0)