|
12 | 12 | // See the License for the specific language governing permissions and |
13 | 13 | // limitations under the License. |
14 | 14 |
|
| 15 | +use std::collections::HashMap; |
| 16 | +use std::sync::Arc; |
| 17 | + |
| 18 | +use catalog::CatalogManagerRef; |
| 19 | +use catalog::information_schema::InformationSchemaTableFactoryRef; |
| 20 | +use common_error::ext::BoxedError; |
15 | 21 | #[cfg(feature = "enterprise")] |
16 | | -pub use ee::*; |
| 22 | +use common_meta::ddl_manager::TriggerDdlManagerRef; |
| 23 | +use common_meta::kv_backend::KvBackendRef; |
| 24 | +use flow::FrontendClient; |
17 | 25 | #[cfg(feature = "enterprise")] |
18 | | -use operator::statement::TriggerQuerierFactoryRef; |
| 26 | +use operator::statement::TriggerQuerierRef; |
19 | 27 |
|
20 | | -use crate::extension::common::InformationSchemaTableFactoriesRef; |
| 28 | +use crate::extension::common::{InformationSchemaTableFactories, TableFactoryContext}; |
21 | 29 |
|
22 | | -#[cfg(feature = "enterprise")] |
23 | | -mod ee { |
24 | | - use std::sync::Arc; |
25 | | - |
26 | | - use catalog::CatalogManagerRef; |
27 | | - use common_error::ext::BoxedError; |
28 | | - use common_meta::ddl_manager::TriggerDdlManagerRef; |
29 | | - use common_meta::kv_backend::KvBackendRef; |
30 | | - use flow::FrontendClient; |
31 | | - |
32 | | - #[async_trait::async_trait] |
33 | | - pub trait TriggerDdlManagerFactory: Send + Sync { |
34 | | - async fn create( |
35 | | - &self, |
36 | | - ctx: TriggerDdlManagerRequest, |
37 | | - ) -> Result<TriggerDdlManagerRef, BoxedError>; |
38 | | - } |
| 30 | +#[derive(Default)] |
| 31 | +pub struct Extension { |
| 32 | + #[cfg(feature = "enterprise")] |
| 33 | + pub trigger_ddl_manager: Option<TriggerDdlManagerRef>, |
| 34 | + #[cfg(feature = "enterprise")] |
| 35 | + pub trigger_querier: Option<TriggerQuerierRef>, |
| 36 | +} |
39 | 37 |
|
40 | | - pub type TriggerDdlManagerFactoryRef = Arc<dyn TriggerDdlManagerFactory>; |
| 38 | +/// Factory trait to create Extension instances. |
| 39 | +pub trait ExtensionFactory: InformationSchemaTableFactories + Send + Sync { |
| 40 | + fn create( |
| 41 | + &self, |
| 42 | + ctx: ExtensionContext, |
| 43 | + ) -> impl Future<Output = Result<Extension, BoxedError>> + Send; |
| 44 | +} |
41 | 45 |
|
42 | | - pub struct TriggerDdlManagerRequest { |
43 | | - pub kv_backend: KvBackendRef, |
44 | | - pub catalog_manager: CatalogManagerRef, |
45 | | - pub fe_client: Arc<FrontendClient>, |
| 46 | +pub struct ExtensionContext { |
| 47 | + pub kv_backend: KvBackendRef, |
| 48 | + pub catalog_manager: CatalogManagerRef, |
| 49 | + pub frontend_client: Arc<FrontendClient>, |
| 50 | +} |
| 51 | + |
| 52 | +pub struct DefaultExtensionFactory; |
| 53 | + |
| 54 | +#[async_trait::async_trait] |
| 55 | +impl InformationSchemaTableFactories for DefaultExtensionFactory { |
| 56 | + async fn create_factories( |
| 57 | + &self, |
| 58 | + _ctx: TableFactoryContext, |
| 59 | + ) -> Result<HashMap<String, InformationSchemaTableFactoryRef>, BoxedError> { |
| 60 | + Ok(HashMap::new()) |
46 | 61 | } |
47 | 62 | } |
48 | 63 |
|
49 | | -#[derive(Default)] |
50 | | -pub struct Extension { |
51 | | - pub info_schema_factories: Option<InformationSchemaTableFactoriesRef>, |
52 | | - #[cfg(feature = "enterprise")] |
53 | | - pub trigger_ddl_manager_factory: Option<TriggerDdlManagerFactoryRef>, |
54 | | - #[cfg(feature = "enterprise")] |
55 | | - pub trigger_querier_factory: Option<TriggerQuerierFactoryRef>, |
| 64 | +impl ExtensionFactory for DefaultExtensionFactory { |
| 65 | + async fn create(&self, _ctx: ExtensionContext) -> Result<Extension, BoxedError> { |
| 66 | + Ok(Extension::default()) |
| 67 | + } |
56 | 68 | } |
0 commit comments