diff --git a/rocketmq-common/src/common/stats.rs b/rocketmq-common/src/common/stats.rs index e2a41676..78f3a7ad 100644 --- a/rocketmq-common/src/common/stats.rs +++ b/rocketmq-common/src/common/stats.rs @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +pub mod call_snapshot; pub mod moment_stats_item; pub mod stats_snapshot; diff --git a/rocketmq-common/src/common/stats/call_snapshot.rs b/rocketmq-common/src/common/stats/call_snapshot.rs new file mode 100644 index 00000000..44064a2d --- /dev/null +++ b/rocketmq-common/src/common/stats/call_snapshot.rs @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +#[derive(Debug, PartialEq, Copy, Clone)] +pub struct CallSnapshot { + timestamp: u64, + times: u64, + value: u64, +} + +impl CallSnapshot { + pub fn new(timestamp: u64, times: u64, value: u64) -> Self { + CallSnapshot { + timestamp, + times, + value, + } + } + + // Getter for timestamp + pub fn get_timestamp(&self) -> u64 { + self.timestamp + } + + // Getter for times + pub fn get_times(&self) -> u64 { + self.times + } + + // Getter for value + pub fn get_value(&self) -> u64 { + self.value + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn call_snapshot_initializes_correctly() { + let snapshot = CallSnapshot::new(100, 200, 300); + assert_eq!(snapshot.get_timestamp(), 100); + assert_eq!(snapshot.get_times(), 200); + assert_eq!(snapshot.get_value(), 300); + } +}