-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
fang_tasks queries done #24
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.
tests please 👮
src/asynk/async_queue.rs
Outdated
.await | ||
} | ||
pub async fn remove_all_tasks(&mut self) -> Result<u64, AsyncQueueError> { | ||
self.execute_one(REMOVE_ALL_TASK_QUERY, &[]).await |
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.
this query may fail if the number of removed records is more than 1
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.
@ayrat555 i am sure that query will not fail because execute_one calls
https://docs.rs/tokio-postgres/0.7.0/tokio_postgres/struct.Client.html#method.execute
that do not panic! if two or n records are deleted, execute method will return as u64 2 or n, that is then number of rows affected.
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.
my comment was related to this check - https://github.com/ayrat555/fang/pull/24/files#diff-24272200c270b7446465f4378bfa6c16bd4a7f88837d283e84b24114d0ec3404L79
Merge branch commit was in order to resolve a conflict. |
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.
Great job 🚀
Added small comments
src/asynk/async_queue.rs
Outdated
assert_eq!(1, result); | ||
let result = queue.remove_tasks_type("common").await.unwrap(); | ||
assert_eq!(2, result); | ||
queue.transaction.unwrap().rollback().await.unwrap(); |
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 you don't need to roll back. it will be rolled back automatically when queue is dropped
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.
@ayrat555 It is true, you do not need to rollback explicitly but i think a rollback is an important operation that should be done explicitly, if you would to delete the explicit rollback, i will delete them.
@@ -76,13 +110,6 @@ where | |||
return Err(AsyncQueueError::PoolAndTransactionEmpty); | |||
}; | |||
|
|||
if result != 1 { |
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.
we can rename execute_one
into execute
and add additional parameter - expected_result_count: Option
if let Some(expected_result) = expected_result_count {
if result != expected_result {
return Err(AsyncQueueError::ResultError {
expected: expected_result,
found: 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.
@ayrat555 , Ok i will add this code, but we should call the function different because there is already an execute function Transaction::execute. Maybe will be better call it execute_test
because we are gonna to pass an expected_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.
I think it's fine to call it execute
. because we're adding the method to our own struct
but you can call it checked_execute
if you don't like just execute
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.
@ayrat555 is a problem to add this parameter to expected_result_count: Option to all functions ?
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's fine. but the code will be duplicated
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.
@ayrat555 if we change all tests and only call Checked execute in the tests we can avoid the duplicated code.
what do you think ??
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.
@ayrat555 why would you like this error in checked_execute ?
assert_eq! macro already gives the expected value and the value given.
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.
Fix clippy
, and the pr is good to merge
No description provided.