diff --git a/src/meta/app/src/background/job_ident.rs b/src/meta/app/src/background/job_ident.rs index 5f351c6d702d3..d81d1ad2f6b98 100644 --- a/src/meta/app/src/background/job_ident.rs +++ b/src/meta/app/src/background/job_ident.rs @@ -31,6 +31,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_background_job"; const TYPE: &'static str = "BackgroundJobIdent"; + const HAS_TENANT: bool = true; type ValueType = BackgroundJobId; } diff --git a/src/meta/app/src/background/task_ident.rs b/src/meta/app/src/background/task_ident.rs index 9c8ccae55638f..33e63deaafda4 100644 --- a/src/meta/app/src/background/task_ident.rs +++ b/src/meta/app/src/background/task_ident.rs @@ -30,6 +30,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_background_task_by_name"; const TYPE: &'static str = "BackgroundTaskIdent"; + const HAS_TENANT: bool = true; type ValueType = BackgroundTaskInfo; } diff --git a/src/meta/app/src/data_mask/data_mask_name_ident.rs b/src/meta/app/src/data_mask/data_mask_name_ident.rs index 5e139cc8d2bd5..f8cb0789ccc93 100644 --- a/src/meta/app/src/data_mask/data_mask_name_ident.rs +++ b/src/meta/app/src/data_mask/data_mask_name_ident.rs @@ -29,6 +29,8 @@ mod kvapi_impl { pub struct Resource; impl TenantResource for Resource { const PREFIX: &'static str = "__fd_datamask"; + const TYPE: &'static str = "DataMaskNameIdent"; + const HAS_TENANT: bool = true; type ValueType = DatamaskId; } diff --git a/src/meta/app/src/data_mask/mask_policy_table_id_list_ident.rs b/src/meta/app/src/data_mask/mask_policy_table_id_list_ident.rs index 180cfc1ec8a19..c873c0c66d1dd 100644 --- a/src/meta/app/src/data_mask/mask_policy_table_id_list_ident.rs +++ b/src/meta/app/src/data_mask/mask_policy_table_id_list_ident.rs @@ -13,8 +13,10 @@ // limitations under the License. use crate::tenant_key::ident::TIdent; +use crate::tenant_key::raw::TIdentRaw; pub type MaskPolicyTableIdListIdent = TIdent; +pub type MaskPolicyTableIdListIdentRaw = TIdentRaw; pub use kvapi_impl::Resource; @@ -28,6 +30,8 @@ mod kvapi_impl { pub struct Resource; impl TenantResource for Resource { const PREFIX: &'static str = "__fd_datamask_id_list"; + const TYPE: &'static str = "MaskPolicyTableIdListIdent"; + const HAS_TENANT: bool = true; type ValueType = MaskpolicyTableIdList; } diff --git a/src/meta/app/src/principal/connection_ident.rs b/src/meta/app/src/principal/connection_ident.rs index 315ec5d210e7e..cadfbfb5ce0c1 100644 --- a/src/meta/app/src/principal/connection_ident.rs +++ b/src/meta/app/src/principal/connection_ident.rs @@ -32,6 +32,8 @@ mod kvapi_impl { pub struct Resource; impl TenantResource for Resource { const PREFIX: &'static str = "__fd_connection"; + const TYPE: &'static str = "ConnectionIdent"; + const HAS_TENANT: bool = true; type ValueType = UserDefinedConnection; } diff --git a/src/meta/app/src/principal/network_policy_ident.rs b/src/meta/app/src/principal/network_policy_ident.rs index f6054c82589e4..0a7e801d7a73a 100644 --- a/src/meta/app/src/principal/network_policy_ident.rs +++ b/src/meta/app/src/principal/network_policy_ident.rs @@ -32,6 +32,8 @@ mod kvapi_impl { pub struct Resource; impl TenantResource for Resource { const PREFIX: &'static str = "__fd_network_policies"; + const TYPE: &'static str = "NetworkPolicyIdent"; + const HAS_TENANT: bool = true; type ValueType = NetworkPolicy; } diff --git a/src/meta/app/src/principal/password_policy_ident.rs b/src/meta/app/src/principal/password_policy_ident.rs index ce44f501bd58b..7e31bd64c37e3 100644 --- a/src/meta/app/src/principal/password_policy_ident.rs +++ b/src/meta/app/src/principal/password_policy_ident.rs @@ -33,6 +33,8 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_password_policies"; + const TYPE: &'static str = "PasswordPolicyIdent"; + const HAS_TENANT: bool = true; type ValueType = PasswordPolicy; } diff --git a/src/meta/app/src/principal/role_ident.rs b/src/meta/app/src/principal/role_ident.rs index c035c605ddb5d..71adb342ecc1a 100644 --- a/src/meta/app/src/principal/role_ident.rs +++ b/src/meta/app/src/principal/role_ident.rs @@ -22,13 +22,13 @@ pub type RoleIdentRaw = TIdentRaw; pub use kvapi_impl::Resource; -impl TIdent { +impl RoleIdent { pub fn role_name(&self) -> &str { self.name() } } -impl TIdentRaw { +impl RoleIdentRaw { pub fn role_name(&self) -> &str { self.name() } @@ -45,6 +45,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_roles"; const TYPE: &'static str = "RoleIdent"; + const HAS_TENANT: bool = true; type ValueType = RoleInfo; } diff --git a/src/meta/app/src/principal/udf_ident.rs b/src/meta/app/src/principal/udf_ident.rs index 342cc4ab08cc3..785ef6142e64c 100644 --- a/src/meta/app/src/principal/udf_ident.rs +++ b/src/meta/app/src/principal/udf_ident.rs @@ -22,13 +22,13 @@ pub type UdfIdentRaw = TIdentRaw; pub use kvapi_impl::Resource; -impl TIdent { +impl UdfIdent { pub fn udf_name(&self) -> &str { self.name() } } -impl TIdentRaw { +impl UdfIdentRaw { pub fn udf_name(&self) -> &str { self.name() } @@ -45,6 +45,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_udfs"; const TYPE: &'static str = "UdfIdent"; + const HAS_TENANT: bool = true; type ValueType = UserDefinedFunction; } diff --git a/src/meta/app/src/principal/user_defined_file_format_ident.rs b/src/meta/app/src/principal/user_defined_file_format_ident.rs index 2958da84a08c1..b9637644a78db 100644 --- a/src/meta/app/src/principal/user_defined_file_format_ident.rs +++ b/src/meta/app/src/principal/user_defined_file_format_ident.rs @@ -32,6 +32,8 @@ mod kvapi_impl { pub struct Resource; impl TenantResource for Resource { const PREFIX: &'static str = "__fd_file_formats"; + const TYPE: &'static str = "UserDefinedFileFormatIdent"; + const HAS_TENANT: bool = true; type ValueType = UserDefinedFileFormat; } diff --git a/src/meta/app/src/principal/user_setting_ident.rs b/src/meta/app/src/principal/user_setting_ident.rs index 78553bcb6df39..af2520bf0e9ef 100644 --- a/src/meta/app/src/principal/user_setting_ident.rs +++ b/src/meta/app/src/principal/user_setting_ident.rs @@ -29,6 +29,8 @@ mod kvapi_impl { pub struct Resource; impl TenantResource for Resource { const PREFIX: &'static str = "__fd_settings"; + const TYPE: &'static str = "SettingIdent"; + const HAS_TENANT: bool = true; type ValueType = UserSetting; } diff --git a/src/meta/app/src/principal/user_stage_ident.rs b/src/meta/app/src/principal/user_stage_ident.rs index 5e5abdf79de65..df70c8bbbb86c 100644 --- a/src/meta/app/src/principal/user_stage_ident.rs +++ b/src/meta/app/src/principal/user_stage_ident.rs @@ -29,6 +29,8 @@ mod kvapi_impl { pub struct Resource; impl TenantResource for Resource { const PREFIX: &'static str = "__fd_stages"; + const TYPE: &'static str = "StageIdent"; + const HAS_TENANT: bool = true; type ValueType = StageInfo; } diff --git a/src/meta/app/src/schema/catalog_name_ident.rs b/src/meta/app/src/schema/catalog_name_ident.rs index 158bd68141a29..302c730681aa6 100644 --- a/src/meta/app/src/schema/catalog_name_ident.rs +++ b/src/meta/app/src/schema/catalog_name_ident.rs @@ -35,6 +35,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_catalog"; const TYPE: &'static str = "CatalogNameIdent"; + const HAS_TENANT: bool = true; type ValueType = CatalogId; } diff --git a/src/meta/app/src/schema/database_id_history_ident.rs b/src/meta/app/src/schema/database_id_history_ident.rs index cc298d9bf9856..0d129baf6f294 100644 --- a/src/meta/app/src/schema/database_id_history_ident.rs +++ b/src/meta/app/src/schema/database_id_history_ident.rs @@ -47,6 +47,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_db_id_list"; const TYPE: &'static str = "DatabaseIdHistoryIdent"; + const HAS_TENANT: bool = true; type ValueType = DbIdList; } diff --git a/src/meta/app/src/schema/database_name_ident.rs b/src/meta/app/src/schema/database_name_ident.rs index e5d26992d40ef..86b49cb872366 100644 --- a/src/meta/app/src/schema/database_name_ident.rs +++ b/src/meta/app/src/schema/database_name_ident.rs @@ -44,6 +44,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_database"; const TYPE: &'static str = "DatabaseNameIdent"; + const HAS_TENANT: bool = true; type ValueType = DatabaseId; } diff --git a/src/meta/app/src/schema/index_name_ident.rs b/src/meta/app/src/schema/index_name_ident.rs index 5bcf7578762ab..4ffe208162000 100644 --- a/src/meta/app/src/schema/index_name_ident.rs +++ b/src/meta/app/src/schema/index_name_ident.rs @@ -47,6 +47,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_index"; const TYPE: &'static str = "IndexNameIdent"; + const HAS_TENANT: bool = true; type ValueType = IndexId; } diff --git a/src/meta/app/src/schema/sequence.rs b/src/meta/app/src/schema/sequence.rs index 39670f4dcaf36..4ac7c6c3ed130 100644 --- a/src/meta/app/src/schema/sequence.rs +++ b/src/meta/app/src/schema/sequence.rs @@ -102,6 +102,7 @@ mod kvapi_impl { pub struct Resource; impl TenantResource for Resource { const PREFIX: &'static str = "__fd_sequence"; + const HAS_TENANT: bool = true; type ValueType = SequenceMeta; } diff --git a/src/meta/app/src/schema/table_lock_ident.rs b/src/meta/app/src/schema/table_lock_ident.rs index 8318c9fba05bd..476062132da68 100644 --- a/src/meta/app/src/schema/table_lock_ident.rs +++ b/src/meta/app/src/schema/table_lock_ident.rs @@ -70,6 +70,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_table_lock"; const TYPE: &'static str = "TableLockIdent"; + const HAS_TENANT: bool = true; type ValueType = LockMeta; } diff --git a/src/meta/app/src/schema/virtual_column_ident.rs b/src/meta/app/src/schema/virtual_column_ident.rs index 673577e4270be..f3d1dae1d7dc8 100644 --- a/src/meta/app/src/schema/virtual_column_ident.rs +++ b/src/meta/app/src/schema/virtual_column_ident.rs @@ -45,6 +45,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_virtual_column"; const TYPE: &'static str = "VirtualColumnIdent"; + const HAS_TENANT: bool = true; type ValueType = VirtualColumnMeta; } diff --git a/src/meta/app/src/share/share_consumer_ident.rs b/src/meta/app/src/share/share_consumer_ident.rs index d29c99af29dd3..743c0854aa623 100644 --- a/src/meta/app/src/share/share_consumer_ident.rs +++ b/src/meta/app/src/share/share_consumer_ident.rs @@ -46,6 +46,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_share_account_id"; const TYPE: &'static str = "ShareConsumerIdent"; + const HAS_TENANT: bool = true; type ValueType = ShareAccountMeta; } diff --git a/src/meta/app/src/share/share_end_point_ident.rs b/src/meta/app/src/share/share_end_point_ident.rs index 08f171c0418c5..8101684415ebb 100644 --- a/src/meta/app/src/share/share_end_point_ident.rs +++ b/src/meta/app/src/share/share_end_point_ident.rs @@ -45,6 +45,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_share_endpoint"; const TYPE: &'static str = "ShareEndpointIdent"; + const HAS_TENANT: bool = true; type ValueType = ShareEndpointId; } diff --git a/src/meta/app/src/share/share_name_ident.rs b/src/meta/app/src/share/share_name_ident.rs index e35edb3b5f49f..7c2458c8fbd8f 100644 --- a/src/meta/app/src/share/share_name_ident.rs +++ b/src/meta/app/src/share/share_name_ident.rs @@ -46,6 +46,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_share"; const TYPE: &'static str = "ShareNameIdent"; + const HAS_TENANT: bool = true; type ValueType = ShareId; } diff --git a/src/meta/app/src/tenant/tenant_quota_ident.rs b/src/meta/app/src/tenant/tenant_quota_ident.rs index d1309f656636a..7fdef97d6f43f 100644 --- a/src/meta/app/src/tenant/tenant_quota_ident.rs +++ b/src/meta/app/src/tenant/tenant_quota_ident.rs @@ -44,6 +44,7 @@ mod kvapi_impl { impl TenantResource for Resource { const PREFIX: &'static str = "__fd_quotas"; const TYPE: &'static str = "TenantQuotaIdent"; + const HAS_TENANT: bool = true; type ValueType = TenantQuota; } diff --git a/src/meta/app/src/tenant_key/ident.rs b/src/meta/app/src/tenant_key/ident.rs index 7e05eacb52a60..fdbcfe60c8b84 100644 --- a/src/meta/app/src/tenant_key/ident.rs +++ b/src/meta/app/src/tenant_key/ident.rs @@ -219,6 +219,7 @@ mod tests { impl TenantResource for Foo { const PREFIX: &'static str = "foo"; + const HAS_TENANT: bool = true; type ValueType = Infallible; } @@ -237,6 +238,7 @@ mod tests { impl TenantResource for Foo { const PREFIX: &'static str = "foo"; + const HAS_TENANT: bool = true; type ValueType = Infallible; } diff --git a/src/meta/app/src/tenant_key/resource.rs b/src/meta/app/src/tenant_key/resource.rs index f71d26a2b8420..cd7aafd13665f 100644 --- a/src/meta/app/src/tenant_key/resource.rs +++ b/src/meta/app/src/tenant_key/resource.rs @@ -35,6 +35,16 @@ pub trait TenantResource { /// ``` const TYPE: &'static str = ""; + /// Whether to encode tenant into the key, when encoding a key without key-space. + /// + /// There are two kinds of key before introducing key space: + /// 1. The key with tenant, such as `CatalogNameIdent(tenant, name)`. + /// 2. The key without tenant, such as `TableId(table_id:u64)`. + /// + /// Meta-service keys are implemented with [`TIdent`]. + /// [`TenantResource`] should be able to distinguish the two kinds of keys. + const HAS_TENANT: bool; + /// The type of the value for the key [`TIdent`](TIdent). type ValueType: kvapi::Value; }