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