split the DebugCollector into different modules #9493
Merged
+556
−409
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.
tl;dr for reviewers: this change is mostly just code movement. The one non-movement change I made (which is still pretty trivial) was changing the return type of
ZoneInvoker::get_zones()fromArchiveLogsErrortoZoneError. This was just a change to the return type -- nothing else changed because we already had a conversion fromZoneErrortoArchiveLogsErrorthat callers who wanted that can use.My goal with this PR is to clarify the structure within the DebugCollector. Today, there's a chain of several things that work together:
DebugCollectorTaskis a tokio task that takes requests from the rest of sled agent and usesDebugCollector(which is really a handle) to send them toDebugCollectorWorker(which does all the work) and wait for responses. This was split into two modules at the top level ofsled-agent/config-reconciler:debug_collector_task.rs: containsDebugCollectorTaskand a related structFormerZoneRootArchiver. These are sort of the external interface to the debug collector.debug_collector.rs: contains theDebugCollector(handle), theDebugCollectorWorker(which does all the real work), all the tests, and a bunch of helper traits and impls that are mainly used for dependency injectionI've separated things differently here. First, from the parent crate's perspective, this is now all consolidated into one
debug_collectormodule. It's now a directory, not a file. Within it there's:task.rscontainsDebugCollectorTaskandFormerZoneRootArchiverhandle.rscontainsDebugCollectorworker.rscontainsDebugCollectorWorkerand all the testshelpers.rscontains the dependency injection traits, their "real" impls, and some supporting typesI also added a detailed comment to
debug_collector/mod.rsthat explains the structure.I think this makes each module a lot simpler to understand. In future work I plan to factor out more of the worker implementation and it'll be important to be able to separate pieces into different files, still all within the
debug_collectormodule.Staged on top of #9484.