metric_engine/engine/
staging.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use common_base::AffectedRows;
16use snafu::ResultExt;
17use store_api::region_engine::RegionEngine;
18use store_api::region_request::RegionRequest;
19use store_api::storage::RegionId;
20
21use crate::engine::MetricEngine;
22use crate::error::{MitoEnterStagingOperationSnafu, Result};
23
24impl MetricEngine {
25    /// Handles the enter staging request for the given region.
26    pub(crate) async fn handle_enter_staging_request(
27        &self,
28        region_id: RegionId,
29        request: RegionRequest,
30    ) -> Result<AffectedRows> {
31        // We don't need to enter staging for metadata region.
32        // Callers should pass the data region id here; metadata regions stay unchanged.
33        self.inner
34            .mito
35            .handle_request(region_id, request)
36            .await
37            .context(MitoEnterStagingOperationSnafu)
38            .map(|response| response.affected_rows)
39    }
40}