reused grpc connections, not a constant refreshes anymore, all fixed now, keep on fixing other bugs

This commit is contained in:
Priec
2025-09-12 18:15:46 +02:00
parent 85c7c89c28
commit cae47da5f2
6 changed files with 33 additions and 198 deletions

View File

@@ -14,12 +14,20 @@ pub struct AuthClient {
impl AuthClient {
pub async fn new() -> Result<Self> {
// Kept for backward compatibility; opens a new connection.
let client = AuthServiceClient::connect("http://[::1]:50051")
.await
.context("Failed to connect to auth service")?;
Ok(Self { client })
}
/// Preferred: reuse an existing Channel (from GrpcClient).
pub async fn with_channel(channel: Channel) -> Result<Self> {
Ok(Self {
client: AuthServiceClient::new(channel),
})
}
/// Login user via gRPC.
pub async fn login(&mut self, identifier: String, password: String) -> Result<LoginResponse> {
let request = tonic::Request::new(LoginRequest { identifier, password });