Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a stream init time field #590

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions server/src/handlers/http/logstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,16 @@ pub async fn get_stats(req: HttpRequest) -> Result<impl Responder, StreamError>

let time = Utc::now();

let stream_init_time = &CONFIG
.storage()
.get_object_store()
.get_whole_json(&stream_name)
.await
.unwrap()["created-at"];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have to get this from object store every time. There is an in-memory map maintained at Parseable server to avoid this exact same situation. Please use the map.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved it in the latest commit .... now the created at data is loaded from the file either on load or once the file is created

let stats = serde_json::json!({
"stream": stream_name,
"stream created at": stream_init_time,
"time": time,
"ingestion": {
"count": stats.events,
Expand Down
4 changes: 1 addition & 3 deletions server/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ impl StreamInfo {

pub fn add_stream(&self, stream_name: String) {
let mut map = self.write().expect(LOCK_EXPECT);
let metadata = LogStreamMetadata {
..Default::default()
};
let metadata = LogStreamMetadata::default();
map.insert(stream_name, metadata);
}

Expand Down
8 changes: 8 additions & 0 deletions server/src/storage/object_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ pub trait ObjectStorage: Sync + 'static {
Ok(stats)
}

async fn get_whole_json(&self, stream_name: &str) -> Result<Value, ObjectStorageError> {
let stream_metadata = self.get_object(&stream_json_path(stream_name)).await?;
let stream_metadata: Value =
serde_json::from_slice(&stream_metadata).expect("parseable config is valid json");

Ok(stream_metadata)
}

async fn get_retention(&self, stream_name: &str) -> Result<Retention, ObjectStorageError> {
let stream_metadata = self.get_object(&stream_json_path(stream_name)).await?;
let stream_metadata: Value =
Expand Down
Loading