xline-kv / Xline

A geo-distributed KV store for metadata management
https://xline.cloud
Apache License 2.0
596 stars 74 forks source link

[Refactor]: Temporary interceptors #657

Open themanforfree opened 7 months ago

themanforfree commented 7 months ago
// crates/curp/src/mod.rs
pub trait ClientApi {
  ...
  async fn propose(
      &self,
      cmd: &Self::Cmd,
      token: Option<&String>, // TODO: Allow external custom interceptors, do not pass token in parameters
      use_fast_path: bool,
  ) -> Result<ProposeResponse<Self::Cmd>, Self::Error>;
  ...
}

Current we have added a token parameter to the propose method of the curp client to have xline pass a token for each request, but curp itself does not need this token. Therefore, it is better to remove this parameter and add the ability to create temporary interceptors to the ClientApi, Xline or other applications can specify a temporary interceptor when making requests, and the curp layer will apply a interceptor for the current request before sending the request, so that there is no need to expose the token to the curp layer, and improve the flexibility of curp to send requests