「连载」边缘计算(九)01-26:边缘部分源码(源码分析篇)

(接上篇)

Cloudcore码入口

Cloudcore源码入口为KubeEdge/cloud/CloudCore/CloudCore.go。

CloudCore 源码入口函数具体如下所示。

func main() {

command := app.NewCloudCoreCommand() //此函数是对cobra调用的封装

...

}

进入app.NewCloudCoreCommand()函数内部,也就是KubeEdge/cloud/CloudCore/app/server.go中的NewCloudCoreCommand()函数中。

NewCloudCoreCommand()函数定义具体如下所示。

func NewCloudCoreCommand() *cobra.Command {

...

cmd := &cobra.Command{

...

Run: func(cmd *cobra.Command, args []string) {

...

registerModules() //注册CloudCore中的功能模块

    // start all modules

    core.Run() //启动已注册的CloudCore中的功能模块

},

}

 ...

}

NewCloudCoreCommand()函数中,通过registerModules()函数注册CloudCore中的功能模块,通过core.Run()函数启动已注册的CloudCore中的功能模块。至于registerModules()函数注册了哪些功能模块,core.Run()函数怎么启动已注册功能模块的,详见《深入理解边缘计算:云、边、端工作原理与源码分析》8.2.3节。

注意:KubeEdge/cloud/admission/admission.go,KubeEdge/cloud/csidriver/csidriver.go两个入口,目前还没有用到,暂不分析。

EdgeCore码入口

EdgeCore源码入口为KubeEdge/edge/cmd/EdgeCore/EdgeCore.go。

EdgeCore源码入口函数具体如下所示。

func main() {

command := app.NewEdgeCoreCommand()//此函数是对cobra调用的封装

...

}

进入app.NewEdgeCoreCommand()函数内部,也就是KubeEdge/edge/cmd/EdgeCore/app/server.go中的NewEdgeCoreCommand()函数中。

NewEdgeCoreCommand()函数定义具体如下所示。

func NewEdgeCoreCommand() *cobra.Command {

...

cmd := &cobra.Command{

...

Run: func(cmd *cobra.Command, args []string) {

...

registerModules() //注册CloudCore中的功能模块

    // start all modules

    core.Run() //启动已注册的CloudCore中的功能模块

},

  }

  ...

}

NewEdgeCoreCommand()函数中,通过 registerModules()函数注册EdgeCore中的功能模块,通过core.Run()函数启动已注册的EdgeCore中的功能模块。至于registerModules()函数注册了哪些功能模块,core.Run()函数怎么启动已注册功能模块的,详见《深入理解边缘计算:云、边、端工作原理与源码分析》8.2.3节。

edgemesh码入口

edgemesh源码入口为KubeEdge/edgemesh/cmd/edgemesh.go。

edgemesh源码入口函数具体如下所示。

func main() {

...

pkg.Register() //注册edgemesh的功能模块

//Start server

server.StartTCP() //启动一个tcp服务

}

从main()函数中可以看到,edgemesh没有使用cobra,而是直接注册功能模块,然后启动了一个TCP服务。

 edgesite码入口

edgesite源码入口为KubeEdge/edgesite/cmd/edgesite.go。

edgesite源码入口函数具体如下所示。

func NewEdgeSiteCommand() *cobra.Command {

...

cmd := &cobra.Command{

...

Run: func(cmd *cobra.Command, args []string) {

...

registerModules() //注册CloudCore中的功能模块

    // start all modules

    core.Run() //启动已注册的CloudCore中的功能模块

},

  }

  ...

}

NewEdgeSiteCommand()函数中,通过 registerModules()函数注册edgesite中的功能模块,通过core.Run()函数启动已注册的EdgeCore中的功能模。至于registerModules()函数注册了哪些功能模块,core.Run()函数怎么启动已注册功能模块的,详见《深入理解边缘计算:云、边、端工作原理与源码分析》8.2.节。

至此,组件(CloudCoreEdgeCore、edge_mesh和edge_site)层面的源码共用框架和功能分析就结束了。下面深入分析各组件中功能模块的共用框架和功能。

 「未完待续……

点击下方标题可阅读技术文章

「连载」边缘计算(一)01-16:边缘计算系统逻辑架构(原理篇)
「连载」边缘计算(二)01-17:边缘计算系统逻辑架构(原理篇)
「连载」边缘计算(三)01-18:边缘部分原理解析(原理篇)
「连载」边缘计算(四)01-19:边缘部分原理解析(原理篇)
「连载」边缘计算(五)01-22:边缘部分原理解析(原理篇)
「连载」边缘计算(六)01-23:边缘部分原理解析(原理篇)
「连载」边缘计算(七)01-24:边缘部分原理解析(原理篇)
「连载」边缘计算(八)01-25:边缘部分源码(源码分析篇)



 

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-30 18:16:05       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-30 18:16:05       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-30 18:16:05       87 阅读
  4. Python语言-面向对象

    2024-01-30 18:16:05       96 阅读

热门阅读

  1. 抽象工厂模式深度理解,以及举例说明

    2024-01-30 18:16:05       46 阅读
  2. 网络安全攻防红队常用命令

    2024-01-30 18:16:05       42 阅读
  3. 华纳云:SQL Server中offset使用报错怎么解决

    2024-01-30 18:16:05       50 阅读
  4. treeview

    treeview

    2024-01-30 18:16:05      41 阅读
  5. redis 高可用

    2024-01-30 18:16:05       52 阅读
  6. Stream流

    Stream流

    2024-01-30 18:16:05      50 阅读
  7. Ubuntu20.04使用QT安装工具安装QT开发环境

    2024-01-30 18:16:05       76 阅读