Skip to main content

common_function/
admin.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
15mod build_index_table;
16mod discard_unflushed_data;
17mod flush_compact_region;
18mod flush_compact_table;
19mod gc;
20mod migrate_region;
21#[cfg(feature = "enterprise")]
22mod purge_table;
23mod reconcile_catalog;
24mod reconcile_database;
25mod reconcile_table;
26
27use flush_compact_region::{CompactRegionFunction, FlushRegionFunction};
28use flush_compact_table::{CompactTableFunction, FlushTableFunction};
29use gc::{GcRegionsFunction, GcTableFunction};
30use migrate_region::MigrateRegionFunction;
31#[cfg(feature = "enterprise")]
32use purge_table::PurgeTableFunction;
33use reconcile_catalog::ReconcileCatalogFunction;
34use reconcile_database::ReconcileDatabaseFunction;
35use reconcile_table::ReconcileTableFunction;
36
37use crate::admin::build_index_table::BuildIndexFunction;
38use crate::admin::discard_unflushed_data::DiscardUnflushedDataFunction;
39use crate::flush_flow::FlushFlowFunction;
40use crate::function_registry::FunctionRegistry;
41
42/// Administration functions
43pub(crate) struct AdminFunction;
44
45impl AdminFunction {
46    /// Register all admin functions to [`FunctionRegistry`].
47    pub fn register(registry: &FunctionRegistry) {
48        registry.register(MigrateRegionFunction::factory());
49        registry.register(FlushRegionFunction::factory());
50        registry.register(CompactRegionFunction::factory());
51        registry.register(FlushTableFunction::factory());
52        registry.register(CompactTableFunction::factory());
53        registry.register(GcRegionsFunction::factory());
54        registry.register(GcTableFunction::factory());
55        registry.register(BuildIndexFunction::factory());
56        registry.register(FlushFlowFunction::factory());
57        registry.register(ReconcileCatalogFunction::factory());
58        registry.register(ReconcileDatabaseFunction::factory());
59        registry.register(ReconcileTableFunction::factory());
60    }
61
62    /// Register functions that must only be resolved by an ADMIN statement.
63    pub fn register_admin_only(registry: &FunctionRegistry) {
64        registry.register(DiscardUnflushedDataFunction::factory());
65        #[cfg(feature = "enterprise")]
66        registry.register(PurgeTableFunction::factory());
67    }
68}