1. go项目调研
1.1. google/go-cloud
https://github.com/google/go-cloud
blog:
https://go.dev/blog/go-cloud
tutorial:
https://gocloud.dev/tutorials/cli-uploader/
设计 review
以 blob storage API 为例,review 一下设计。
过程中参考了 设计文档
separates the concerns of provisioning infrastructure and using infrastructure
“关注点分离”的思想,分离“负责提供基础设施的运维人员” 和 “负责使用基础设施的开发人员”:
- The developer persona wants to write business logic that is agnostic of underlying cloud provider. Their focus is on making software correct for the requirements at hand.
- The operator persona wants to incorporate the business logic into the organization's policies and provision resources for the logic to run. Their focus is making software run predictably and reliably with the resources at hand.
开发人员使用可移植 API,而运维人员负责处理“不可移植”的部分。
Instead of adding large amounts of leaky complexity to the Go CDK, we expect the operator role to handle the management of non-portable platform-specific resources
这种思想对做跨平台产品很重要。详见设计文档 https://github.com/google/go-cloud/blob/master/internal/docs/design.md#developers-and-operators
一些例子:
比如不提供创建bucket 的接口
Note, as a design principle of the Go CDK, blob.Bucket does not support creating a bucket and instead focuses solely on interacting with it. This separates the concerns of provisioning infrastructure and using infrastructure.
理由是为了避免设计ACL ,避免设计权限相关的东西。因为 acl 在不同的云平台对应不同的模型,如果让 sdk 来适配这些复杂的安全模型,会导致复杂度爆炸。这个点很有意思,见 https://github.com/google/go-cloud/blob/master/internal/docs/design.md#developers-and-operators

比如,访问云服务的 acl 、密钥等信息由环境变量提供,这也是“把耦合基础设施的部分分离开、由 operator 来负责提供”的思想:

如何处理 Dapr API 遇到的 "metadata 破坏可移植性" 的问题
看起来没预留类似的 map 字段。
- 如何实现“按需编译”
// TODO - 其他 api 设计
1.2. beyondstorage/go-storage
跨平台存储 API
网友评论