microsandbox_db/entity/writeback_allocation.rs
1//! Entity definition for active host-global writeback pressure members.
2
3use sea_orm::entity::prelude::*;
4
5//--------------------------------------------------------------------------------------------------
6// Types
7//--------------------------------------------------------------------------------------------------
8
9/// One active dirty-credit pool member owned by a sandbox run.
10#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
11#[sea_orm(table_name = "writeback_allocation")]
12pub struct Model {
13 /// Cryptographically random allocation identifier.
14 #[sea_orm(primary_key, auto_increment = false)]
15 pub id: String,
16 /// Run that originally acquired the membership.
17 ///
18 /// This is deliberately not a foreign key: crash recovery must retain membership even if
19 /// lifecycle cleanup removes the run row before another runtime can inspect the stale lease.
20 pub run_id: i32,
21 /// Owner-only lock-file basename held for the process lifetime.
22 pub lease_name: String,
23 /// Maximum limit passed to each eligible writable raw disk.
24 pub per_disk_limit_bytes: i64,
25 /// Number of disks represented by this membership.
26 pub disk_count: i32,
27 /// Requested maximum across all disks, retained for schema compatibility and diagnostics.
28 pub reserved_bytes: i64,
29 /// Host-global pool requested when the membership was created.
30 pub pool_bytes: i64,
31 /// Linux boot identifier recorded when the member joined the pressure pool.
32 pub boot_id: String,
33 /// Sorted Linux backing-filesystem device identities (`major:minor`, comma-separated).
34 pub backing_devices: String,
35 /// Allocation creation time.
36 pub created_at: DateTime,
37}
38
39/// Writeback memberships intentionally have no cascading database relation.
40#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
41pub enum Relation {}
42
43//--------------------------------------------------------------------------------------------------
44// Trait Implementations
45//--------------------------------------------------------------------------------------------------
46
47impl ActiveModelBehavior for ActiveModel {}