「连载」边缘计算(九)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:边缘部分源码(源码分析篇)



 

  • 24
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值