Changeset View
Changeset View
Standalone View
Standalone View
keyserver/addons/rust-node-addon/src/identity_client/delete_user.rs
use super::*; | use super::*; | ||||
#[napi] | #[napi] | ||||
#[instrument(skip_all)] | #[instrument(skip_all)] | ||||
pub async fn delete_user(user_id: String) -> Result<()> { | pub async fn delete_user(user_id: String) -> Result<()> { | ||||
let channel = Channel::from_static(&IDENTITY_SERVICE_SOCKET_ADDR) | let channel = get_identity_service_channel().await?; | ||||
.connect() | |||||
.await | |||||
.map_err(|_| { | |||||
Error::new( | |||||
Status::GenericFailure, | |||||
"Unable to connect to identity service".to_string(), | |||||
) | |||||
})?; | |||||
let token: MetadataValue<_> = AUTH_TOKEN | let token: MetadataValue<_> = AUTH_TOKEN | ||||
.parse() | .parse() | ||||
.map_err(|_| Error::from_status(Status::GenericFailure))?; | .map_err(|_| Error::from_status(Status::GenericFailure))?; | ||||
let mut identity_client = | let mut identity_client = | ||||
IdentityServiceClient::with_interceptor(channel, |mut req: Request<()>| { | IdentityServiceClient::with_interceptor(channel, |mut req: Request<()>| { | ||||
req.metadata_mut().insert("authorization", token.clone()); | req.metadata_mut().insert("authorization", token.clone()); | ||||
Ok(req) | Ok(req) | ||||
}); | }); | ||||
Show All 11 Lines |