调研跨平台 sdk

1. go项目调研

1.1. google/go-cloud

repo:
https://github.com/google/go-cloud

blog:
https://go.dev/blog/go-cloud

tutorial:
https://gocloud.dev/tutorials/cli-uploader/

1.1.1. 设计 review: 以 blob storage API 为例

以 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

image.png

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


image.png
如何处理 Dapr API 遇到的 "metadata 破坏可移植性" 的问题

看起来没预留类似的 map 字段。

详细设计

上面说了那么多设计思想,那具体有哪些功能呢?

  • CRUD
    Blob · Go CDK (gocloud.dev)

  • Attributes
    blob package - gocloud.dev/blob - Go Packages

Attributes returns attributes for the blob stored at key.

  • Exists
    https://pkg.go.dev/gocloud.dev/blob#Bucket.Exists

  • SignedURL
    blob package - gocloud.dev/blob - Go Packages

  • IsAccessible
    blob package - gocloud.dev/blob - Go Packages

IsAccessible returns true if the bucket is accessible, false otherwise. It is a shortcut for calling ListPage and checking if it returns an error with code gcerrors.NotFound.

1.1.2. 设计 review: 其他 api

// TODO


image.png

1.1.3. 如何实现“按需编译”

// TODO

1.2. beyondstorage/go-storage

beyondstorage/go-storage: A vendor-neutral storage library for Golang: Write once, run on every storage service. (github.com)

跨平台存储 API

1.3. gofiber/storage

https://github.com/gofiber/storage

跨平台存储 API, 看起来只有 kv 模型

2. java 项目调研

2.1. Capa

2.2. Femas

你可能感兴趣的:(调研跨平台 sdk)