Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Google Protobuf object TypeDefinition.#PR:4011 #4010

Closed
2 tasks done
vio-lin opened this issue May 9, 2019 · 1 comment
Closed
2 tasks done

Generate Google Protobuf object TypeDefinition.#PR:4011 #4010

vio-lin opened this issue May 9, 2019 · 1 comment

Comments

@vio-lin
Copy link
Contributor

vio-lin commented May 9, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

As for dubbo service test, it is convient to use Generic reference.
But for GooglePb test this approach is not work.
We are going to support google protobuf for Generic reference.

  1. ServiceDefinition should be able to support google protobuf Metadata.
  2. Generic invocation should be able to send json String to GenericFilter.
  3. GenericFilter should be able to parse json String to Google Protobuf Object for the request.
  4. GenericFilter should be able to parse Google Protobuf Object to json String for the response.

For (1), PR #4011 is going to support that.
For (2), already support by dubbo.
For (3),#4, PR #3975 already fixed that.

For (1) (PR #4011):

  1. we change TypeDefinitionBuilder to use SPI to load TypeBuilderList.
  2. extended TypeBuilder in ProtobufTypeBuilder class, while user is able to extend that.
  3. ProtobufTypedBuilder is able to parse google protobuf class to TypeDefinition.
  4. We keep similar logic as TypeDefinitionBuilder,so the TypeDefiniton generated by GooglePb will be equals to which generate by java POJO.

How to use?

  1. get google protobuf Metadata from ServiceDefinition.
    test client get metaData form metaData reporter.

  2. parse google protobuf metadata to json string for the user (eg: Dubbo Admin portal).
    TypeDefinition -> json String

  3. send json string with parameter to GenericFilter.

consumer.xml
    <!-- generate proxy for the remote service, then demoService can be used in the same way as the
    local regular interface -->
    <dubbo:reference url ="dubbo://localhost:20880/org.apache.dubbo.demo.protobuf.api.ProtobufDemoService"
                     id="demoService" check="false" interface="org.apache.dubbo.rpc.service.GenericService" generic="proto"/>
   GenericService genericService = context.getBean("demoService", GenericService.class);
    String methodName = "sayHello";
    String[] requestType = new String[]{GooglePBRequestType.class.getName()};
    // TODO this requestStr could generate from serviceMetaData. a new TypeDefinition is create will push next
    String requestStr = "{ \"req\": \"some Message\" }";
    Object[] request = new Object[]{requestStr};
    String hello = (String) genericService.$invoke(methodName,requestType,request);
@vio-lin vio-lin changed the title [WIP]TypeDefinitonBuilder support google protobuf service metadata generating#PR:XXX [WIP]Generate Google Protobuf object TypeDefinition.#PR:4011 May 9, 2019
@vio-lin vio-lin changed the title [WIP]Generate Google Protobuf object TypeDefinition.#PR:4011 Generate Google Protobuf object TypeDefinition.#PR:4011 May 9, 2019
@vio-lin
Copy link
Contributor Author

vio-lin commented Aug 12, 2019

already merged

@vio-lin vio-lin closed this as completed Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant