Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework background task initialization #5962

Merged
merged 36 commits into from
Jun 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fc933eb
phase one: move specific task implementations into submodule
davepacheco Jun 21, 2024
79036c4
phase two: rework imports
davepacheco Jun 21, 2024
7472be7
reorganize the top-level code a bit
davepacheco Jun 24, 2024
c259409
rustfmt
davepacheco Jun 24, 2024
2303eea
wrap too-long strings in background task subsystem
davepacheco Jun 24, 2024
ee8bac5
task name consistency; avoid using driver.activate() directly
davepacheco Jun 24, 2024
87d6d8b
BackgroundTasks: initial cleanup
davepacheco Jun 25, 2024
257f18d
TaskHandle -> TaskName
davepacheco Jun 25, 2024
df3c5f2
Merge branch 'main' into dap/bgtask-init
davepacheco Jun 26, 2024
db53953
Merge branch 'dap/bgtask-init' into dap/bgtask-cleanup
davepacheco Jun 26, 2024
4b0546b
Merge branch 'dap/bgtask-cleanup' into dap/bgtask-cleanup-at-large
davepacheco Jun 26, 2024
23ad49e
Merge commit '6e29409c04fb701dd6a9abfafe76c80a4b07f7d2' into dap/bgta…
davepacheco Jun 26, 2024
86bd174
Merge commit '49f6e01001462fe31c09c83ce423dc73cc3cc1ce' into dap/bgta…
davepacheco Jun 26, 2024
56222ab
Merge branch 'dap/bgtask-cleanup' into dap/bgtask-cleanup-at-large
davepacheco Jun 26, 2024
0449bf4
WIP: reworking initialization (still lots of stuff to fix up)
davepacheco Jun 26, 2024
4f058f3
WIP: flesh it out more
davepacheco Jun 26, 2024
e4cd06a
Merge remote-tracking branch 'origin/dap/bgtask-cleanup-at-large' int…
davepacheco Jun 26, 2024
143c5d6
Merge commit 'd9e638a791edfd199fd896df45f73d5edf2e6d87' into dap/bgta…
davepacheco Jun 26, 2024
af4475e
Merge commit 'ff0c914753022a057d6443540ec3641b35654461' into dap/bgta…
davepacheco Jun 26, 2024
9c47188
Merge commit 'd52aad08c6b77c7dc9dd2e0f3050e4b73faf20fb' into dap/bgta…
davepacheco Jun 26, 2024
bae3fad
Merge commit 'b3a1a72951bd92f6fcfb04b21766a4535f0e1ddb' into dap/bgta…
davepacheco Jun 26, 2024
e004240
Merge commit '931e2d457c7bf9ad40e4475d78db1aa81938ea70' into dap/bgta…
davepacheco Jun 26, 2024
3a7f5c5
Merge remote-tracking branch 'origin/main' into dap/bgtask-init-rework
davepacheco Jun 26, 2024
87160da
use OnceLock; defer the arguments to start()
davepacheco Jun 26, 2024
85eff7a
fix up ExternalEndpoints test code
davepacheco Jun 26, 2024
a8e9629
make Activator non-optional
davepacheco Jun 27, 2024
e35fbde
flesh out some docs
davepacheco Jun 27, 2024
1664e0d
doc comment editing
davepacheco Jun 27, 2024
aefe765
move Activator; continue editing docs
davepacheco Jun 27, 2024
f991eec
fixups
davepacheco Jun 27, 2024
92ee2cd
doc fixup
davepacheco Jun 27, 2024
20f7c41
exercise Activator in tests
davepacheco Jun 27, 2024
0883358
that should be a 503
davepacheco Jun 27, 2024
249ee59
fix omdb test output
davepacheco Jun 27, 2024
1dcf10f
review feedback
davepacheco Jun 28, 2024
514e2b2
start background tasks even if populate fails (see 5980)
davepacheco Jun 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
exercise Activator in tests
  • Loading branch information
davepacheco committed Jun 27, 2024
commit 20f7c41bcc3514da419a392454415ddcd87671f9
15 changes: 11 additions & 4 deletions nexus/src/app/background/driver.rs
Original file line number Diff line number Diff line change
@@ -89,7 +89,6 @@ impl Driver {
/// `activator` is an [`Activator`] that has not previously been used in a
/// call to this function. It will be wired up so that using it will
/// activate this newly-registered background task.
// XXX-dap TODO-coverage activator
#[allow(clippy::too_many_arguments)]
hawkw marked this conversation as resolved.
Show resolved Hide resolved
pub fn register(
&mut self,
@@ -99,9 +98,6 @@ impl Driver {
imp: Box<dyn BackgroundTask>,
opctx: OpContext,
watchers: Vec<Box<dyn GenericWatcher>>,
// XXX-dap can we do something about TaskName? It's only used by the
// tests, too. It's nice to have it for sure but is it really
// necessary?
activator: &Activator,
) -> TaskName {
// Activation of the background task happens in a separate tokio task.
@@ -586,6 +582,17 @@ mod test {
let status = driver.task_status(&h3);
let last = status.last.unwrap_completion();
assert_eq!(last.iteration, 4);

// Explicitly activate just "t2", this time using its Activator.
act2.activate();
wait_until_count(rx2.clone(), 3).await;
assert_eq!(*rx3.borrow(), 4);
let status = driver.task_status(&h2);
let last = status.last.unwrap_completion();
assert_eq!(last.iteration, 3);
let status = driver.task_status(&h3);
let last = status.last.unwrap_completion();
assert_eq!(last.iteration, 4);
}

/// Simple background task that moves in lockstep with a consumer, allowing