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

Solving Circular Dependency in Dubbo-Go #2565

Closed
FinalT opened this issue Jan 6, 2024 · 2 comments
Closed

Solving Circular Dependency in Dubbo-Go #2565

FinalT opened this issue Jan 6, 2024 · 2 comments

Comments

@FinalT
Copy link
Member

FinalT commented Jan 6, 2024

Why is this needed:
This issue was brought up by #2539. Although the export logic of the server layer was separated, the generated triple files still depend on the server layer. This means that our internal service module still depends on the server layer, and our underlying modules depend on these internal services. As the server layer is an upper-level module, it depends on these lower-level modules, resulting in a circular dependency.

What would you like to be added:
However, the underlying modules typically only use a few interfaces of the internal services, and the number of internal services is not large. It is not necessary to depend on all packages of the internal services. One possible solution is to create an "internal" package as the top-level module, where the service methods are defined. Then, the internal services can still be registered through the server layer, and the methods can be further registered in the internal package. This way, other modules do not need to directly depend on the internal services.

Refer to grpc-go to resolve circular dependencies

@chickenlj
Copy link
Contributor

There're some terms that I cannot understand well, internal service, underlying service, internal package, server layer. Could you please explain the part in dubbo-go they stand for, maybe giving an example for each of them?

One possible solution is to create an "internal" package as the top-level module, where the service methods are defined. Then, the internal services can still be registered through the server layer, and the methods can be further registered in the internal package. This way, other modules do not need to directly depend on the internal services.

For this solution, could you please give a simple example of maybe how it solves the specific issue in #2539?

@FinalT
Copy link
Member Author

FinalT commented Jan 8, 2024

Take healthcheck for example,Here are the current dependencies between modules,It's easy to make circular dependencies if other modules need to make changes to the service health state in the future
image
This is the relationship between modules after transformation
image

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

2 participants