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

Proposal: support bound multiple service implements into one server #597

Closed
a631807682 opened this issue Aug 17, 2022 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@a631807682
Copy link
Member

Is your feature request related to a problem? Please describe.

We usually don't declare all services in one IDL (proto file). Take COMMUNITY_MEMBERSHIP as an example, we usually logically distinguish between Member services and Maintainer services, they are Each implements its own logic, we only merge when starting the service.

We'll distinguish them like this:

  • base.proto
message BaseResp {
...
}
  • maintainer.proto
service MaintainerService {
    rpc MergePullRequest (MergePullRequestRequest) returns (MergePullRequestResponse) {}
}
  • member.proto
service MemberService {
    rpc CloseIssues (CloseIssuesRequest) returns (CloseIssuesResponse) {}
}

When I use grpc-go I can make multiple impls bound into one service.

	s := grpc.NewServer(...)
	maintainer.RegisterMaintainerServer(s, &MaintainerServiceImpl{})
	member.RegisterMemberServer(s, &MemberServiceImpl{})
 	s.Serve(...)

grpc-go/serviceInfo
kitex/serviceInfo

Describe the solution you'd like
Support bound multiple service implements into one server

@YangruiEmma
Copy link
Member

Kitex doesn't support multi-service now. But for thrift, you can define multi-service in IDL and use combine service . For gRPC, it is our TODO to support it.

@a631807682
Copy link
Member Author

a631807682 commented Aug 18, 2022

I have two questions about Combine Service

Question 1

There could be decades method defined in service, but only one or two methods is needed by client. Combine Service provides a way to split one service into several services. For Example, there is a ExampleService

I'm not sure if I'm right, the Combine Service appears to be designed to simplify client-side logic, but it does not have the ability to split services and combine multi IDL files, we can split services ourself, but seems combine multi IDL files should be supported.

// CombineServiceImpl implements the last service interface defined in the IDL.
type CombineServiceImpl struct{}

func (s *CombineServiceImpl) MergePullRequest(ctx context.Context, req *api.MergePullRequestRequest) (resp *api.MergePullRequestResponse, err error) {
	return maintainerSrv.MergePullRequest(...)
}

func (s *CombineServiceImpl) CloseIssues(ctx context.Context, req *api.CloseIssuesRequest) (resp *api. CloseIssuesResponse, err error) {
	return memberSrv.CloseIssues(...)
}

Question 2

exampleservice0, exampleservice1 and exampleservice2 are normally generated codes.

We may only need a few sub service of CombineService, can we reuse the same connection if we only want to use exampleservice0 and exampleservice1 ?

@YangruiEmma
Copy link
Member

Question 1
I am sure about your question, this is to combine multi services in one service which name is CombineService. When your generated code file is too big to read, it is useful. And as you said, it also can simplify client-side code.

Question 2
How to use the connection depends on your client. If you want to use 2 services, you can use CombineService to build a client.

@YangruiEmma YangruiEmma added the enhancement New feature or request label Aug 31, 2022
@YangruiEmma
Copy link
Member

TODO same with #679

@Marina-Sakai
Copy link
Contributor

@a631807682 The gRPC multi-service feature is now released in version v0.8.0. Please check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants