Page MenuHomePhabricator

D4733.diff
No OneTemporary

D4733.diff

diff --git a/native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs b/native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs
--- a/native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs
+++ b/native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs
@@ -1,10 +1,19 @@
use lazy_static::lazy_static;
use std::sync::Arc;
use tokio::runtime::{Builder, Runtime};
+use tonic::{transport::Channel, Response, Status};
+
+use identity::{
+ get_user_id_request::AuthType,
+ identity_service_client::IdentityServiceClient, GetUserIdRequest,
+ GetUserIdResponse,
+};
pub mod identity {
tonic::include_proto!("identity");
}
+const IDENTITY_SERVICE_SOCKET_ADDR: &str = "[::1]:50051";
+
lazy_static! {
pub static ref RUNTIME: Arc<Runtime> = Arc::new(
Builder::new_multi_thread()
@@ -15,3 +24,33 @@
.unwrap()
);
}
+
+pub struct Client {
+ identity_client: IdentityServiceClient<Channel>,
+}
+
+impl Client {
+ async fn new() -> Self {
+ Self {
+ identity_client: IdentityServiceClient::connect(
+ IDENTITY_SERVICE_SOCKET_ADDR,
+ )
+ .await
+ .unwrap(),
+ }
+ }
+
+ async fn get_user_id(
+ &mut self,
+ auth_type: AuthType,
+ user_info: String,
+ ) -> Result<Response<GetUserIdResponse>, Status> {
+ self
+ .identity_client
+ .get_user_id(GetUserIdRequest {
+ auth_type: auth_type.into(),
+ user_info,
+ })
+ .await
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 27, 10:13 AM (9 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2712670
Default Alt Text
D4733.diff (1 KB)

Event Timeline