Skip to content

Commit

Permalink
adjust call points
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Nov 21, 2023
1 parent 4efb182 commit 305ba7c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/cmd/src/cli/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ pub struct BenchTableMetadataCommand {

impl BenchTableMetadataCommand {
pub async fn build(&self) -> Result<Instance> {
let etcd_store = EtcdStore::with_endpoints([&self.etcd_addr]).await.unwrap();
let etcd_store = EtcdStore::with_endpoints("", [&self.etcd_addr])
.await
.unwrap();

let table_metadata_manager = Arc::new(TableMetadataManager::new(etcd_store));

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/src/cli/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl UpgradeCommand {
etcd_addr: &self.etcd_addr,
})?;
let tool = MigrateTableMetadata {
etcd_store: EtcdStore::with_etcd_client(client),
etcd_store: EtcdStore::with_etcd_client("", client),
dryrun: self.dryrun,
skip_catalog_keys: self.skip_catalog_keys,
skip_table_global_keys: self.skip_table_global_keys,
Expand Down
10 changes: 7 additions & 3 deletions src/common/meta/src/kv_backend/etcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ pub struct EtcdStore {
}

impl EtcdStore {
pub async fn with_endpoints<E, S>(root: String, endpoints: S) -> Result<KvBackendRef>
pub async fn with_endpoints<R, E, S>(root: R, endpoints: S) -> Result<KvBackendRef>
where
R: Into<Vec<u8>>,
E: AsRef<str>,
S: AsRef<[E]>,
{
Expand All @@ -57,9 +58,12 @@ impl EtcdStore {
Ok(Self::with_etcd_client(root, client))
}

pub fn with_etcd_client(root: String, client: Client) -> KvBackendRef {
pub fn with_etcd_client<R>(root: R, client: Client) -> KvBackendRef
where
R: Into<Vec<u8>>,
{
Arc::new(Self {
root: root.into_bytes(),
root: root.into(),
client,
})
}
Expand Down
4 changes: 3 additions & 1 deletion src/meta-srv/examples/kv_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ fn main() {

#[tokio::main]
async fn run() {
let kv_backend = EtcdStore::with_endpoints(["127.0.0.1:2380"]).await.unwrap();
let kv_backend = EtcdStore::with_endpoints("", ["127.0.0.1:2380"])
.await
.unwrap();

// put
let put_req = PutRequest {
Expand Down
2 changes: 1 addition & 1 deletion src/meta-srv/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub async fn build_meta_srv(opts: &MetaSrvOptions, plugins: Plugins) -> Result<M
.await
.context(error::ConnectEtcdSnafu)?;
(
EtcdStore::with_etcd_client(etcd_client.clone()),
EtcdStore::with_etcd_client("", etcd_client.clone()),
Some(EtcdElection::with_etcd_client(&opts.server_addr, etcd_client.clone()).await?),
Some(EtcdLock::with_etcd_client(etcd_client)?),
)
Expand Down
2 changes: 1 addition & 1 deletion src/meta-srv/src/mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub async fn mock_with_memstore() -> MockInfo {
}

pub async fn mock_with_etcdstore(addr: &str) -> MockInfo {
let kv_backend = EtcdStore::with_endpoints([addr]).await.unwrap();
let kv_backend = EtcdStore::with_endpoints("", [addr]).await.unwrap();
mock(Default::default(), kv_backend, None, None).await
}

Expand Down

0 comments on commit 305ba7c

Please sign in to comment.