risingwave_meta_model/
actor.rs

1// Copyright 2025 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 risingwave_pb::meta::table_fragments::actor_status::PbActorState;
16use sea_orm::entity::prelude::*;
17use serde::{Deserialize, Serialize};
18
19use crate::{ActorId, ConnectorSplits, ExprContext, FragmentId, VnodeBitmap, WorkerId};
20
21#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
22#[sea_orm(rs_type = "String", db_type = "string(None)")]
23pub enum ActorStatus {
24    #[sea_orm(string_value = "INACTIVE")]
25    Inactive,
26    #[sea_orm(string_value = "RUNNING")]
27    Running,
28}
29
30impl From<PbActorState> for ActorStatus {
31    fn from(val: PbActorState) -> Self {
32        match val {
33            PbActorState::Unspecified => unreachable!(),
34            PbActorState::Inactive => ActorStatus::Inactive,
35            PbActorState::Running => ActorStatus::Running,
36        }
37    }
38}
39
40impl From<ActorStatus> for PbActorState {
41    fn from(val: ActorStatus) -> Self {
42        match val {
43            ActorStatus::Inactive => PbActorState::Inactive,
44            ActorStatus::Running => PbActorState::Running,
45        }
46    }
47}
48
49#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
50pub struct ActorModel {
51    pub actor_id: ActorId,
52    pub fragment_id: FragmentId,
53    pub status: ActorStatus,
54    pub splits: ConnectorSplits,
55    pub worker_id: WorkerId,
56    pub vnode_bitmap: Option<VnodeBitmap>,
57    pub expr_context: ExprContext,
58}