Skip to content

Commit 07af2dd

Browse files
committed
Add port option
1 parent 913d731 commit 07af2dd

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

server/src/handlers/livetail.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::net::{Ipv4Addr, SocketAddrV4};
1+
use std::net::SocketAddr;
22

33
use arrow_flight::encode::FlightDataEncoderBuilder;
44
use cookie::Cookie;
@@ -21,6 +21,7 @@ use tower_http::cors::{Any, CorsLayer};
2121

2222
use crate::livetail::{Message, LIVETAIL};
2323
use crate::metadata::STREAM_INFO;
24+
use crate::option::CONFIG;
2425
use crate::rbac::map::SessionKey;
2526
use crate::rbac::{self, Users};
2627
use crate::utils;
@@ -143,7 +144,13 @@ impl FlightService for FlightServiceImpl {
143144
}
144145

145146
pub fn server() -> impl Future<Output = Result<(), Box<dyn std::error::Error + Send>>> + Send {
146-
let addr = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 7000);
147+
let mut addr: SocketAddr = CONFIG
148+
.parseable
149+
.address
150+
.parse()
151+
.expect("valid socket address");
152+
addr.set_port(CONFIG.parseable.livetail_port);
153+
147154
let service = FlightServiceImpl {};
148155

149156
let svc = FlightServiceServer::new(service);
@@ -160,7 +167,7 @@ pub fn server() -> impl Future<Output = Result<(), Box<dyn std::error::Error + S
160167
.layer(cors)
161168
.layer(GrpcWebLayer::new())
162169
.add_service(svc)
163-
.serve(std::net::SocketAddr::V4(addr))
170+
.serve(addr)
164171
.map_err(|err| Box::new(err) as Box<dyn std::error::Error + Send>)
165172
}
166173

server/src/option.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ pub struct Server {
196196
/// Open AI access key
197197
pub open_ai_key: Option<String>,
198198

199+
/// Livetail port
200+
pub livetail_port: u16,
201+
199202
/// Rows in Parquet Rowgroup
200203
pub row_group_size: usize,
201204

@@ -250,6 +253,10 @@ impl FromArgMatches for Server {
250253
.cloned()
251254
.expect("default for send analytics");
252255
self.open_ai_key = m.get_one::<String>(Self::OPEN_AI_KEY).cloned();
256+
self.livetail_port = m
257+
.get_one::<u16>(Self::LIVETAIL_PORT)
258+
.cloned()
259+
.expect("default for livetail port");
253260
// converts Gib to bytes before assigning
254261
self.query_memory_pool_size = m
255262
.get_one::<u8>(Self::QUERY_MEM_POOL_SIZE)
@@ -314,6 +321,7 @@ impl Server {
314321
pub const OPENID_CLIENT_ID: &str = "oidc-client";
315322
pub const OPENID_CLIENT_SECRET: &str = "oidc-client-secret";
316323
pub const OPENID_ISSUER: &str = "oidc-issuer";
324+
pub const LIVETAIL_PORT: &str = "livetail-port";
317325
// todo : what should this flag be
318326
pub const QUERY_MEM_POOL_SIZE: &str = "query-mempool-size";
319327
pub const ROW_GROUP_SIZE: &str = "row-group-size";
@@ -457,6 +465,16 @@ impl Server {
457465
.value_parser(validation::url)
458466
.help("Set host global domain address"),
459467
)
468+
.arg(
469+
Arg::new(Self::LIVETAIL_PORT)
470+
.long(Self::LIVETAIL_PORT)
471+
.env("P_FLIGHT_PORT")
472+
.value_name("PORT")
473+
.default_value("8001")
474+
.required(false)
475+
.value_parser(value_parser!(u16))
476+
.help("Set port for livetail arrow flight server"),
477+
)
460478
.arg(
461479
Arg::new(Self::QUERY_MEM_POOL_SIZE)
462480
.long(Self::QUERY_MEM_POOL_SIZE)

0 commit comments

Comments
 (0)