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

feat: support Consul as ServiceRegistry #695

Merged
merged 62 commits into from
Aug 27, 2024
Merged

feat: support Consul as ServiceRegistry #695

merged 62 commits into from
Aug 27, 2024

Conversation

lyt122
Copy link
Contributor

@lyt122 lyt122 commented Aug 23, 2024

ref #259

@github-actions github-actions bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Aug 23, 2024
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 80.48780% with 24 lines in your changes missing coverage. Please review.

Project coverage is 88.36%. Comparing base (db65556) to head (8448ef3).
Report is 5 commits behind head on main.

Files Patch % Lines
controller/registries/consul/config.go 80.48% 14 Missing and 10 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #695      +/-   ##
==========================================
+ Coverage   88.14%   88.36%   +0.22%     
==========================================
  Files         119      119              
  Lines        5837     5941     +104     
==========================================
+ Hits         5145     5250     +105     
+ Misses        500      493       -7     
- Partials      192      198       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lyt122 lyt122 marked this pull request as draft August 23, 2024 14:16
@lyt122 lyt122 force-pushed the main branch 2 times, most recently from 7909392 to 6bc3642 Compare August 25, 2024 15:58
feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry

feat: add consul as serviceRegistry
@lyt122 lyt122 marked this pull request as ready for review August 26, 2024 01:49
Copy link
Member

@spacewander spacewander left a comment

Choose a reason for hiding this comment

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

It seems the test is not stable? I rerun it and it fails.


service := map[string]any{
"Node": "node1", // 指定节点名称
"Address": ip, // 节点IP地址
Copy link
Member

Choose a reason for hiding this comment

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

Let's use English comment


serviceID := name + ip + port
body := map[string]any{
"Node": "node1", // 指定节点名称
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

@@ -17,6 +17,23 @@ services:
- "8849:8848"
networks:
service:
consul:
image: docker.m.daocloud.io/library/consul:1.10.8
Copy link
Member

Choose a reason for hiding this comment

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

Could we use the latest image (1.15.4)?

controller/registries/consul/config.go Show resolved Hide resolved
controller/registries/consul/config.go Show resolved Hide resolved
controller/registries/consul/config.go Show resolved Hide resolved
if err != nil {
reg.logger.Errorf("failed to subscribe service, err: %v, service: %v", err, service.ServiceName)
delete(serviceMap, service)
delete(reg.watchingServices, service)
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to delete service from reg.watchingServices if _, ok := reg.watchingServices[service]; !ok

var host string
suffix := strings.Join([]string{reg.client.NameSpace, reg.client.DataCenter, reg.name, RegistryType}, ".")
suffix = strings.ReplaceAll(suffix, "_", "-")
if len(tag) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Join an empty string is harmless as we will remove the repeated dots below. We can remove an extra branch.

@lyt122 lyt122 marked this pull request as draft August 26, 2024 04:23
@lyt122 lyt122 marked this pull request as ready for review August 26, 2024 14:29
@lyt122
Copy link
Contributor Author

lyt122 commented Aug 26, 2024

@spacewander

name: "test_registry",
}

// 测试用例
Copy link
Member

Choose a reason for hiding this comment

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

Let's use English

@spacewander spacewander merged commit c0e2633 into mosn:main Aug 27, 2024
13 checks passed
@spacewander
Copy link
Member

Merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants