Skip to main content

plugins/
flownode.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_base::Plugins;
16use flow::error::Result;
17use flow::{FlownodeBuilder, FlownodeInstance, FlownodeOptions};
18
19use crate::options::PluginOptions;
20
21/// Sets up flownode plugins before the [`FlownodeBuilder`] is constructed.
22#[allow(unused_mut, unused_variables)]
23pub async fn setup_flownode_plugins_pre_build(
24    plugins: &mut Plugins,
25    plugin_options: &[PluginOptions],
26    _fn_opts: &FlownodeOptions,
27) -> Result<()> {
28    Ok(())
29}
30
31/// Sets up flownode plugins after the [`FlownodeBuilder`] is constructed
32/// but before [`FlownodeBuilder::build()`].
33///
34/// Plugins can read context from the builder (e.g., opts, catalog_manager, flow_metadata_manager)
35/// and insert additional plugins. After this call, [`FlownodeBuilder::set_plugins()`]
36/// should be called to sync plugins into the builder.
37#[allow(unused_variables)]
38pub async fn setup_flownode_plugins_post_build(
39    plugins: &mut Plugins,
40    plugin_options: &[PluginOptions],
41    builder: &FlownodeBuilder,
42) -> Result<()> {
43    Ok(())
44}
45
46pub async fn start_flownode_plugins(_instance: &FlownodeInstance) -> Result<()> {
47    Ok(())
48}
49
50pub mod context {
51    use std::sync::Arc;
52
53    use catalog::CatalogManagerRef;
54    use common_meta::FlownodeId;
55    use common_meta::kv_backend::KvBackendRef;
56    use flow::FrontendClient;
57
58    /// The context for `GrpcBuilderConfiguratorRef` in flownode.
59    pub struct GrpcConfigureContext {
60        pub kv_backend: KvBackendRef,
61        pub fe_client: Arc<FrontendClient>,
62        pub flownode_id: FlownodeId,
63        pub catalog_manager: CatalogManagerRef,
64    }
65}