-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(meta): add event log service (#13392)
- Loading branch information
Showing
27 changed files
with
681 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/frontend/src/catalog/system_catalog/rw_catalog/rw_event_logs.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2023 RisingWave Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use itertools::Itertools; | ||
use risingwave_common::catalog::RW_CATALOG_SCHEMA_NAME; | ||
use risingwave_common::error::Result; | ||
use risingwave_common::row::OwnedRow; | ||
use risingwave_common::types::{DataType, ScalarImpl, Timestamptz}; | ||
use risingwave_pb::meta::event_log::Event; | ||
use serde_json::json; | ||
|
||
use crate::catalog::system_catalog::{BuiltinTable, SysCatalogReaderImpl}; | ||
|
||
pub const RW_EVENT_LOGS: BuiltinTable = BuiltinTable { | ||
name: "rw_event_logs", | ||
schema: RW_CATALOG_SCHEMA_NAME, | ||
columns: &[ | ||
(DataType::Varchar, "unique_id"), | ||
(DataType::Timestamptz, "timestamp"), | ||
(DataType::Varchar, "event_type"), | ||
(DataType::Jsonb, "info"), | ||
], | ||
pk: &[0], | ||
}; | ||
|
||
impl SysCatalogReaderImpl { | ||
pub async fn read_event_logs(&self) -> Result<Vec<OwnedRow>> { | ||
let configs = self | ||
.meta_client | ||
.list_event_log() | ||
.await? | ||
.into_iter() | ||
.sorted_by(|a, b| a.timestamp.cmp(&b.timestamp)) | ||
.map(|e| { | ||
let ts = Timestamptz::from_millis(e.timestamp.unwrap() as i64).unwrap(); | ||
let event_type = event_type(e.event.as_ref().unwrap()); | ||
OwnedRow::new(vec![ | ||
Some(ScalarImpl::Utf8(e.unique_id.to_owned().unwrap().into())), | ||
Some(ScalarImpl::Timestamptz(ts)), | ||
Some(ScalarImpl::Utf8(event_type.into())), | ||
Some(ScalarImpl::Jsonb(json!(e).into())), | ||
]) | ||
}) | ||
.collect_vec(); | ||
Ok(configs) | ||
} | ||
} | ||
|
||
fn event_type(e: &Event) -> String { | ||
match e { | ||
Event::CreateStreamJobFail(_) => "CREATE_STREAM_JOB_FAIL", | ||
Event::DirtyStreamJobClear(_) => "DIRTY_STREAM_JOB_CLEAR", | ||
Event::MetaNodeStart(_) => "META_NODE_START", | ||
} | ||
.into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2023 RisingWave Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use risingwave_meta::manager::event_log::EventLogMangerRef; | ||
use risingwave_pb::meta::event_log_service_server::EventLogService; | ||
use risingwave_pb::meta::{ListEventLogRequest, ListEventLogResponse}; | ||
use tonic::{Request, Response, Status}; | ||
|
||
pub struct EventLogServiceImpl { | ||
event_log_manager: EventLogMangerRef, | ||
} | ||
|
||
impl EventLogServiceImpl { | ||
pub fn new(event_log_manager: EventLogMangerRef) -> Self { | ||
Self { event_log_manager } | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl EventLogService for EventLogServiceImpl { | ||
async fn list_event_log( | ||
&self, | ||
_request: Request<ListEventLogRequest>, | ||
) -> Result<Response<ListEventLogResponse>, Status> { | ||
let event_logs = self.event_log_manager.list_event_logs(); | ||
Ok(Response::new(ListEventLogResponse { event_logs })) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.