Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: TIdent add a flag to indicate if the tenant should be encoded into key #15321

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/meta/app/src/background/job_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/background/task_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/meta/app/src/data_mask/data_mask_name_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions src/meta/app/src/data_mask/mask_policy_table_id_list_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// limitations under the License.

use crate::tenant_key::ident::TIdent;
use crate::tenant_key::raw::TIdentRaw;

pub type MaskPolicyTableIdListIdent = TIdent<Resource>;
pub type MaskPolicyTableIdListIdentRaw = TIdentRaw<Resource>;

pub use kvapi_impl::Resource;

Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/meta/app/src/principal/connection_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/meta/app/src/principal/network_policy_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/meta/app/src/principal/password_policy_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/meta/app/src/principal/role_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ pub type RoleIdentRaw = TIdentRaw<Resource>;

pub use kvapi_impl::Resource;

impl TIdent<Resource> {
impl RoleIdent {
pub fn role_name(&self) -> &str {
self.name()
}
}

impl TIdentRaw<Resource> {
impl RoleIdentRaw {
pub fn role_name(&self) -> &str {
self.name()
}
Expand All @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/meta/app/src/principal/udf_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ pub type UdfIdentRaw = TIdentRaw<Resource>;

pub use kvapi_impl::Resource;

impl TIdent<Resource> {
impl UdfIdent {
pub fn udf_name(&self) -> &str {
self.name()
}
}

impl TIdentRaw<Resource> {
impl UdfIdentRaw {
pub fn udf_name(&self) -> &str {
self.name()
}
Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/meta/app/src/principal/user_defined_file_format_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/meta/app/src/principal/user_setting_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/meta/app/src/principal/user_stage_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/schema/catalog_name_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/schema/database_id_history_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/schema/database_name_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/schema/index_name_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/schema/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/schema/table_lock_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/schema/virtual_column_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/share/share_consumer_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/share/share_end_point_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/share/share_name_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/meta/app/src/tenant/tenant_quota_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/meta/app/src/tenant_key/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ mod tests {

impl TenantResource for Foo {
const PREFIX: &'static str = "foo";
const HAS_TENANT: bool = true;
type ValueType = Infallible;
}

Expand All @@ -237,6 +238,7 @@ mod tests {

impl TenantResource for Foo {
const PREFIX: &'static str = "foo";
const HAS_TENANT: bool = true;
type ValueType = Infallible;
}

Expand Down
10 changes: 10 additions & 0 deletions src/meta/app/src/tenant_key/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<R: TenantResource>`](TIdent).
type ValueType: kvapi::Value;
}
Loading