-
Notifications
You must be signed in to change notification settings - Fork 131
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
Introduce KeySpace interface for API v2. #353
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
@@ -204,22 +209,27 @@ pub trait PdClient: Send + Sync + 'static { | |||
async fn update_leader(&self, ver_id: RegionVerId, leader: metapb::Peer) -> Result<()>; | |||
|
|||
async fn invalidate_region_cache(&self, ver_id: RegionVerId); | |||
|
|||
fn get_request_codec(&self) -> Self::RequestCodec; |
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 it should return reference to Self::RequestCodec?
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.
Since the only use of RequestCodec
is in the construction of Dispatch
, and it requires a move, I think Self::RequestCodec
is more direct.
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 see. Then we can probably rename it to create_request_codec or new_request_codec which means it's actually a factory method. It's not going to be called many times, and move is the right semantic.
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
examples/pessimistic.rs
Outdated
@@ -20,7 +23,7 @@ async fn main() { | |||
}; | |||
|
|||
// init | |||
let client = Client::new_with_config(args.pd, config, None) | |||
let client = Client::new_with_config(args.pd, config, TxnApiV1, None) |
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.
Client
itself can tell we are using TxnKV already, can we hide things like TxnApiV1, TxnApiV2, RawApiV1, RawApiV2. Just let user chose the appropriate client and use ApiV1 or ApiV2.
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 may reexport them in their own module, like: raw::ApiV1
, txn::ApiV1
Signed-off-by: iosmanthus <[email protected]>
src/lib.rs
Outdated
//! let client = RawClient::new(vec!["127.0.0.1:2379"], None).await?; | ||
//! # use tikv_client::request::request_codec::RawApiV1; | ||
//! futures::executor::block_on(async { | ||
//! let client = RawClient::new(vec!["127.0.0.1:2379"], RawApiV1, None).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 might break the original API, we should add a default implementation for API V1.
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
src/request/mod.rs
Outdated
} | ||
|
||
#[macro_export] | ||
macro_rules! impl_kv_request_for_scan_op { |
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.
These macro rules have the same patterns which are to take some field out and then encode or decode it. We should extract them into one rule.
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
} | ||
} | ||
|
||
impl KeySpaceId { |
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.
@sunxiaoguang PTAL. This is the logic for constructing keyspace from the name.
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
Signed-off-by: iosmanthus <[email protected]>
I am very excited for this! |
Signed-off-by: iosmanthus [email protected]
This pull request is still working in progress, and the interfaces for request encoding are stable. However, lots of the request structs need to implement with these interfaces.
The core interfaces to encode the request are:
When the
C
is bound toRequestCodec
, the requests are able to be encoded:TODO: