refactor(#2591): make NodeKind the queue payload — drop JobPayload, agent into variants
This commit is contained in:
parent
2294cd4516
commit
be2dfa8cd3
8 changed files with 233 additions and 177 deletions
|
|
@ -1,8 +1,8 @@
|
|||
//! The concrete resource + payload types the rebuild queue schedules over —
|
||||
//! the bridge from hive-c0re's [`NodeKind`] onto the domain-agnostic
|
||||
//! `hive-jobq` crate. `hive-jobq` is generic over a resource type
|
||||
//! `R: Clone + Eq + Hash` and a node payload `N`; here `R` is [`Resource`] and
|
||||
//! `N` is [`JobPayload`].
|
||||
//! The concrete resource type the rebuild queue schedules over — the bridge
|
||||
//! from hive-c0re's [`NodeKind`] onto the domain-agnostic `hive-jobq` crate.
|
||||
//! `hive-jobq` is generic over a resource type `R: Clone + Eq + Hash` and a node
|
||||
//! payload `N`; here `R` is [`Resource`] and `N` is [`NodeKind`] directly (each
|
||||
//! variant carries the agent it targets).
|
||||
|
||||
use hive_jobq::Dep;
|
||||
|
||||
|
|
@ -24,16 +24,7 @@ pub enum Resource {
|
|||
Agent(String),
|
||||
}
|
||||
|
||||
/// A schedulable node's payload — the crate's generic `N`. Carries the
|
||||
/// primitive operation and the agent it targets. The agent is per-node (a DAG
|
||||
/// spans agents), and the lease [`Resource::Agent`] is keyed on it.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct JobPayload {
|
||||
pub kind: NodeKind,
|
||||
pub agent: String,
|
||||
}
|
||||
|
||||
impl JobPayload {
|
||||
impl NodeKind {
|
||||
/// The [`Dep::Resource`] edges this node must acquire to run, derived from
|
||||
/// its kind + agent: a build slot for nix-heavy kinds
|
||||
/// ([`NodeKind::needs_build_slot`]) and the agent lease for
|
||||
|
|
@ -43,15 +34,15 @@ impl JobPayload {
|
|||
/// `Agent` lock through the crate's recursive re-entrancy.
|
||||
pub fn resource_deps(&self) -> Vec<Dep<Resource>> {
|
||||
let mut deps = Vec::new();
|
||||
if self.kind.needs_build_slot() {
|
||||
if self.needs_build_slot() {
|
||||
deps.push(Dep::Resource {
|
||||
name: Resource::BuildSlot,
|
||||
count: 1,
|
||||
});
|
||||
}
|
||||
if self.kind.needs_lease() {
|
||||
if self.needs_lease() {
|
||||
deps.push(Dep::Resource {
|
||||
name: Resource::Agent(self.agent.clone()),
|
||||
name: Resource::Agent(self.agent().to_owned()),
|
||||
count: 1,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue