Skip to content

[High] ClusterState 40-field God Struct needs decomposition #971

@piwi3910

Description

@piwi3910

Codebase Review Round 2 — Finding #10

Severity: High
Location: config.rs:85-156

Problem

ClusterState is a 40-field flat struct that serves as the central configuration object. This "God Struct" anti-pattern makes the code hard to understand, test, and extend. Tests that construct ClusterState require 47 lines of boilerplate to set all fields.

Impact

  • Adding new features requires modifying a 40+ field struct
  • Test setup is verbose and fragile (any new field breaks all test constructors)
  • No logical grouping makes it hard to understand which fields relate to which subsystem

Fix

  • Decompose into logical sub-structs: TlsConfig, RateLimitConfig, WafConfig, MeshConfig, ObservabilityConfig, etc.
  • Implement Default for each sub-struct to reduce test boilerplate
  • ClusterState becomes a composition of these sub-structs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions