-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] OSS api design #98
Comments
@alpha-baby hi buddy, any comments? |
我也认为dapr那个bindings API不是一个很好理解的东西,可能还是我太菜理解不了这么抽象的东西(🐶)。
我认同这个观点,我觉得dapr也很难去推动修改API。 方案2我觉得在oss这种场景中是完全可行的。但是方案2这个API是不是足够通用我就不能给太多建议了(经验不够) |
// Get file with stream.
rpc GetFile(GetFileRequest) returns (stream GetFileResponse) {}
// Put file with stream.
rpc PutFile(stream PutFileRequest) returns (PutFileResponse) {} 这样是不是好一点呀 |
同意,好像get入参用不到stream 另外传参加下store_name吧? |
In addition to |
GetFileRequest
GetFileResponse
PutFileRequest
PutFileResponse 这几个对象里面的字段看目前的设计是比较少的,估计这里不太行。 |
good!! |
Yes, it's a mistake, but for PutFile interface, i think return empty is ok. |
I think we can follow asw s3 protocol: The Common operations in the protocol as below: Create a bucket – Create and name your own bucket in which to store your objects. Write an object – Store data by creating or overwriting an object. When you write an object, you specify a unique key in the namespace of your bucket. This is also a good time to specify any access control you want on the object. Read an object – Read data back. You can download the data via HTTP. Delete an object – Delete some of your data. List keys – List the keys contained in one of your buckets. You can filter the key list based on a prefix. By the way, In myopinion Create a bucket, Delete an object ,List keys It is more appropriate to put it in the outbinding, |
Add CRUD operation for file(OSS), If users want to customize their own operations, they can consider putting it in binding later. |
This issue has been automatically marked as stale because it has not had recent activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue or help wanted) or other activity occurs. Thank you for your contributions. |
可以适配支持一下 minio https://github.com/minio/minio ,S3 的接口 |
哦,已经看到代码库有 minio 的相关代码了。 |
https://github.com/mosn/layotto/blob/main/docs/en/api_reference/api_reference_v1.md#spec.proto.runtime.v1.ListFileRequest |
现在两个问题:
minio也支持分页 有个maxKeys 个人觉得可以加个分页字段,毕竟就连linux都可以 |
对于list的返回值,目前是个文件名列表,需要增加一下文件信息吗?看了一下common的有下面几个字段:
|
@wenxuwan 还有一个查询文件元信息或者探测文件是否存在的接口,也需要看看 https://help.aliyun.com/document_detail/31984.htm?spm=a2c4g.11186623.0.0.77af5d7aqqsyje#reference-bgh-cbw-wdb 否则目前判断文件是否存在,必须是一个 get stream ,抛异常才能知道是否存在,开发者使用体验比较差的。我以 js 举例你看看。 // throw error
await assert.rejects(
async () => {
const filepath = join(tmpfileDir, name);
const stream = await client.file.get({
storeName,
name,
});
await pipeline(
stream,
createWriteStream(filepath),
);
},
(err: any) => {
// console.error(err);
assert.equal(err.code, 13);
assert.match(err.message, /StatusCode=404, ErrorCode=NoSuchKey/);
return true;
}
); |
嗯,这个有在设计的最近,接口已经定义了,可以一起看下
|
本期将对接口和实现进行以下变动:
上述改动对于已经使用的GET,PUT,DEL接口没有影响。 |
@wenxuwan 赞,期待 pr 。 |
是不是没有必要单独增加一个 FileExists 接口,用 GetFileMeta 就可以了,比如 GetFileMeta 一个不存在的 Object,只需要返回错误码 |
嗯,可以复用一个,错误码的话,grpc自带的错误码应该可以覆盖到文件操作。对于一些特殊的错误码的话目前还没做定义,像dapr一样,都是直接返回interfanal error,然后在message里面增加错误信息。 |
是的,grpc 里的错误码暂时是够用的,我们尽量不返回 internal error,真出了 unexpected 的异常才返回。 |
嗯,后面如果有common的错误码,再统一出来,目前先复用grpc的。 |
emmmm我在想干脆直接把AWS S3或者 POSIX API里面和文件系统相关的API 一一对应的移植过来,一方面省的自己推敲了(懒); 另一方面复用业界已有标准>>>>>自己重新发明标准 |
hdfs 要分页的话需要自己指定列出的数量,我们对其的实现也是每次列出目录下最多100个文件,这需要外部定义大小,在上面hdfs sdk里面有详细的介绍。 个人觉得S3标准和传统文件系统标准有区别的,但如果统一抽象成 所以如果考虑用beyondstorage的话,可以在rpc下面包一层就够了)没有东西是包一层解决不了的,如果不行,就加两层:) |
@bokket 是说自动生成一套接口?好神奇,在哪能看到啊求链接学习学习 |
刚看了下,Dapr binding API现在已经支持AWS S3和阿里云OSS了,可以看看能否直接复用,这样就不需要自己重新搞了 包括redis协议,感觉可以用在一些支持redis协议的缓存上 |
dapr的binding不支持stream,对于大文件根本没法玩的。文件接口肯定是stream存在的。binding的操作当时是想让他们支持stream,但没后文了,可以参考:dapr/dapr#3338 |
This issue has been automatically marked as stale because it has not had recent activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue or help wanted) or other activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue or help wanted. Thank you for your contributions. |
Dapr现状
dapr现在在bindings里面支持了aliyun OSS的实现,具体实现可以参照oss。
dapr的Binding的分为Input和Out前者就是个类似于sub的能力,收到事件,调用回调函数。后者就是对后端的组件进行一些CRUD操作,如下:
InvokeBinding是一个Unary的rpc调用,这对于OSS这种支持大文件需要流式传输的功能肯定是没法支持的。
方案
方案一:
增加InvokeService为stream的rpc调用:
先给Dapr提了个Issue来跟踪:
dapr/dapr#3338
方案二:
本身dapr的binding的概念就不是一个很好的抽象,感觉就是什么都可以做。但又不知道应该用来做哪些东西。对于OSS这种流式传输的,我们也可以在pb中单独抽象出一类接口:
The text was updated successfully, but these errors were encountered: