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

Move Nexus notification to standalone task #1584

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mkeeter
Copy link
Contributor

@mkeeter mkeeter commented Dec 5, 2024

Previously, we would spawn a new tokio::task in the Downstairs to do an async notification to Nexus, iff the notify-nexus feature was enabled. This is awkward for a few reasons:

  • Spawning tasks in an otherwise-synchronous function can be surprising (since it implicitly requires a tokio runtime)
  • It requires importing a bunch of Nexus types into the mod downstairs
  • This code was only compiled if notify-nexus is enabled, which means that it's easy to have something that builds locally but fails in CI
  • There's a bunch of duplicate logging, because each function notifies Nexus separately

This PR moves Nexus notifications to a separate notify module, which runs a single task to do these notifications in one place. It communicates to the rest of Crucible through a queue; if the queue fills up, we log and discard the notification request (since this is best-effort).

All of this code is always compiled; we check the feature (using cfg!(feature = "notify-nexus") to determine whether it's actually enabled. This module is responsible for translating into Nexus types, so they don't leak into the rest of the codebase.

repair_id: reconcile_id,
// surely we won't have usize::MAX extents
current_item: current_task as i64,
// i am serious, and don't call me shirley
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✈️

upstairs/src/downstairs.rs Outdated Show resolved Hide resolved

repairs.push(DownstairsUnderRepair {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit of a shame to change this struct into a tuple, but I wouldn't block the PR for it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but it is intentional; I wanted to remove Nexus-flavored types from every module except notify.rs. We could add a new intermediate-type, but probably not worth it...

upstairs/src/notify.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants