当前位置:网站首页>Dapr 源码解析 | 项目总览
Dapr 源码解析 | 项目总览
2022-06-09 15:41:00 【风神修罗使】
本文源码选用 dapr 1.4.3 https://github.com/zcong1993/dapr-1/tree/learn-1.4.3
Concepts

总体来看, dapr 可以分为这么几个概念:
Building blocks 构建块
dapr 向用户提供的 HTTP/gRPC API, 由一个或多个 component 组成.
例如: Secrets 模块对用户提供获取 secrets 的 API.
# 获取单个 secret
GET http://localhost:<daprPort>/v1.0/secrets/<secret-store-name>/<name>
# 批量获取
GET http://localhost:<daprPort>/v1.0/secrets/<secret-store-name>/bulk
Components 模块
dapr 抽象出来的用于构建块和应用的通用化模块.
例如: Secret Stores 组件对外提供 secret 读取服务.
type SecretStore interface {
// Init authenticates with the actual secret store and performs other init operation
Init(metadata Metadata) error
// GetSecret retrieves a secret using a key and returns a map of decrypted string/string values
GetSecret(req GetSecretRequest) (GetSecretResponse, error)
// BulkGetSecrets retrieves all secrets in the store and returns a map of decrypted string/string values
BulkGetSecret(req BulkGetSecretRequest) (BulkGetSecretResponse, error)
}
支持 Kubernetes, Hashicorp Vault, Azure KeyVault 等多种 provider.
Configuration
组织 dapr 运行需要的各种配置, 主要分为: 全局配置, 模块配置和运行时配置.
Observability 可观测性
dapr 可观测性模块, 对外提供 logging, metrics, tracing 等指标.
Security
dapr 安全相关, 例如: 服务间 mTLS 加密.
Services
dapr 项目对外提供的 cli app. 从项目入口 cmd 文件夹也可以看出:
cmd
├── daprd // 核心 runtime, 后续源码阅读重点
├── injector // k8s dapr sidecar 注入器
├── operator // k8s operator
├── placement // actor 相关
└── sentry // mTLS 相关
运行环境
dapr 支持两种运行方式, 分别是: 独立运行和 k8s 运行.
Self-hosted
此种模式下, daprd 会作为一个 sidecar 进程运行在你的每个 app 旁边, 你的 app 可以通过 HTTP/gRPC 与它交互. 配置文件会存储在本地. 运行时配置需要使用 flag 传递.
Kubernetes
在 k8s 中, daprd 会做为一个 sidecar 容器运行在你的 app pod 中, 并且这一切都是 dapr-sidecar-injector 和 dapr-operator 帮你自动完成的. 配置文件也是使用 k8s crd 的形式管理, 运行配置可以通过 k8s annonation 来配置.
边栏推荐
- 谷歌亮出AI“王牌”,生成超逼真图片,网友:OpenAIDALL-E要被碾压了?
- 《CSDN 涨粉攻略》11个涨粉方法,你学会了几个?
- ps怎么复制图层
- 70 DOM reading XML
- June training (day 05) - double pointer
- Wechat applet drawing canvas, drawing network pictures
- 64 interface appearance (window without border, irregular form, transparent form)
- 六月集训(第02天) —— 字符串
- May training (day 22) - orderly gathering
- 五月集训(第27天) —— 图
猜你喜欢

Aloudata创始人周卫林:以NoETL叩开数据平台变革之门

What is the difference between IPS screen and LED screen

ps怎么复制图层到另一个图

ps如何放大缩小图片

The aquatic industry digital B2B e-commerce platform realizes fine management and drives enterprise performance growth

618的省钱技术攻略 来啦 -体验场景 领取10元猫超卡!

MySQL advanced optimization 01 - 40000 word detailed database performance analysis tool (in-depth, comprehensive and detailed, for collection and standby)

My Lord, times have changed...

探索复杂系统高阶交互的奥秘 | 高阶网络读书会启动

wps如何取消隐藏的单元格工作表
随机推荐
Async await return value description
ps怎么复制图层到另一个图
618的省钱技术攻略 来啦 -体验场景 领取10元猫超卡!
What is the PS fill shortcut
期货在哪开户,找谁开安全可靠??
R语言广义线性模型函数GLM、glm函数构建逻辑回归模型(Logistic regression)、分析模型是否过离散(Overdispersion)、使用假设检验的方法来分析模型是否过度分散
LeetCode 6077. 巫师的总力量和
[error reporting] no module named 'pytest‘
微信小程序使用canvas绘图,并保存下载到本地。圆形头像,虚线网络图片
微信小程序保存视频到相册wx.saveVideoToPhotosAlbum()
LeetCode 327. 区间和的个数
What is the difference between IPS screen and LED screen
Basic usage of Hongmeng pageslider sliding component
defi存币生息理财dapp系统开发逻辑
直播预告 | 社交新纪元,共探元宇宙社交新体验
低代码分析盘点:银行业低代码应用需要规避两大误区
May training (day 27) - figure
The demand for data storage is increasingly diversified, and it is a general trend to divide and conquer
WPS how to unhide cell worksheets
wps如何取消隐藏的单元格工作表