You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2023/01/15 09:20:16 UTC

[GitHub] [shenyu] Inuyasha-Monster opened a new issue, #4321: [Question]

Inuyasha-Monster opened a new issue, #4321:
URL: https://github.com/apache/shenyu/issues/4321

   ### Question
   
   ![image](https://user-images.githubusercontent.com/12888788/212532562-ad7dcf38-01f0-4c9d-97cb-40b1c5d9c0df.png)
   As shown in the place marked in the picture, we can cache the result through a static field and a static constructor to avoid repeated construction of the proto file, as shown below
   ```java
   private static final Descriptors.Descriptor JSON_MARSHALLER_DESCRIPTOR;
   
   static {
       // build Descriptor Proto
       DescriptorProtos.DescriptorProto.Builder jsonMarshaller = DescriptorProtos.DescriptorProto.newBuilder();
       jsonMarshaller.setName(GrpcConstants.JSON_DESCRIPTOR_PROTO_NAME);
       jsonMarshaller.addFieldBuilder()
               .setName(GrpcConstants.JSON_DESCRIPTOR_PROTO_FIELD_NAME)
               .setNumber(1)
               .setType(DescriptorProtos.FieldDescriptorProto.Type.TYPE_STRING);
   
       // build File Descriptor Proto
       DescriptorProtos.FileDescriptorProto.Builder fileDescriptorProtoBuilder = DescriptorProtos.FileDescriptorProto.newBuilder();
       fileDescriptorProtoBuilder.addMessageType(jsonMarshaller);
   
       DescriptorProtos.FileDescriptorProto fileDescriptorProto = fileDescriptorProtoBuilder.build();
       try {
           Descriptors.FileDescriptor fileDescriptor = Descriptors.FileDescriptor
                   .buildFrom(fileDescriptorProto, new Descriptors.FileDescriptor[0]);
           JSON_MARSHALLER_DESCRIPTOR = fileDescriptor.findMessageTypeByName(GrpcConstants.JSON_DESCRIPTOR_PROTO_NAME);
       } catch (Descriptors.DescriptorValidationException e) {
           LOG.error("dynamic build JsonMarshaller descriptor is fail: {}", e.getMessage());
           throw new RuntimeException("dynamic build JsonMarshaller descriptor is fail", e);
       }
   }
   ```
   I have tested that it is work ok and can improve the performance of each grpc invoke ... and i can perfect it


-- 
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: notifications-unsubscribe@shenyu.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shenyu] yu199195 closed issue #4321: [Question]

Posted by "yu199195 (via GitHub)" <gi...@apache.org>.
yu199195 closed issue #4321: [Question] <JsonMessage's buildJsonMarshallerDescriptor method result can be cache?>
URL: https://github.com/apache/shenyu/issues/4321


-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shenyu] Inuyasha-Monster commented on issue #4321: [Question]

Posted by GitBox <gi...@apache.org>.
Inuyasha-Monster commented on issue #4321:
URL: https://github.com/apache/shenyu/issues/4321#issuecomment-1383100219

   If possible, it will improve both grpc server and grpc client performance


-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org