Skip to content

Commit ba932ac

Browse files
Devdutt Shenoinikhilsinhaparseable
andauthored
refactor: use clap::Parser for readability (#1088)
als fix Kafka `SslProtocol` parsing --------- Co-authored-by: Nikhil Sinha <[email protected]>
1 parent 8166e7b commit ba932ac

38 files changed

+535
-814
lines changed

src/about.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn print_latest_release(latest_release: update::LatestRelease) {
136136
pub async fn print(config: &Config, meta: &StorageMetadata) {
137137
// print current version
138138
let current = current();
139-
let latest_release = if config.parseable.check_update {
139+
let latest_release = if config.options.check_update {
140140
update::get_latest(&meta.deployment_id).await.ok()
141141
} else {
142142
None

src/alerts/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ impl Alert {
103103
) -> Context {
104104
let deployment_instance = format!(
105105
"{}://{}",
106-
CONFIG.parseable.get_scheme(),
107-
CONFIG.parseable.address
106+
CONFIG.options.get_scheme(),
107+
CONFIG.options.address
108108
);
109109
let deployment_id = storage::StorageMetadata::global().deployment_id;
110110
let deployment_mode = storage::StorageMetadata::global().mode.to_string();

src/analytics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl Report {
112112
memory_total_bytes: mem_total,
113113
platform: platform().to_string(),
114114
storage_mode: CONFIG.get_storage_mode_string().to_string(),
115-
server_mode: CONFIG.parseable.mode,
115+
server_mode: CONFIG.options.mode,
116116
version: current().released_version.to_string(),
117117
commit_hash: current().commit_hash,
118118
active_ingestors: ingestor_metrics.0,
@@ -219,7 +219,7 @@ async fn fetch_ingestors_metrics(
219219
let mut vec = vec![];
220220
let mut active_ingestors = 0u64;
221221
let mut offline_ingestors = 0u64;
222-
if CONFIG.parseable.mode == Mode::Query {
222+
if CONFIG.options.mode == Mode::Query {
223223
// send analytics for ingest servers
224224

225225
// ingestor infos should be valid here, if not some thing is wrong

src/audit.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ impl AuditLogger {
4747
// Try to construct the log endpoint URL by joining the base URL
4848
// with the ingest path, This can fail if the URL is not valid,
4949
// when the base URL is not set or the ingest path is not valid
50-
let log_endpoint = match CONFIG
51-
.parseable
52-
.audit_logger
53-
.as_ref()?
54-
.join("/api/v1/ingest")
55-
{
50+
let log_endpoint = match CONFIG.options.audit_logger.as_ref()?.join("/api/v1/ingest") {
5651
Ok(url) => url,
5752
Err(err) => {
5853
eprintln!("Couldn't setup audit logger: {err}");
@@ -71,8 +66,8 @@ impl AuditLogger {
7166
.header("x-p-stream", "audit_log");
7267

7368
// Use basic auth if credentials are configured
74-
if let Some(username) = CONFIG.parseable.audit_username.as_ref() {
75-
req = req.basic_auth(username, CONFIG.parseable.audit_password.as_ref())
69+
if let Some(username) = CONFIG.options.audit_username.as_ref() {
70+
req = req.basic_auth(username, CONFIG.options.audit_password.as_ref())
7671
}
7772

7873
match req.send().await {

src/banner.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::{option::Config, storage::StorageMetadata};
2525

2626
pub async fn print(config: &Config, meta: &StorageMetadata) {
2727
print_ascii_art();
28-
let scheme = config.parseable.get_scheme();
28+
let scheme = config.options.get_scheme();
2929
status_info(config, &scheme, meta.deployment_id);
3030
storage_info(config).await;
3131
about::print(config, meta).await;
@@ -50,10 +50,10 @@ fn status_info(config: &Config, scheme: &str, id: Uid) {
5050
let address = format!(
5151
"\"{}://{}\" ({}), \":{}\" (livetail), \":{}\" (flight protocol)",
5252
scheme,
53-
config.parseable.address,
53+
config.options.address,
5454
scheme.to_ascii_uppercase(),
55-
config.parseable.grpc_port,
56-
config.parseable.flight_port
55+
config.options.grpc_port,
56+
config.options.flight_port
5757
);
5858

5959
let mut credentials =
@@ -63,7 +63,7 @@ fn status_info(config: &Config, scheme: &str, id: Uid) {
6363
credentials = "\"Using default creds admin, admin. Please set credentials with P_USERNAME and P_PASSWORD.\"".red().to_string();
6464
}
6565

66-
let llm_status = match &config.parseable.open_ai_key {
66+
let llm_status = match &config.options.open_ai_key {
6767
Some(_) => "OpenAI Configured".green(),
6868
None => "Not Configured".grey(),
6969
};
@@ -107,7 +107,7 @@ async fn storage_info(config: &Config) {
107107
config.staging_dir().to_string_lossy(),
108108
);
109109

110-
if let Some(path) = &config.parseable.hot_tier_storage_path {
110+
if let Some(path) = &config.options.hot_tier_storage_path {
111111
eprintln!(
112112
"\
113113
{:8}Hot Tier: \"Enabled, Path: {}\"",

src/catalog/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub async fn remove_manifest_from_snapshot(
335335
STREAM_INFO.set_first_event_at(stream_name, None)?;
336336
storage.put_snapshot(stream_name, meta.snapshot).await?;
337337
}
338-
match CONFIG.parseable.mode {
338+
match CONFIG.options.mode {
339339
Mode::All | Mode::Ingest => {
340340
Ok(get_first_event(storage.clone(), stream_name, Vec::new()).await?)
341341
}
@@ -349,7 +349,7 @@ pub async fn get_first_event(
349349
dates: Vec<String>,
350350
) -> Result<Option<String>, ObjectStorageError> {
351351
let mut first_event_at: String = String::default();
352-
match CONFIG.parseable.mode {
352+
match CONFIG.options.mode {
353353
Mode::All | Mode::Ingest => {
354354
// get current snapshot
355355
let stream_first_event = STREAM_INFO.get_first_event(stream_name)?;

0 commit comments

Comments
 (0)