Update zookeeper client

This commit is contained in:
ManyTheFish 2023-08-07 14:20:01 +02:00
parent 3d46e84d97
commit b311089435
4 changed files with 16 additions and 15 deletions

23
Cargo.lock generated
View File

@ -1265,7 +1265,7 @@ dependencies = [
"tempfile", "tempfile",
"thiserror", "thiserror",
"time", "time",
"uuid 1.3.3", "uuid 1.4.1",
] ]
[[package]] [[package]]
@ -1464,7 +1464,7 @@ dependencies = [
"faux", "faux",
"tempfile", "tempfile",
"thiserror", "thiserror",
"uuid 1.3.3", "uuid 1.4.1",
] ]
[[package]] [[package]]
@ -1994,7 +1994,7 @@ dependencies = [
"tempfile", "tempfile",
"thiserror", "thiserror",
"time", "time",
"uuid 1.3.3", "uuid 1.4.1",
] ]
[[package]] [[package]]
@ -2665,7 +2665,7 @@ dependencies = [
"tokio-stream", "tokio-stream",
"toml", "toml",
"urlencoding", "urlencoding",
"uuid 1.3.3", "uuid 1.4.1",
"vergen", "vergen",
"walkdir", "walkdir",
"yaup", "yaup",
@ -2691,7 +2691,7 @@ dependencies = [
"thiserror", "thiserror",
"time", "time",
"tokio", "tokio",
"uuid 1.3.3", "uuid 1.4.1",
"zookeeper-client", "zookeeper-client",
] ]
@ -2722,7 +2722,7 @@ dependencies = [
"thiserror", "thiserror",
"time", "time",
"tokio", "tokio",
"uuid 1.3.3", "uuid 1.4.1",
] ]
[[package]] [[package]]
@ -2802,7 +2802,7 @@ dependencies = [
"tempfile", "tempfile",
"thiserror", "thiserror",
"time", "time",
"uuid 1.3.3", "uuid 1.4.1",
] ]
[[package]] [[package]]
@ -4420,9 +4420,9 @@ dependencies = [
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.3.3" version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d"
dependencies = [ dependencies = [
"getrandom", "getrandom",
"serde", "serde",
@ -4865,9 +4865,9 @@ dependencies = [
[[package]] [[package]]
name = "zookeeper-client" name = "zookeeper-client"
version = "0.4.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade019937af9b1e2160582cb8d905bcff5d4b71da82444b7bf2ccc9c93f344f2" checksum = "4d69dd5ba1592db2f385d3ff8fee13ed3a50024d2cf65bf4b49ca8ba7cfb9070"
dependencies = [ dependencies = [
"bytes", "bytes",
"compact_str", "compact_str",
@ -4882,6 +4882,7 @@ dependencies = [
"strum", "strum",
"thiserror", "thiserror",
"tokio", "tokio",
"uuid 1.4.1",
] ]
[[package]] [[package]]

View File

@ -26,4 +26,4 @@ thiserror = "1.0.40"
time = { version = "0.3.20", features = ["serde-well-known", "formatting", "parsing", "macros"] } time = { version = "0.3.20", features = ["serde-well-known", "formatting", "parsing", "macros"] }
tokio = { version = "1.27.0", features = ["full"] } tokio = { version = "1.27.0", features = ["full"] }
uuid = { version = "1.3.1", features = ["serde", "v4"] } uuid = { version = "1.3.1", features = ["serde", "v4"] }
zookeeper-client = "0.4.0" zookeeper-client = "0.5.0"

View File

@ -38,7 +38,7 @@ impl AuthController {
// setup the auth zk environment, the `auth` node // setup the auth zk environment, the `auth` node
Some(ref zk) => { Some(ref zk) => {
let options = let options =
zk::CreateOptions::new(zk::CreateMode::Persistent, zk::Acl::anyone_all()); zk::CreateMode::Persistent.with_acls(zk::Acls::anyone_all());
// TODO: we should catch the potential unexpected errors here https://docs.rs/zookeeper-client/latest/zookeeper_client/struct.Client.html#method.create // TODO: we should catch the potential unexpected errors here https://docs.rs/zookeeper-client/latest/zookeeper_client/struct.Client.html#method.create
// for the moment we consider that `create` only returns Error::NodeExists. // for the moment we consider that `create` only returns Error::NodeExists.
match zk.create("/auth", &[], &options).await { match zk.create("/auth", &[], &options).await {
@ -159,7 +159,7 @@ impl AuthController {
// TODO: we may commit only after zk persisted the keys // TODO: we may commit only after zk persisted the keys
let key = tokio::task::spawn_blocking(move || store.put_api_key(key)).await??; let key = tokio::task::spawn_blocking(move || store.put_api_key(key)).await??;
if let Some(ref zk) = self.zk { if let Some(ref zk) = self.zk {
let options = zk::CreateOptions::new(zk::CreateMode::Persistent, zk::Acl::anyone_all()); let options = zk::CreateMode::Persistent.with_acls(zk::Acls::anyone_all());
zk.create(&format!("/auth/{}", key.uid), &serde_json::to_vec_pretty(&key)?, &options) zk.create(&format!("/auth/{}", key.uid), &serde_json::to_vec_pretty(&key)?, &options)
.await?; .await?;

View File

@ -105,7 +105,7 @@ walkdir = "2.3.3"
yaup = "0.2.1" yaup = "0.2.1"
serde_urlencoded = "0.7.1" serde_urlencoded = "0.7.1"
termcolor = "1.2.0" termcolor = "1.2.0"
zookeeper-client = "0.4.0" zookeeper-client = "0.5.0"
[dev-dependencies] [dev-dependencies]
actix-rt = "2.8.0" actix-rt = "2.8.0"