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