-
Notifications
You must be signed in to change notification settings - Fork 321
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
refactor tskv : Error passed up in async function #560
Conversation
bernie seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Thank You |
@roseboy-liu please make a review |
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 agree with your idea,but with some comments, please check.
tskv/src/kvcore.rs
Outdated
|
||
let summary = tokio::spawn(run_summary_job(summary, summary_task_receiver, summary_task_sender)); | ||
if let Err(e) = tokio::try_join!(wal, flush, compact, summary) { | ||
return Err(Error::Compact { reason: e.to_string()}) |
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.
add a new error code
tskv/src/kvcore.rs
Outdated
@@ -58,7 +59,7 @@ pub struct TsKv { | |||
} | |||
|
|||
impl TsKv { | |||
pub async fn open(opt: Options, ts_family_num: u32) -> Result<Self> { | |||
pub async fn open(opt: Options, ts_family_num: u32) -> Result<Self, Error> { |
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 has defined in error.rs mod 'pub type Result<T, E = Error> = std::result::Result<T, E>'
@@ -475,3 +379,86 @@ impl TsKv { | |||
Ok(None) | |||
} | |||
} | |||
|
|||
|
|||
async fn run_wal_job(wal_opt: Arc<WalConfig>, mut receiver: UnboundedReceiver<WalTask>) -> Result<()> { |
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.
If there is no refactoring, in place to modify
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.
change to function, remove &self
Errors inside the [run_wal_job,run_flush_job,run_compact_job,run_summary_job] functions are passed up
避免以上四个函数中的错误在内部消耗而外部不可知而向上传递,并将方法改为异步函数形式,另外项目Error设计不是很优雅