dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

[Feature][3.3] Triple protocol support multi arguments

Open AlbumenJ opened this issue 11 months ago • 12 comments

Pre-check

  • [X] I am sure that all the content I provide is in English.

Search before asking

  • [X] I had searched in the issues and found no similar feature requirement.

Apache Dubbo Component

Java SDK (apache/dubbo)

Descriptions

Triple protocol support multi arguments in none-annotation mode

Interface:

public interface GreetingsService {
    String sayHi(String name, String message);
}

Example requests:

  1. using array
curl \
    --header "Content-Type: application/json" \
    --data '["Dubbo","hello"]' \
    http://localhost:50052/org.apache.dubbo.samples.tri.unary.GreetingsService/sayHi/
  1. using map
curl \
    --header "Content-Type: application/json" \
    --data '{"name":"Dubbo","message":"hello"}' \
    http://localhost:50052/org.apache.dubbo.samples.tri.unary.GreetingsService/sayHi/

Related issues

No response

Are you willing to submit a pull request to fix on your own?

  • [ ] Yes I am willing to submit a pull request on my own!

Code of Conduct

AlbumenJ avatar Mar 20 '24 03:03 AlbumenJ

I'm interested. Please assign it to me.

finefuture avatar Mar 20 '24 04:03 finefuture

@finefuture I'm currently working on this, and I'm make a tasklist for rest, if you're interest on it, I can assign some to you.

oxsean avatar Mar 20 '24 04:03 oxsean

@finefuture I'm currently working on this, and I'm make a tasklist for rest, if you're interest on it, I can assign some to you.

Okay, please assign some to me.

finefuture avatar Mar 20 '24 06:03 finefuture

@AlbumenJ request payload will be determined by interface argument name, is it a good idea?

Chenjp avatar May 13 '24 09:05 Chenjp

@AlbumenJ request payload will be determined by interface argument name, is it a good idea?

This is as expected

AlbumenJ avatar May 14 '24 03:05 AlbumenJ

@AlbumenJ request payload will be determined by interface argument name, is it a good idea?

This is as expected

Assume another composite parameter exist:

public class CompositeBean implements Serializable {
  private String name;
  private String code;
  .... 
}
public interface GreetingsService {
  String sayHi3(String name, String message, CompositeBean source); 
}

I dont know what request should be.

Chenjp avatar May 16 '24 16:05 Chenjp

@AlbumenJ request payload will be determined by interface argument name, is it a good idea?

This is as expected

Assume another composite parameter exist:

public class CompositeBean implements Serializable {
  private String name;
  private String code;
  .... 
}
public interface GreetingsService {
  String sayHi3(String name, String message, CompositeBean source); 
}

I dont know what request should be.

["testName", "testMessage", {"name":"subName", "code": "subCode"}]

AlbumenJ avatar May 17 '24 02:05 AlbumenJ

@AlbumenJ I have another question, does triple protocol allow method overload currently?

public interface GreetingsService {
  String sayHi3(String name, String message, CompositeBean source); 
  String sayHi3(String name, String message, SourceBean source);
}

Chenjp avatar May 27 '24 05:05 Chenjp

@AlbumenJ I have another question, does triple protocol allow method overload currently?

public interface GreetingsService {
  String sayHi3(String name, String message, CompositeBean source); 
  String sayHi3(String name, String message, SourceBean source);
}

For Triple in wrapper mode, we support. For Triple in plain http or grpc mode, we don't support.

AlbumenJ avatar May 28 '24 02:05 AlbumenJ

@AlbumenJ I have another question, does triple protocol allow method overload currently?

public interface GreetingsService {
  String sayHi3(String name, String message, CompositeBean source); 
  String sayHi3(String name, String message, SourceBean source);
}

For Triple in wrapper mode, we support. For Triple in plain http or grpc mode, we don't support.

Since dubbo support multi-protocols and different protocols have different constraints. It's better to ensure semantic consistency, make each Service protocol-insensitive. I recommend removing method overload support for all protocols.

Chenjp avatar May 28 '24 09:05 Chenjp

@AlbumenJ I have another question, does triple protocol allow method overload currently?

public interface GreetingsService {
  String sayHi3(String name, String message, CompositeBean source); 
  String sayHi3(String name, String message, SourceBean source);
}

For Triple in wrapper mode, we support. For Triple in plain http or grpc mode, we don't support.

Since dubbo support multi-protocols and different protocols have different constraints. It's better to ensure semantic consistency, make each Service protocol-insensitive. I recommend removing method overload support for all protocols.

That is a hope. Only a hope. Really really really hard~

AlbumenJ avatar May 30 '24 09:05 AlbumenJ

    def "override mapping test"() {
        given:
            def request = new TestRequest(path: path)
        expect:
            runner.run(request, String.class) == output
        where:
            path                          | output
            '/say?name=sam&count=2'       | '2'
            '/say?name=sam'               | '1'
            '/say~SL'                     | '2'
            '/say~S'                      | '1'
            '/say~S?name=sam&count=2'     | '1'
            '/say~S.yml?name=sam&count=2' | '1'
    }

    String say(String name, Long count)

    String say(String name)

In the latest REST Triple, support method override has been added by passing the method signature abbreviation.

oxsean avatar Jun 19 '24 01:06 oxsean