-
Notifications
You must be signed in to change notification settings - Fork 66
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
storage: add traits and a memory implementation #86
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
do we need to present local/remote/external category concepts in code structure? if so do we need to move |
No, it's not necessary. We can provide some built-in implementations in As for cloud platforms, maybe we can consider adding a
|
ok, I'd like to implement s3 in |
@zojw I refactored the file layout a little bit. Specifically, I move storage traits to an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reset LGTM
|
||
/// An interface to upload an object. | ||
#[async_trait] | ||
pub trait StorageObjectUploader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this trait is more suitable laid in storage_object.rs
~~~?
ditto MemObjectUploader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But actually storage_object.rs
doesn't need this, it is the return type of a StorageBucket
method, so I think it should be considered as a part of StorageBucket
.
pub trait ObjectHandle {} | ||
pub use async_trait::async_trait; | ||
|
||
// TODO: use std::stream::Stream instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May we create an issue for it and note how to achieve it? TODO in comments can be always an issue in the project which is more actionable and comment-able.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make senses, here is the issue #91
Box::new(stream::iter(object_names)) | ||
} | ||
|
||
async fn upload_object(&self, name: &str) -> Box<dyn StorageObjectUploader> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we need to detect the state of the bucket that owned this object?
e.g. two people A and B
---- A: get bucket "bucket-test" that exists and hold MemBucket
to next usage
---- B: empty and delete "bucket-test"
---- A: try to upload object into "bucket-test" <=== should return an error, because the object can not download?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it depends. If we mimic file system behaviors on Linux, it is OK to use an opened but deleted directory/file. Once the directory is closed, all data is gone. But I think we should follow the practice of different object storages here.
Refactor storage interfaces as described in #80.
This PR also provides a memory storage implementation.
More tests may be added later.
Ref: #68