mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 20:07:56 +00:00
add simple name derivation heuristic for JobManager Subsystem impl (#1490)
Subsystems are encouraged to either typedef themselves as appropriate `JobManager` instances for their job type, or wrap a `JobManager` instance and delegate the `Subsystem` impl. In both cases, we want to use a sensible, non-repeated subsystem name for appropriate logging and debugging. This PR adds a heuristic: if the job name ends in the literal "Job", then that gets stripped. Otherwise, the job name is used. This improves on the previous situation, in which subsystems typedef'd to or wrapping `JobManager` all got the same constant (!) name.
This commit is contained in:
committed by
GitHub
parent
45d17beb8e
commit
bcfd6c2d3a
@@ -715,7 +715,7 @@ where
|
||||
});
|
||||
|
||||
SpawnedSubsystem {
|
||||
name: "JobManager",
|
||||
name: Job::NAME.strip_suffix("Job").unwrap_or(Job::NAME),
|
||||
future,
|
||||
}
|
||||
}
|
||||
@@ -737,6 +737,8 @@ mod tests {
|
||||
ActiveLeavesUpdate,
|
||||
FromOverseer,
|
||||
OverseerSignal,
|
||||
SpawnedSubsystem,
|
||||
Subsystem,
|
||||
};
|
||||
use futures::{
|
||||
channel::mpsc,
|
||||
@@ -959,4 +961,16 @@ mod tests {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_subsystem_impl_and_name_derivation() {
|
||||
let pool = sp_core::testing::TaskExecutor::new();
|
||||
let (context, _) = make_subsystem_context::<CandidateSelectionMessage, _>(pool.clone());
|
||||
|
||||
let SpawnedSubsystem { name, .. } = FakeCandidateSelectionSubsystem::new(
|
||||
pool,
|
||||
HashMap::new(),
|
||||
).start(context);
|
||||
assert_eq!(name, "FakeCandidateSelection");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user