Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion crates/cost/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ serde_json = "1"

[dev-dependencies]
# The executor's charge for each summary state, checked against the bytes
# the state byte models give for it plus the accumulator's own fields (#947).
# the state byte models give for it plus the accumulator's own fields, and
# against priced bytes on seeded workload data (#947).
asap-executor = { path = "../executor" }
13 changes: 13 additions & 0 deletions crates/cost/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,19 @@ pub enum CostModel {
ClusterCapacity(ClusterLimits),
}

impl CostModel {
/// The per-unit costs each node's usage is priced with. Only cost
/// model 1 prices per node: `UsageOverTime(u)` gives `Some(&u)`. Cost
/// model 2 prices the plan's peaks (in `plan_cost`), not each node, and
/// cost model 3 has no prices, so both give `None`.
pub fn per_node_unit_costs(&self) -> Option<&ResourceUnitCost> {
match self {
CostModel::UsageOverTime(unit_cost) => Some(unit_cost),
CostModel::ProvisionedCapacity(_) | CostModel::ClusterCapacity(_) => None,
}
}
}

/// A fixed cluster's capacity (cost model 3) and how to choose within it.
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(deny_unknown_fields)]
Expand Down
Loading
Loading