Building the login/logout client
Our login function takes the following signature:
// nanoservices/user-session-cache/cache-client/src/lib.rs
pub async fn login(
address: &str,
user_id: &str,
timeout_mins: usize,
perm_user_id: i32
) -> Result<(), NanoServiceError> {
. . .
Ok(())
}
Inside our login function, we get the connection and send the request with the code below:
// nanoservices/user-session-cache/cache-client/src/lib.rs
let mut con = get_connnection(address).await?;
let result = con
.req_packed_command(
&redis::cmd("login.set")
.arg(user_id)
.arg(timeout_mins)
.arg(perm_user_id.to_string())
.clone(),
)
.await.map_err(|e|{
NanoServiceError::new(
e.to_string(),
NanoServiceErrorStatus::Unknown
)
})?;
match result {
Value::Okay => {
return Ok(());
},
_ => {
return...