apache / apache/dubbo

URL code optimization

Open
#10,946 3 comments 0 reactions 0 assignees View on GitHub
type/discussion
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

In the url part of dubbo, I saw some unreasonable designs, maybe we can refactor and optimize it.

For example, the most basic parent class URL should ensure the integrity of its own attributes. See #10921.

There are some others, such as:

1. Single attribute principle.
![image](https://user-images.githubusercontent.com/38374721/202143365-f0396960-d13e-43b9-8bb6-8981c640567f.png)
There are multiple attributes here including host and port. Do we only need one host and port? Other places use the method to obtain, so when you want to dynamically modify the ip and port, only change one place instead of traversing
2. Too much Overload does not look concise enough, although this is one of the characteristics of java
Is it better to use the builder mode and load on demand?
![image](https://user-images.githubusercontent.com/38374721/202149674-12610c81-d839-448c-8c8f-b6162019d31f.png)
3. The URL should only contain necessary attributes, such as host and port (maybe more, looks a bit like the first point), and cannot be overridden. The form of an abstract class may be better (it is meaningless to use it alone), and additional interface is also necessary

@AlbumenJ PTAL

Contributor guide

Open the contributing guide

Research direction

Start by reading the URL implementation in Dubbo and the related discussion in #10921. Review the existing URL attributes, overloads, and subclass or interface structure described in this issue, then seek an agreed design before making changes. Done means the URL design is simplified without breaking existing behavior, with verification for the affected usage paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.