Skip to content

Commit 4058572

Browse files
hoophalabLinZhihao-723junhaoliao
authored
refactor(api-server): Rename timestamp and results cache parameters for clarity. (y-scope#1886)
Co-authored-by: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com> Co-authored-by: Junhao Liao <junhao.liao@yscope.com>
1 parent c1fe990 commit 4058572

4 files changed

Lines changed: 36 additions & 36 deletions

File tree

components/api-server/src/client.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,21 @@ pub struct QueryConfig {
3838

3939
/// The beginning timestamp (in epoch milliseconds) for the search range (inclusive).
4040
#[serde(default)]
41-
pub begin_timestamp: Option<i64>,
41+
pub time_range_begin_millisecs: Option<i64>,
4242

4343
/// The ending timestamp (in epoch milliseconds) for the search range (inclusive).
4444
#[serde(default)]
45-
pub end_timestamp: Option<i64>,
45+
pub time_range_end_millisecs: Option<i64>,
4646

4747
/// Whether the string match should be case-insensitive.
4848
#[serde(default)]
4949
pub ignore_case: bool,
5050

51-
/// Whether to write the search results to files. If `false`, results will be stored in
52-
/// `MongoDB`.
51+
/// Whether to buffer search results in `MongoDB`.
52+
/// By default, search results are buffered in temporary files. When set to `true`, results
53+
/// will be stored in `MongoDB` instead.
5354
#[serde(default)]
54-
pub write_to_file: bool,
55+
pub buffer_results_in_mongodb: bool,
5556
}
5657

5758
impl From<QueryConfig> for SearchJobConfig {
@@ -60,10 +61,10 @@ impl From<QueryConfig> for SearchJobConfig {
6061
dataset: value.dataset,
6162
query_string: value.query_string,
6263
max_num_results: value.max_num_results,
63-
begin_timestamp: value.begin_timestamp,
64-
end_timestamp: value.end_timestamp,
64+
begin_timestamp: value.time_range_begin_millisecs,
65+
end_timestamp: value.time_range_end_millisecs,
6566
ignore_case: value.ignore_case,
66-
write_to_file: value.write_to_file,
67+
write_to_file: !value.buffer_results_in_mongodb,
6768
..Default::default()
6869
}
6970
}

components/api-server/src/routes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ async fn health() -> String {
8585
example = json!({
8686
"query_string": "*",
8787
"dataset": "default",
88-
"begin_timestamp": 0,
89-
"end_timestamp": 17_356_896,
88+
"time_range_begin_millisecs": 0,
89+
"time_range_end_millisecs": 17_356_896,
9090
"ignore_case": true,
9191
"max_num_results": 0,
92-
"write_to_file": false
92+
"buffer_results_in_mongodb": true
9393
})),
9494
responses(
9595
(

docs/src/_static/generated/api-server-openapi.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
"example": {
4545
"query_string": "*",
4646
"dataset": "default",
47-
"begin_timestamp": 0,
48-
"end_timestamp": 17356896,
47+
"time_range_begin_millisecs": 0,
48+
"time_range_end_millisecs": 17356896,
4949
"ignore_case": true,
5050
"max_num_results": 0,
51-
"write_to_file": false
51+
"buffer_results_in_mongodb": true
5252
}
5353
}
5454
},
@@ -119,13 +119,9 @@
119119
"query_string"
120120
],
121121
"properties": {
122-
"begin_timestamp": {
123-
"type": [
124-
"integer",
125-
"null"
126-
],
127-
"format": "int64",
128-
"description": "The beginning timestamp (in epoch milliseconds) for the search range (inclusive)."
122+
"buffer_results_in_mongodb": {
123+
"type": "boolean",
124+
"description": "Whether to buffer search results in `MongoDB`.\nBy default, search results are buffered in temporary files. When set to `true`, results\nwill be stored in `MongoDB` instead."
129125
},
130126
"dataset": {
131127
"type": [
@@ -134,14 +130,6 @@
134130
],
135131
"description": "The dataset to search within. If not provided, only `default` dataset will be searched."
136132
},
137-
"end_timestamp": {
138-
"type": [
139-
"integer",
140-
"null"
141-
],
142-
"format": "int64",
143-
"description": "The ending timestamp (in epoch milliseconds) for the search range (inclusive)."
144-
},
145133
"ignore_case": {
146134
"type": "boolean",
147135
"description": "Whether the string match should be case-insensitive."
@@ -156,9 +144,21 @@
156144
"type": "string",
157145
"description": "The search query as a KQL string."
158146
},
159-
"write_to_file": {
160-
"type": "boolean",
161-
"description": "Whether to write the search results to files. If `false`, results will be stored in\n`MongoDB`."
147+
"time_range_begin_millisecs": {
148+
"type": [
149+
"integer",
150+
"null"
151+
],
152+
"format": "int64",
153+
"description": "The beginning timestamp (in epoch milliseconds) for the search range (inclusive)."
154+
},
155+
"time_range_end_millisecs": {
156+
"type": [
157+
"integer",
158+
"null"
159+
],
160+
"format": "int64",
161+
"description": "The ending timestamp (in epoch milliseconds) for the search range (inclusive)."
162162
}
163163
},
164164
"additionalProperties": false

docs/src/user-docs/guides-using-the-api-server.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ following commands to submit a query to clp-json and stream the results.
3535
"dataset": "default",
3636
"ignore_case": false,
3737
"max_num_results": 100,
38-
"write_to_file": false
3938
}'
4039
```
4140

@@ -57,11 +56,11 @@ following commands to submit a query to clp-json and stream the results.
5756
Example streamed output:
5857

5958
```text
60-
data: {"timestamp": 1633036800, "message": "Example log message"}
59+
data: {"timestamp": 1767225600000, "message": "Example log message"}
6160
62-
data: {"timestamp": 1633036810, "message": "Another matched log line"}
61+
data: {"timestamp": 1767225600010, "message": "Another matched log line"}
6362
64-
data: {"timestamp": 1633036820, "message": "No logs found" }
63+
data: {"timestamp": 1767225600020, "message": "No logs found" }
6564
```
6665

6766
[OpenAPI]: https://swagger.io/specification/

0 commit comments

Comments
 (0)