apache / dubbo-admin

The ops and reference implementation for Apache Dubbo
https://dubbo.apache.org
Apache License 2.0
3.99k stars 2.17k forks source link

Admin 第一版迭代:console和控制面部分 #1177

Open chickenlj opened 1 year ago

chickenlj commented 1 year ago

参考分支:https://github.com/apache/dubbo-admin/tree/refactor-with-go-components-experimental

架构

所有资源启动,都统一到dubbo-admin run 一条命令,run 启动所有内容:

可以参考 kuma 引入 component 的概念,每一块内容作为一个 Component

// Component defines a process that will be run in the application
// Component should be designed in such a way that it can be stopped by stop channel and started again (for example when instance is reelected for a leader).
type Component interface {
    // Start blocks until the channel is closed or an error occurs.
    // The component will stop running when the channel is closed.
    Start(<-chan struct{}) error

    // NeedLeaderElection indicates if component should be run only by one instance of Control Plane even with many Control Plane replicas.
    NeedLeaderElection() bool
}

Runtime 用来管控所有 Component

type Manager interface {

    // Add registers a component, i.e. gRPC Server, HTTP server, reconciliation loop.
    Add(...Component) error

    // Start starts registered components and blocks until the Stop channel is closed.
    // Returns an error if there is an error starting any component.
    // If there are any GracefulComponent, it waits until all components are done.
    Start(<-chan struct{}) error
}

// Runtime represents initialized application state.
type Runtime interface {
    RuntimeInfo
    RuntimeContext
    component.Manager
}

type RuntimeInfo interface {
    GetInstanceId() string
    SetClusterId(clusterId string)
    GetClusterId() string
    GetStartTime() time.Time
}

type RuntimeContext interface {
    Config() kuma_cp.Config
    DataSourceLoader() datasource.Loader
    ResourceManager() core_manager.ResourceManager
}

推送机制内容统一

以下三部分组件,分别都包含 CRD、Controller、gRPC server,需要把 gRPC Server 部分统一起来。

ServiceMapping

CR 定义放到 deploy 推送机制与 security 合并 cmd 合并

RuleConfiguration

CR 定义放到 deploy 推送机制与 security 合并 cmd 合并

Authority

authority 的 cmd 参数,都沉淀到 admin.yml 配置文件中 authority 变为子命令,用法距举例 dubbo-admin rundubbo-admin authoritydubbo-admin console

sjmshsh commented 1 year ago

Maybe I can have a try.