Skip to content

Commit a794c94

Browse files
committed
feat: add getset for serveroptions
1 parent af30b53 commit a794c94

File tree

4 files changed

+50
-6
lines changed

4 files changed

+50
-6
lines changed

Cargo.lock

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-postgres-cli/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
9999
println!("Loaded {} as table {}", table_path, table_name);
100100
}
101101

102-
let server_options = ServerOptions {
103-
host: opts.host.clone(),
104-
port: opts.port,
105-
};
102+
let server_options = ServerOptions::new()
103+
.with_host(opts.host)
104+
.with_port(opts.port);
106105

107106
serve(session_context, &server_options)
108107
.await

datafusion-postgres/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ bytes = "1.10.1"
2121
chrono = { version = "0.4", features = ["std"] }
2222
datafusion = { workspace = true }
2323
futures = "0.3"
24+
getset = "0.1"
2425
log = "0.4"
2526
pgwire = { workspace = true }
2627
postgres-types = "0.2"

datafusion-postgres/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ pub use handlers::{DfSessionService, HandlerFactory, Parser};
88
use std::sync::Arc;
99

1010
use datafusion::prelude::SessionContext;
11+
use getset::{Getters, Setters, WithSetters};
1112
use pgwire::tokio::process_socket;
1213
use tokio::net::TcpListener;
1314

15+
#[derive(Getters, Setters, WithSetters)]
16+
#[getset(get = "pub", set = "pub", set_with = "pub")]
1417
pub struct ServerOptions {
15-
pub host: String,
16-
pub port: u16,
18+
host: String,
19+
port: u16,
20+
}
21+
22+
impl ServerOptions {
23+
pub fn new() -> ServerOptions {
24+
ServerOptions::default()
25+
}
1726
}
1827

1928
impl Default for ServerOptions {

0 commit comments

Comments
 (0)