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

Correct the relationships around services, clusters and instances #1107

Closed
jifengnan opened this issue Apr 24, 2019 · 2 comments
Closed

Correct the relationships around services, clusters and instances #1107

jifengnan opened this issue Apr 24, 2019 · 2 comments
Labels
area/Naming kind/enhancement Category issues or prs related to enhancement.

Comments

@jifengnan
Copy link
Contributor

jifengnan commented Apr 24, 2019

Issue Description

Type: feature request

Describe what feature you want

修正service,cluster和instance之间的关系(Correct the relationships between services and clusters, clusters and instances)

鉴于 #1098 涉及的代码修改过于庞大,因此可以先从修正service,cluster和instance之间的关系开始着手。(Since it's a huge work to support #1098 , so we can start from correcting the relationships around services, clusters and instances)

Describe what you expected to happen

根据nacos官方设定,一个service由多个cluster组成,一个cluster由多个instance组成,其UML图应为:service ◇→ cluster ◇→ instance (均为聚合关系)(The uml class diagram should be service ◇→ cluster ◇→ instance)

一般,聚合关系的类结构应该如下:

Service{
	List<Cluster> clusters; //只是例子,不代表一定得是个List
}

Cluster{
	Service service;
	List<Instance> instances; //只是例子,不代表一定得是个List
}

Instance{
	Cluster cluster;
}

除非是DTO,否则cluster和instance中不应该出现service name等service中的属性(冗余),而应通过service.getName获取。同理instance中也不应该出现cluster name。这样可以保证service属性(比如name)的一致性,一处修改,处处生效。

目前naming模块的 service, cluster 和 instance 分别继承自api模块的 service, cluster 和 instance,而api模块的这三个类从作用来看类似于DTO,所以导致naming模块的三个类无法避免的拥有了冗余属性。这一块以后应该要彻底解决掉,但现在作为一个改动最小的临时方案,可以通过覆盖父类的方法来暂时达到目的。

@nacos-bot
Copy link
Collaborator

Hi @jifengnan, we detect non-English characters in the issue. This comment is an auto translation from @nacos-bot to help other users to understand this issue.
We encourage you to describe your issue in English which is more friendly to other users.

Correct the relationships around services, clusters and instances

Issue Description

Type: feature request

Describe what feature you want

Correct the relationship between services, clusters and instances (Correct the relationships between services and clusters, clusters and instances)

Since the code changes involved in #1098 are too large, you can start by modifying the relationship between service, cluster, and instance. (Since it's a huge work to support #1098 , so we can start from correcting the relationships around services, clusters and instances)

Describe what you expected to happen

According to the official nacos setting, a service consists of multiple clusters. A cluster consists of multiple instances. The UML diagram should be: service ◇→ cluster ◇→ instance (all aggregate relationships) (The uml class diagram should be service ◇ → cluster ◇→ instance)

In general, the class structure of an aggregate relationship should be as follows:

Service{
	List<Cluster> clusters;
}

Cluster{
	Service service;
	List<Instance> instances;
}

Instance{
	Cluster cluster;
}

Unless it is a DTO, the attributes in the service name and other services should not appear in the cluster and instance, but should be obtained through service.getName. The cluster name should not appear in the same instance. This can ensure the consistency of the service attribute (such as name), one modification, and take effect everywhere.

@jifengnan
Copy link
Contributor Author

Finished in PR#1554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/Naming kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

No branches or pull requests

3 participants