sentinel-group/sentinel-rust

DefaultMetricSearcher has not implemented the MetricSearcher trait

flearc opened this issue · 2 comments

The MetricSearcher trait defines methods' with a return type of Result<MetricItem>.

pub trait MetricSearcher {
    fn find_by_time_and_resource(
        begin_time_ms: u64,
        end_time_ms: u64,
        resource: &str,
    ) -> Result<MetricItem>;
    fn find_from_time_with_max_lines(begin_time_ms: u64, max_lines: u32) -> Result<MetricItem>;
}

However return type of DefaultMetricSearcher's similar methods is Result<MetricItemVec>.

pub fn find_by_time_and_resource(
        &self,
        begin_time_ms: u64,
        end_time_ms: u64,
        resource: String,
    ) -> Result<MetricItemVec> {
        ...
    }

    pub fn find_from_time_with_max_lines(
        &self,
        begin_time_ms: u64,
        max_lines: usize,
    ) -> Result<MetricItemVec> {
        ...
    }

DefaultMetricSearcher has not implemented the MetricSearcher trait. WHY?

Consider modifying the return type of the MetricSearcher trait methods to Result<MetricItemVec>, aligning with the return type of similar methods in DefaultMetricSearcher. Then let DefaultMetricSearcher implements MetricSearcher.

Your remark is right, it looks like a typo. This mod is not well tested. You can submit a PR if you'd like to fix it :)