「连载」边缘计算(二十三)02-28:边缘部分源码(源码分析篇)

(接上篇)

EdgeCore edgehub

前面对EdgeCore组件的edged、devicetwin功能模块进行了分析,本节对EdgeCore组件的另一个功能模块edgehub进行剖析。 edgehub作为edge部分与cloud部分进行交互的门户,我们有必要将edgehub相关内容彻底分析清楚,为使用过程中的故障排查和未来的功能扩展与性能优化提供便利。edgehub的剖析具体包括edgehub的struct调用链剖析、edgehub的具体逻辑剖析。

edgehub 的struct组成剖析

EdgeCore模块注册函数具体如下所示。

|-----------------------------------------------------------------------------------------------------------------------|
| KubeEdge/edge/cmd/EdgeCore/app/server.go |
| // registerModules register all the modules started in EdgeCore func registerModules() { ... edgehub.Register() ... } |

registerModules()函数中的edgehub.Register()具体如下所示。

|------------------------------------------------------------------------------------------------------------------|
| KubeEdge/edge/pkg/edgehub/module.go |
| // Register register edgehub func Register() { core.Register(&EdgeHub{ controller: NewEdgeHubController(), }) } |

顺着Register()函数中EdgeHub struct的实例化语句进入EdgeHub struct定义,具体如下所示。

|----------------------------------------------------------------------------------------------------------------------|
| KubeEdge/edge/pkg/edgehub/module.go |
| //EdgeHub defines edgehub object structure type EdgeHub struct { context *context.Context controller *Controller } |

EdgeHub struct中包含*context.Context和*Controller 两个属性。

1) *context.Context: 在《深入理解边缘计算:云、边、端工作原理与源码分析》8.3.2中,笔者已经分析过*context.Context,它是一个基于go-channels的消息框架,EdgeCore用它作为各功能模块之间通信的消息管道。

2)*Controller:edgehub的主要功能载体。

Controller struct的定义具体如下所示。

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| KubeEdge/edge/pkg/edgehub/controller.go |
| //Controller is EdgeHub controller object type Controller struct { context *context.Context chClient clients.Adapter config *config.ControllerConfig stopChan chan struct{} syncKeeper map[string]chan model.Message keeperLock sync.RWMutex } |

从Controller struct的定义可以确定,Controller struct是edgehub核心功能载体没错了。

到此,edgehub的struct组成剖析就结束了。接下来剖析edgehub的具体逻辑。

edgehub 的具体逻辑剖析

回到edgehub的注册函数,开始剖析edgehub相关的逻辑,具体如下所示。

|------------------------------------------------------------------------------------------------------------------|
| KubeEdge/edge/pkg/edgehub/module.go |
| // Register register edgehub func Register() { core.Register(&EdgeHub{ controller: NewEdgeHubController(), }) } |

未完待续......

相关推荐
小毅&Nora17 小时前
【后端】【工具】从 “Vibe PPT“ 到 “蕉幻“:一个原生 AI PPT 生成应用的深度解析
人工智能·powerpoint
ekprada17 小时前
Day 42 深度学习可解释性:Grad-CAM 与 Hook 机制
人工智能·机器学习
nwsuaf_huasir17 小时前
深度学习雷达信号参数估计
人工智能·深度学习
永霖光电_UVLED17 小时前
Navitas 与 Cyient 达成合作伙伴关系,旨在推动氮化镓(GaN)技术在印度的普及
大数据·人工智能·生成对抗网络
视觉光源老郑17 小时前
推荐一些机器视觉检测光源的优秀品牌
人工智能·计算机视觉·视觉检测
serve the people17 小时前
AI 模型识别 Nginx 流量中爬虫机器人的防御机制
人工智能·爬虫·nginx
PS12323217 小时前
桥梁与隧道安全守护者 抗冰冻型风速监测方案
大数据·人工智能
九鼎创展科技17 小时前
「有温度的陪伴」:基于全志 V821 的情感共鸣型实体机器人详解
linux·人工智能·嵌入式硬件·机器人
白熊18817 小时前
【论文精读】Transformer: Attention Is All You Need 注意力机制就是一切
人工智能·深度学习·transformer
CES_Asia17 小时前
资本赋能实体智能——2026 CES Asia机器人产业投资峰会定档北京
大数据·人工智能·microsoft·机器人