Skip to main content

common_meta/reconciliation/reconcile_table/
reconciliation_end.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_procedure::{Context as ProcedureContext, Status};
16use common_telemetry::info;
17use serde::{Deserialize, Serialize};
18use tonic::async_trait;
19
20use crate::error::Result;
21use crate::reconciliation::reconcile_table::{ReconcileTableContext, State};
22
23/// The state of the reconciliation end.
24/// This state is used to indicate that the reconciliation is done.
25#[derive(Debug, Serialize, Deserialize)]
26pub struct ReconciliationEnd;
27
28#[async_trait]
29#[typetag::serde]
30impl State for ReconciliationEnd {
31    async fn next(
32        &mut self,
33        ctx: &mut ReconcileTableContext,
34        procedure_ctx: &ProcedureContext,
35    ) -> Result<(Box<dyn State>, Status)> {
36        let table_id = ctx.table_id();
37        let table_name = ctx.table_name();
38        let metrics = ctx.metrics();
39
40        info!(
41            "Physical table reconciliation completed. table_name: {}, table_id: {}, procedure_id: {}, metrics: {}",
42            table_name, table_id, procedure_ctx.procedure_id, metrics
43        );
44
45        Ok((Box::new(ReconciliationEnd), Status::done()))
46    }
47}