-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable deeper insights while filtering items to install (#73)
- Loading branch information
1 parent
ea7c973
commit a447b57
Showing
4 changed files
with
158 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/talos_cohort_replicator/src/utils/installer_utils.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use ahash::RandomState; | ||
use indexmap::IndexMap; | ||
|
||
use crate::core::{StatemapInstallState, StatemapInstallerHashmap}; | ||
|
||
pub fn is_queue_item_state_match(state: StatemapInstallState) -> impl FnMut(&&StatemapInstallerHashmap) -> bool { | ||
move |x| x.state == state | ||
} | ||
pub fn is_queue_item_above_version<'a>(version: &'a u64) -> impl FnMut(&&'a StatemapInstallerHashmap) -> bool { | ||
move |x| { | ||
// If no safepoint, this could be a abort item and is safe to install as statemap will be empty. | ||
let Some(safepoint) = x.safepoint else { | ||
return true; | ||
}; | ||
|
||
version >= &safepoint | ||
} | ||
} | ||
pub fn is_queue_item_serializable<'a>(queue: &'a IndexMap<u64, StatemapInstallerHashmap, RandomState>) -> impl FnMut(&&'a StatemapInstallerHashmap) -> bool { | ||
move |x| { | ||
// If no safepoint, this could be a abort item and is safe to install as statemap will be empty. | ||
let Some(safepoint) = x.safepoint else { | ||
return true; | ||
}; | ||
|
||
// If there is no version matching the safepoint, then it is safe to install | ||
let Some(safepoint_pointing_item) = queue.get(&safepoint) else { | ||
return true; | ||
}; | ||
safepoint_pointing_item.state == StatemapInstallState::Installed | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pub(crate) mod installer_utils; | ||
mod replicator_utils; | ||
|
||
pub use replicator_utils::*; |