-
Notifications
You must be signed in to change notification settings - Fork 134
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
Add sync API for raw client #301
base: master
Are you sure you want to change the base?
Conversation
dfe2d54
to
d9bfd5c
Compare
Thanks! I'm wondering if it is better to have a separate sync RawClient, instead of mixing sync and async API in the same struct. How do you like it? Also, could you please add appropriate example(s) in the README and/or under the example directory? It would best help the new users who are the expected users of sync API. |
I think it will be like a SyncRawClient which wraps the RawClient insides. And sure, I will add some examples into README doc. |
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.
Thanks! I have a few suggestions. And please fix the errors according to CI results.
Tips: make check
and make unit-test
can be helpful in your local environment.
src/raw/client.rs
Outdated
} | ||
|
||
impl SyncClient { | ||
/// The Sync version of Client |
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.
The comments should be moved to the definition of the structure.
/// The Sync version of Client | |
/// The synchronous version of RawClient |
src/raw/client.rs
Outdated
} | ||
|
||
|
||
fn assert_non_atomic(&self) -> 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 the sync client doesn't have to implement these assert_ methods.
src/lib.rs
Outdated
@@ -122,7 +122,7 @@ pub use crate::backoff::Backoff; | |||
#[doc(inline)] | |||
pub use crate::kv::{BoundRange, IntoOwnedRange, Key, KvPair, Value}; | |||
#[doc(inline)] | |||
pub use crate::raw::{lowering as raw_lowering, Client as RawClient, ColumnFamily}; | |||
pub use crate::raw::{lowering as raw_lowering, Client as RawClient, SyncClient, ColumnFamily}; |
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.
pub use crate::raw::{lowering as raw_lowering, Client as RawClient, SyncClient, ColumnFamily}; | |
pub use crate::raw::{lowering as raw_lowering, Client as RawClient, SyncClient as SyncRawClient, ColumnFamily}; |
src/raw/client.rs
Outdated
@@ -563,3 +628,117 @@ impl Client { | |||
self.atomic.then(|| ()).ok_or(Error::UnsupportedMode) | |||
} | |||
} | |||
|
|||
#[derive(Clone)] | |||
pub struct SyncClient { |
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.
Shall we put the sync client in a separate file? It would look cleaner.
ffdfb74
to
c056a75
Compare
src/raw/sync_client.rs
Outdated
/// let client = SyncRawClient::new(vec!["192.168.0.100"]).await.unwrap(); | ||
/// # }); | ||
/// ``` | ||
pub async fn new<S: Into<String>>(pd_endpoints: Vec<S>) -> Result<SyncClient> { |
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 should also be synchronous.
src/raw/sync_client.rs
Outdated
Self::new_with_config(pd_endpoints, Config::default()).await | ||
} | ||
|
||
pub async fn new_with_config<S: Into<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.
And here
src/raw/sync_client.rs
Outdated
/// ```rust,no_run | ||
/// # use tikv_client::SyncRawClient; | ||
/// # use futures::prelude::*; | ||
/// # futures::executor::block_on(async { |
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.
There shouldn't be async
stuff in the docs and examples.
LGTM. Fix the fmt check please. |
hey @ekexium , could you please help take a look at it? THX! |
@xuhui-lu Could you take a look at these checks and make sure they pass? |
it is weird, it all passed before I merge master into it. Let me take a look. |
@xuhui-lu Oh right. A recent PR just changed the API |
cool, I have merge that change into my PR. It seems that the master branch's CI failed also. |
The master branch is fine. The failed action is going to be removed. #309 |
The failed action is about deploying the doc and is only executed on the master branch, so it shouldn't block merging this PR. You could fix the tests first. |
sure, unit test fixed. |
Signed-off-by: xuhui-lu <[email protected]>
LGTM. Could you sign off your last commit please? |
Signed-off-by: xuhui-lu <[email protected]>
I recently found that I need a synchronous interface with timeout in my development work. Will this PR continue to be developed? Can I continue this work? |
The raw part work of #289