-
Notifications
You must be signed in to change notification settings - Fork 88
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
replace file system with file builder #96
Conversation
@yiwu-arbug @Connor1996 @MrCroxx Could any of you help take a look at this while you have time? The |
GAT will be stable soon. I think it's okay to use it. |
path: &Path, | ||
reader: R, | ||
) -> Result<Self::Reader<R>, Box<dyn std::error::Error>> | ||
where |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
pub trait FileBuilder: Send + Sync { | ||
/// Types of outcome file reader/writer. They must not alter the length of | ||
/// bytes stream, nor buffer bytes between operations. | ||
type Reader<R: Seek + Read>: Seek + Read; |
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.
type Reader: Seek + Read
should be enough? Then all across the file builder should use Reader
.
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.
It is enough, but then we can't guarantee the implementor will actually use R
/W
from typing perspective. Though I'm not sure this is the idiomatic way to contracting such requirement.
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.
Also, I think it would be hard for implementor to wrap a generic R
/W
into a non-generic Reader
type.
Good to know! Reviews are still welcome. |
Signed-off-by: tabokie <xy.tao@outlook.com>
Signed-off-by: tabokie <xy.tao@outlook.com>
LGTM |
@@ -116,10 +59,7 @@ impl LogFd { | |||
} | |||
|
|||
pub fn sync(&self) -> IoResult<()> { | |||
let start = Instant::now(); | |||
let res = fsync(self.0).map_err(|e| from_nix_error(e, "fsync")); | |||
LOG_SYNC_TIME_HISTOGRAM.observe(start.saturating_elapsed().as_secs_f64()); |
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.
keep the metrics?
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.
They are actually moved out to file_pipe_log.rs.
Signed-off-by: tabokie xy.tao@outlook.com
Replace file system(#91) with an Allocator-like type
FileBuilder
.File builder is better, it's strongly typed with our own file writer/reader, so that 1) we don't need to propagate
Send
andSync
trait bound outside of this library, 2) user writers or readers are promised to use our writer/reader as a backend.There still are some reasonable requirements on user types, such as no buffering and no length altering, which are documented in trait definition.
Related: TiKV commit that implements a
FileBuilder
for encryption and rate limiting.