reused grpc connections, not a constant refreshes anymore, all fixed now, keep on fixing other bugs
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user