Skip to content

[GSOC] Add discovery provider registry and address store#1126

Open
CAICAIIs wants to merge 3 commits into
apache:masterfrom
CAICAIIs:gsoc-pr1-discovery-provider-store
Open

[GSOC] Add discovery provider registry and address store#1126
CAICAIIs wants to merge 3 commits into
apache:masterfrom
CAICAIIs:gsoc-pr1-discovery-provider-store

Conversation

@CAICAIIs

Copy link
Copy Markdown
Contributor

What changed

This PR implements the PR1 discovery/registry groundwork from the GSoC plan.

  • Add a small provider registry for registry types already present in seata-go: file, etcd/etcd3, raft, and namingserver.
  • Add InitRegistryWithError so init failures can be returned to callers. InitRegistry still panics on error to keep the existing behavior.
  • Add AddressStore as the registry-owned snapshot store for service instances, keyed by cluster.
  • Move etcd3 lookup and watch updates through AddressStore while keeping the existing key/value parsing and lookup behavior.

Out of scope

This PR does not add Nacos, ZooKeeper, Consul, or Redis clients. It also leaves seata-ctl integration and SessionManager connection updates for later PRs.

Tests

  • go test ./pkg/discovery -run 'Test(File|Etcd|Init|AddressStore|RegistryProvider|Naming|Raft)'
  • go test ./pkg/discovery
  • go test ./pkg/discovery -run TestAddressStoreConcurrentUpdateSnapshot -race
  • git diff --check

@github-actions github-actions Bot added enhancement New feature or request coding labels Jun 16, 2026
@codecov-commenter

codecov-commenter commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.44371% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.56%. Comparing base (84c991f) to head (e400bf2).

Files with missing lines Patch % Lines
pkg/discovery/store.go 84.53% 7 Missing and 8 partials ⚠️
pkg/discovery/etcd3.go 55.55% 5 Missing and 3 partials ⚠️
pkg/discovery/provider.go 91.30% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1126      +/-   ##
==========================================
+ Coverage   58.36%   58.56%   +0.19%     
==========================================
  Files         282      284       +2     
  Lines       19405    19486      +81     
==========================================
+ Hits        11326    11412      +86     
+ Misses       7102     7087      -15     
- Partials      977      987      +10     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pkg/discovery/etcd3.go
Comment thread pkg/discovery/init.go
registryService, err := provider(serviceConfig, registryConfig)
if err != nil {
panic(fmt.Errorf("init service registry err:%v", err))
return err

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

这里失败时会保留旧的 registryServiceInstance。看上去是为了兼容旧 InitRegistry 的 panic 语义?但 InitRegistryWithError 作为新 API,最好再补个测试明确一下:已有 registry 后再初始化失败,GetRegistry 应该继续返回旧实例or变成 nil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ok, new commit resolved this

@AsperforMias

Copy link
Copy Markdown

basically, seems LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coding enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants