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

将数据源插件和目录类型解耦 #92

Open
IMBlues opened this issue Sep 28, 2021 · 1 comment
Open

将数据源插件和目录类型解耦 #92

IMBlues opened this issue Sep 28, 2021 · 1 comment
Assignees
Labels
Layer: api Api module related Priority: High Type: enhancement Enhancement for existing feature Type: proposal Proposal

Comments

@IMBlues
Copy link
Contributor

IMBlues commented Sep 28, 2021

当前我们可以创建不同的目录,不同的目录对应不同的数据集合,数据的命名空间(尤其是 username)是相互独立的,同时目录类型本身和同步方式是一一绑定的,这样会带来一些使用上的麻烦,所以我们希望能够针对二者做解耦

现状

image

存在几个内建的 category.type 直接对应同步方式(插件)

  • local
  • ldap
  • mad
  • custom

同时,为了兼容自定义插件的场景,临时增加了一种特殊的类型pluggable 作为过渡,当目录类型是 pluggable 时会尝试从 settings 中获取对应的插件类型。

def get_plugin_by_category(category: "ProfileCategory") -> "DataSourcePlugin":
    """通过 category 类型获取插件名"""
    if category.type == CategoryType.PLUGGABLE.value:
        plugin_name = ConfigProvider(category.id)[PLUGIN_NAME_SETTING_KEY]
        return get_plugin_by_name(plugin_name)

    for n, p in _global_plugins.items():
        if p.category_type == category.type:
            return p
    raise ValueError(f"Plugin with category type: {category.type} does not exist")

同时也会带来一些问题:

  • 同一种类型的目录只能同步一种数据类型。当系统已经在公司内铺开使用后,各个体系产品都已经存储了默认目录的用户名,如果要修改目录的默认属性,会带来巨量的数据一致性挑战。
  • 当我们做多租户改造时,目录将转换成租户组的概念,隔离属性将被复用,但是数据源绑定属性则不应该放在租户组中。

改造

所以我们需要将二者完全解耦。达到的效果就是:

  • 同一个目录(租户组)可以添加多种数据源同步插件,可以同步多种数据源
  • 数据源插件之间的数据不再具有隔离性,将共享命名空间
  • 每一个数据本身将添加一个“数据源标记”,例如,用户在登录时,将通过这个标记找寻到对应的插件登录逻辑,进而统一蓝鲸登录插件和用户管理数据源插件

image

数据迁移

为了保证整体的平滑,我们将已有数据转换概念,一次性升级

image

@IMBlues IMBlues added Type: proposal Proposal Layer: api Api module related labels Sep 28, 2021
@wklken wklken added Type: enhancement Enhancement for existing feature Priority: High labels Nov 14, 2022
@wklken wklken self-assigned this Jan 12, 2023
@wklken
Copy link
Collaborator

wklken commented Jan 12, 2023

@nannan00 多租户需关注

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: api Api module related Priority: High Type: enhancement Enhancement for existing feature Type: proposal Proposal
Projects
None yet
Development

No branches or pull requests

3 participants