Update Rust crate tokenservice-client to 0.4.0 (#106)

Co-authored-by: Renovate <system@toast-server.net>
Co-committed-by: Renovate <system@toast-server.net>
This commit is contained in:
Renovate 2024-08-19 21:49:20 -04:00 committed by toast
parent ef723b8986
commit a5e0a5c129
3 changed files with 74 additions and 45 deletions

100
Cargo.lock generated
View File

@ -946,7 +946,7 @@ dependencies = [
"socket2", "socket2",
"widestring", "widestring",
"windows-sys 0.48.0", "windows-sys 0.48.0",
"winreg 0.50.0", "winreg",
] ]
[[package]] [[package]]
@ -1507,7 +1507,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"sync_wrapper 0.1.2", "sync_wrapper 0.1.2",
"system-configuration", "system-configuration 0.5.1",
"tokio", "tokio",
"tokio-rustls 0.24.1", "tokio-rustls 0.24.1",
"tokio-util", "tokio-util",
@ -1518,14 +1518,14 @@ dependencies = [
"wasm-streams", "wasm-streams",
"web-sys", "web-sys",
"webpki-roots 0.25.4", "webpki-roots 0.25.4",
"winreg 0.50.0", "winreg",
] ]
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.12.5" version = "0.12.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"bytes", "bytes",
@ -1553,7 +1553,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"sync_wrapper 1.0.1", "sync_wrapper 1.0.1",
"system-configuration", "system-configuration 0.6.0",
"tokio", "tokio",
"tokio-native-tls", "tokio-native-tls",
"tower-service", "tower-service",
@ -1561,7 +1561,7 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
"winreg 0.52.0", "windows-registry",
] ]
[[package]] [[package]]
@ -1794,9 +1794,9 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.205" version = "1.0.208"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@ -1812,9 +1812,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.205" version = "1.0.208"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1823,9 +1823,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.122" version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed"
dependencies = [ dependencies = [
"itoa", "itoa",
"memchr", "memchr",
@ -2026,6 +2026,9 @@ name = "sync_wrapper"
version = "1.0.1" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
dependencies = [
"futures-core",
]
[[package]] [[package]]
name = "sysinfo" name = "sysinfo"
@ -2049,7 +2052,18 @@ checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"core-foundation", "core-foundation",
"system-configuration-sys", "system-configuration-sys 0.5.0",
]
[[package]]
name = "system-configuration"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42"
dependencies = [
"bitflags 2.6.0",
"core-foundation",
"system-configuration-sys 0.6.0",
] ]
[[package]] [[package]]
@ -2062,6 +2076,16 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "system-configuration-sys"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "tagptr" name = "tagptr"
version = "0.2.0" version = "0.2.0"
@ -2149,11 +2173,11 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokenservice-client" name = "tokenservice-client"
version = "0.3.3" version = "0.4.0"
source = "sparse+https://git.toast-server.net/api/packages/toast/cargo/" source = "sparse+https://git.toast-server.net/api/packages/toast/cargo/"
checksum = "af9294666d8fc39de691f9dd8e919630622af40279dc6c17716359b318edcbb2" checksum = "69fb4574f5ff7b98c91c98d3a8be2eb4c55a895c44f0682aa269c67b5922bbf8"
dependencies = [ dependencies = [
"reqwest 0.12.5", "reqwest 0.12.7",
"serde", "serde",
"serde_json", "serde_json",
"tokio", "tokio",
@ -2792,7 +2816,7 @@ checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
dependencies = [ dependencies = [
"windows-implement", "windows-implement",
"windows-interface", "windows-interface",
"windows-result", "windows-result 0.1.2",
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
@ -2818,6 +2842,17 @@ dependencies = [
"syn 2.0.72", "syn 2.0.72",
] ]
[[package]]
name = "windows-registry"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0"
dependencies = [
"windows-result 0.2.0",
"windows-strings",
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows-result" name = "windows-result"
version = "0.1.2" version = "0.1.2"
@ -2827,6 +2862,25 @@ dependencies = [
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
[[package]]
name = "windows-result"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-strings"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
dependencies = [
"windows-result 0.2.0",
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.48.0" version = "0.48.0"
@ -2994,16 +3048,6 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "winreg"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5"
dependencies = [
"cfg-if",
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.7.35" version = "0.7.35"

View File

@ -11,7 +11,7 @@ once_cell = "1.19.0"
poise = "0.6.1" poise = "0.6.1"
regex = "1.10.6" regex = "1.10.6"
sysinfo = "0.31.2" sysinfo = "0.31.2"
tokenservice-client = { version = "0.3.3", registry = "gitea" } tokenservice-client = { version = "0.4.0", registry = "gitea" }
tokio = { version = "1.39.2", features = ["macros", "signal", "rt-multi-thread"] } tokio = { version = "1.39.2", features = ["macros", "signal", "rt-multi-thread"] }
tokio-postgres = "0.7.11" tokio-postgres = "0.7.11"
uptime_lib = "0.3.1" uptime_lib = "0.3.1"

View File

@ -1,12 +1,8 @@
use std::sync::LazyLock;
use tokio::sync::RwLock;
use tokenservice_client::{ use tokenservice_client::{
TokenService, TokenService,
TokenServiceApi TokenServiceApi
}; };
static TS_GLOBAL_CACHE: LazyLock<RwLock<Option<TokenServiceApi>>> = LazyLock::new(|| RwLock::new(None));
pub struct TSClient(TokenService); pub struct TSClient(TokenService);
impl TSClient { impl TSClient {
@ -17,19 +13,8 @@ impl TSClient {
} }
pub async fn get(&self) -> Result<TokenServiceApi, crate::Error> { pub async fn get(&self) -> Result<TokenServiceApi, crate::Error> {
{
let cache = TS_GLOBAL_CACHE.read().await;
if let Some(ref api) = *cache {
return Ok(api.clone());
}
}
match self.0.connect().await { match self.0.connect().await {
Ok(api) => { Ok(api) => Ok(api),
let mut cache = TS_GLOBAL_CACHE.write().await;
*cache = Some(api.clone());
Ok(api)
}
Err(e) => Err(e) Err(e) => Err(e)
} }
} }