(接上篇)
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.节。
至此,组件(CloudCore、EdgeCore、edge_mesh和edge_site)层面的源码共用框架和功能分析就结束了。下面深入分析各组件中功能模块的共用框架和功能。
「未完待续……」
点击下方标题可阅读技术文章
「连载」边缘计算(一)01-16:边缘计算系统逻辑架构(原理篇)
「连载」边缘计算(二)01-17:边缘计算系统逻辑架构(原理篇)
「连载」边缘计算(三)01-18:边缘部分原理解析(原理篇)
「连载」边缘计算(四)01-19:边缘部分原理解析(原理篇)
「连载」边缘计算(五)01-22:边缘部分原理解析(原理篇)
「连载」边缘计算(六)01-23:边缘部分原理解析(原理篇)
「连载」边缘计算(七)01-24:边缘部分原理解析(原理篇)
「连载」边缘计算(八)01-25:边缘部分源码(源码分析篇)