Skip to main content

microsandbox_db/entity/
memory_allocation_node.rs

1//! Entity definition for cooperative per-NUMA-node memory promises.
2
3use sea_orm::entity::prelude::*;
4
5//--------------------------------------------------------------------------------------------------
6// Types
7//--------------------------------------------------------------------------------------------------
8
9/// One guest proximity domain backed by a host NUMA node under an active allocation lease.
10#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
11#[sea_orm(table_name = "memory_allocation_node")]
12pub struct Model {
13    /// Parent CPU/allocation lease identifier.
14    #[sea_orm(primary_key, auto_increment = false)]
15    pub allocation_id: String,
16    /// Dense guest proximity-domain identifier.
17    #[sea_orm(primary_key, auto_increment = false)]
18    pub guest_numa_node: i32,
19    /// Host NUMA node selected by the planner.
20    pub host_numa_node: i32,
21    /// Guest memory online at boot, in MiB.
22    pub boot_mib: i64,
23    /// Maximum memory promised to this guest node, in MiB.
24    pub max_mib: i64,
25}
26
27/// Relations for a memory-node promise.
28#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
29pub enum Relation {
30    /// The memory promise belongs to one allocation lease.
31    #[sea_orm(
32        belongs_to = "super::cpu_allocation::Entity",
33        from = "Column::AllocationId",
34        to = "super::cpu_allocation::Column::Id",
35        on_delete = "Cascade"
36    )]
37    Allocation,
38}
39
40//--------------------------------------------------------------------------------------------------
41// Trait Implementations
42//--------------------------------------------------------------------------------------------------
43
44impl Related<super::cpu_allocation::Entity> for Entity {
45    fn to() -> RelationDef {
46        Relation::Allocation.def()
47    }
48}
49
50impl ActiveModelBehavior for ActiveModel {}