risingwave_meta_model/
streaming_job.rs1use std::collections::HashMap;
16
17use risingwave_common::id::JobId;
18use risingwave_pb::id::FragmentId;
19use sea_orm::FromJsonQueryResult;
20use sea_orm::entity::prelude::*;
21use serde::{Deserialize, Serialize};
22
23use crate::{CreateType, JobStatus, StreamingParallelism, derive_from_json_struct};
24
25#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
26#[sea_orm(table_name = "streaming_job")]
27pub struct Model {
28 #[sea_orm(primary_key, auto_increment = false)]
29 pub job_id: JobId,
30 pub job_status: JobStatus,
31 pub create_type: CreateType,
32 pub timezone: Option<String>,
33 pub config_override: Option<String>,
35 pub adaptive_parallelism_strategy: Option<String>,
36 pub parallelism: StreamingParallelism,
37 pub backfill_parallelism: Option<StreamingParallelism>,
38 pub backfill_adaptive_parallelism_strategy: Option<String>,
39 #[sea_orm(column_type = "JsonBinary", nullable)]
40 pub backfill_orders: Option<BackfillOrders>,
41 pub max_parallelism: i32,
42 pub specific_resource_group: Option<String>,
43 pub is_serverless_backfill: bool,
44 pub refresh_interval_sec: Option<i64>,
45}
46
47derive_from_json_struct!(BackfillOrders, HashMap<FragmentId, Vec<FragmentId>>);
56
57#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
58pub enum Relation {
59 #[sea_orm(
60 belongs_to = "super::object::Entity",
61 from = "Column::JobId",
62 to = "super::object::Column::Oid",
63 on_update = "NoAction",
64 on_delete = "Cascade"
65 )]
66 Object,
67}
68
69impl Related<super::object::Entity> for Entity {
70 fn to() -> RelationDef {
71 Relation::Object.def()
72 }
73}
74
75impl ActiveModelBehavior for ActiveModel {}