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