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

Triple client&server api #2502

Merged
merged 22 commits into from
Nov 20, 2023
Merged

Triple client&server api #2502

merged 22 commits into from
Nov 20, 2023

Conversation

chickenlj
Copy link
Contributor

@chickenlj chickenlj commented Nov 13, 2023

  1. ConsumerConfig and ProviderConfig serve as the default configuration across services.
type ConsumerConfig struct {
	ReferenceConfig
}
type ProviderConfig struct {
	ServiceConfig
}
  1. Both the client and server have the same configuration hierarchy.
  • dubbo.NewInstance(InstanceOption)
  • instance.NewServer(ServerOption) / instance.NewClient(ClientOption)
  • server.RegisterService(ServiceOption) / client.GetGreetService(ReferenceOption)
  • greetService.greet(CallOption)

@chickenlj chickenlj marked this pull request as draft November 14, 2023 01:49
@chickenlj chickenlj requested a review from DMwangnima November 14, 2023 01:53
client/options.go Show resolved Hide resolved
client/options.go Show resolved Hide resolved
test.justify(t, newOpts)
}
}
//func TestWithURL(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After merging this PR, we can modify this test file.

"reflect"
)

func CopyFields(sourceValue reflect.Value, targetValue reflect.Value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java-Style but very efficient code :)

client/client.go Outdated
@@ -45,7 +47,7 @@ type ClientInfo struct {
Meta map[string]interface{}
}

func (cli *Client) call(ctx context.Context, paramsRawVals []interface{}, interfaceName, methodName, callType string, opts ...CallOption) (protocol.Result, error) {
func (cli *Client) call(ctx context.Context, paramsRawVals []interface{}, interfaceName, methodName, group, version, callType string, opts ...CallOption) (protocol.Result, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to consider that whether group and version should be required fields.
Since this function is relevant to non-idl API, we need to keep it simple.
For instance, if users do not need to configure group and version,

cli.CallUnary(ctx, req, resp, interfaceName, methodName, "", "") 

Empty strings are very redundant.
I prefer to use CallOption to carry group and version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I was also thinking of using CallOption in the first place. I will move group and version to CallOption later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting group and version into CallOption has other issues. But still it's currently the best way I can think of.

client/client.go Outdated
if err != nil {
return nil, err
}
return res.Result(), res.Error()
}

func (cli *Client) Init(info *ClientInfo) error {
func (cli *Client) Init(interfaceName string, info *ClientInfo, opts ...ReferenceOption) (string, string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClientInfo contains InterfaceName. And we also need to consider about non-idl API style since this function is also important.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got

@chickenlj chickenlj marked this pull request as ready for review November 17, 2023 07:12
@chickenlj chickenlj changed the base branch from feature-triple to main November 18, 2023 04:39
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@ev1lQuark ev1lQuark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if err != nil {
return nil, err
}
rawStream := stream.(*triple_protocol.ServerStreamForClient)
return &HealthWatchClient{rawStream}, nil
}

func appendGroupVersion(opts []client.CallOption, c *HealthImpl) []client.CallOption {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if users passing WithGroup and WithVersion directly? Should we set priority or just ignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have the same concern when implementing this feature.

@@ -267,9 +273,9 @@ func WithLoadBalanceP2C() ReferenceOption {
}
}

func WithLoadBalanceXDSRingHash() ReferenceOption {
func WithLoadBalance(lb string) ReferenceOption {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only do we need to enumerate, but we also need to leave a generic configuration API?

Copy link
Contributor Author

@chickenlj chickenlj Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I realize this is necessary when developing samples. This becomes especially useful when considering Dubbo's high extensibility, we need to make sure our API can support user's self-extended LoadBalance policies.

@DMwangnima
Copy link
Contributor

I would merge this PR and do some fine tuning.

@DMwangnima DMwangnima merged commit 9ea5129 into apache:main Nov 20, 2023
@chickenlj chickenlj deleted the triple-client-api branch November 21, 2023 01:36
@chickenlj
Copy link
Contributor Author

I would merge this PR and do some fine tuning.

Thanks. Please remember to file new issues for todos recognized.

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

Successfully merging this pull request may close these issues.

4 participants