refactor: [#296] Phase 2: Create DockerComposeTopology Aggregate (P2.1, P2.2) #297
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Phase 2: Create DockerComposeTopology Aggregate
Issue: #296
Epic: #287 (Docker Compose Topology Domain Model Refactoring)
Summary
This PR implements Phase 2 of the Docker Compose Topology refactoring, introducing the
DockerComposeTopologyaggregate and establishing the single source of truth pattern for network derivation.Changes
P2.1: Service Enum and Aggregate
Serviceenum (src/domain/topology/service.rs): Type-safe service identification with 5 variants:Tracker- Core BitTorrent trackerMySQL- Database servicePrometheus- Metrics collectionGrafana- VisualizationCaddy- TLS proxyDockerComposeTopologyaggregate (src/domain/topology/aggregate.rs):ServiceTopologyentriesrequired_networks()from service configurationsServiceTopologystruct: Links services to their network assignmentsP2.2: Network Derivation in Context and Template
NetworkDefinitiontype (context/network_definition.rs): Template-friendly network representationContext updates (
context/mod.rs,context/builder.rs):required_networksfield toDockerComposeContextderive_required_networks()method in builderTemplate update (
docker-compose.yml.tera):required_networksloop{%- if mysql %}\n database_network:\n driver: bridge\n{%- endif %}{%- for net in required_networks %}\n {{ net.name }}:\n driver: {{ net.driver }}\n{%- endfor %}Test Coverage
DockerComposeTopologyaggregateServiceenumNetworkDefinitionrequired_networksderivation in contextBehavioral Equivalence
The generated
docker-compose.ymloutput is functionally identical before and after this change. The only difference is implementation: networks are now derived from service configurations rather than duplicated in template conditionals.Files Changed
src/domain/topology/service.rssrc/domain/topology/aggregate.rssrc/domain/topology/mod.rssrc/domain/mod.rscontext/network_definition.rscontext/mod.rscontext/builder.rsdocker-compose.yml.teraProgress Update
After this PR: