Skip to main content

risingwave_meta_model/
worker_property.rs

1// Copyright 2024 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use sea_orm::entity::prelude::*;
16use serde::{Deserialize, Serialize};
17
18use crate::{WorkerId, WorkerResource};
19
20#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
21#[sea_orm(table_name = "worker_property")]
22pub struct Model {
23    #[sea_orm(primary_key, auto_increment = false)]
24    pub worker_id: WorkerId,
25    pub parallelism: i32,
26    pub is_streaming: bool,
27    pub is_serving: bool,
28    pub is_unschedulable: bool,
29    pub internal_rpc_host_addr: Option<String>,
30    pub resource_group: Option<String>,
31    pub is_iceberg_compactor: bool,
32    pub resource: Option<WorkerResource>,
33    pub started_at: Option<i64>,
34}
35
36#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
37pub enum Relation {
38    #[sea_orm(
39        belongs_to = "super::worker::Entity",
40        from = "Column::WorkerId",
41        to = "super::worker::Column::WorkerId",
42        on_update = "NoAction",
43        on_delete = "Cascade"
44    )]
45    Worker,
46}
47
48impl Related<super::worker::Entity> for Entity {
49    fn to() -> RelationDef {
50        Relation::Worker.def()
51    }
52}
53
54impl ActiveModelBehavior for ActiveModel {}