- removed: api-service
- removed: session-service - updated: moved health check out of consul registration - updated: get service info to pull the service from the default namespace for the service account - updated: the rest of the services to be able to handle the new database tables
This commit is contained in:
34
auth-service/src/session_client.rs
Normal file
34
auth-service/src/session_client.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use crate::session::{session_service_client::SessionServiceClient, GetSessionRequest, GetSessionResponse};
|
||||
use async_trait::async_trait;
|
||||
use chrono::{DateTime, Utc};
|
||||
use std::error::Error;
|
||||
use tonic::transport::Channel;
|
||||
|
||||
#[async_trait]
|
||||
pub trait SessionClientTrait: Sized {
|
||||
async fn connect(endpoint: &str) -> Result<Self, Box<dyn std::error::Error>>;
|
||||
async fn get_session(
|
||||
&mut self,
|
||||
session_id: String,
|
||||
) -> Result<GetSessionResponse, Box<dyn std::error::Error>>;
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct SessionClient {
|
||||
client: SessionServiceClient<Channel>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl SessionClientTrait for SessionClient {
|
||||
async fn connect(endpoint: &str) -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let client = SessionServiceClient::connect(endpoint.to_string()).await?;
|
||||
Ok(Self { client })
|
||||
}
|
||||
|
||||
async fn get_session(&mut self, session_id: String) -> Result<GetSessionResponse, Box<dyn Error>> {
|
||||
let request = tonic::Request::new(GetSessionRequest {
|
||||
session_id,
|
||||
});
|
||||
let response = self.client.get_session(request).await?;
|
||||
Ok(response.into_inner())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user