Open-Source Wikis

/

etcd

/

Cleanup opportunities

/

Complexity hotspots

etcd-io/etcd

Complexity hotspots

The largest hand-written Go files in the repo. Generated *.pb.go files dominate the absolute leaderboard but they're not actionable; this page only covers files an engineer would actually edit.

Lines File
2,476 server/etcdserver/server.go
2,215 tests/integration/v3_grpc_test.go
2,150 tests/robustness/validate/validate_test.go
1,802 tests/integration/clientv3/lease/leasing_test.go
1,715 tests/integration/cache_test.go
1,703 tests/framework/integration/cluster.go
1,585 tests/integration/clientv3/watch/v3_watch_test.go
1,576 server/etcdserver/server_test.go
1,402 server/embed/config.go
1,290 server/etcdserver/v3_server.go
1,238 server/auth/store.go

Comments

  • server/etcdserver/server.goEtcdServer's home. It has been refactored repeatedly (apply pipeline, version manager, downgrade handling all moved out). Further extraction candidates: cluster-version negotiation and the corruption guard.
  • server/embed/config.go — every CLI flag plus the YAML file mapping. Hard to split without breaking the public embed.Config shape; some grouping per concern (logging, tracing, gateway, proxy, ...) would help readers.
  • server/etcdserver/v3_server.go — orchestrates RPC entry → Raft propose → apply. Tightly coupled to server.go; refactors usually touch both.
  • server/auth/store.go — the authStore plus permissions cache wiring; the permissions cache file (range_perm_cache.go) was already extracted, but the store itself still mixes user/role state, persistence, and token lifecycle.
  • tests/framework/integration/cluster.go — the in-process cluster fixture; long because every framework feature lives here.

Why "complexity" is not just line count

The file-size metric is a rough proxy. Some of the largest files (server.go, config.go) are intentionally large because they are the "public" surface for their respective concepts — splitting them would scatter the documentation that godoc consumers expect to find together. Where the project has split, it has done so with care:

  • apply/ extraction from server.go (3.6).
  • etcdserver/version/ for cluster-version logic.
  • etcdserver/txn/ for transaction evaluation.
  • pkg/featuregate/ from various ad-hoc flag-toggle code.

Tooling

  • cyclop and gocyclo lint metrics are enabled in tools/.golangci.yaml (with conservative thresholds).
  • tools/etcd-dump-metrics/ indirectly exercises the largest non-test file (server.go) by booting a member and asserting on the registered metrics.

Cross-references

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Complexity hotspots – etcd wiki | Factory