zealchen commented on code in PR #1539:
URL: https://github.com/apache/horaedb/pull/1539#discussion_r1721182253


##########
src/server/src/grpc/remote_engine_service/mod.rs:
##########
@@ -643,24 +702,53 @@ impl RemoteEngineServiceImpl {
 
     async fn write_batch_internal(
         &self,
-        request: Request<WriteBatchRequest>,
-    ) -> std::result::Result<Response<WriteResponse>, Status> {
+        request: TonicWriteBatchRequestExt,
+    ) -> std::result::Result<TonicWriteResponseExt, Status> {
         let begin_instant = Instant::now();
-        let request = request.into_inner();
-        let mut write_table_handles = Vec::with_capacity(request.batch.len());
-        for one_request in request.batch {
-            let ctx = self.handler_ctx();
-            let handle = self
-                .runtimes
-                .write_runtime
-                .spawn(handle_write(ctx, one_request));
-            write_table_handles.push(handle);
-        }
+
+        let (write_table_handles, request_type) = match request {
+            TonicWriteBatchRequestExt::Proto(v) => {
+                let request = v.into_inner();
+                let mut write_table_handles = 
Vec::with_capacity(request.batch.len());
+                for one_request in request.batch {
+                    let ctx = self.handler_ctx();
+                    let handle = self
+                        .runtimes
+                        .write_runtime
+                        .spawn(handle_write(ctx, 
WriteRequestExt::Proto(one_request)));
+                    write_table_handles.push(handle);
+                }
+                (write_table_handles, RequestType::Protobuf)
+            }
+            TonicWriteBatchRequestExt::Flatbuffer(v) => {
+                let request = Arc::new(v.into_inner());
+                let req = 
request.deserialize::<FBWriteBatchRequest>().unwrap();

Review Comment:
   1. FlatBufferBytes::deserialize is changed to unsafe function call as 
internal request routing is supposed to be safe among servers.
   2. Other unwraps are all based on batch() which cannot be None in internal 
procedure.
   3. Always follow the backwards compatibility solution for the schema design  
(https://flatbuffers.dev/flatbuffers_guide_tutorial.html)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to