Skip to main content

risingwave_common/config/
role.rs

1// Copyright 2026 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
15//! Role for compute node and hummock.
16
17use clap::ValueEnum;
18use serde::{Deserialize, Serialize};
19
20/// Role of the compute node or hummock storage.
21#[derive(Copy, Clone, Debug, Default, ValueEnum, Serialize, Deserialize)]
22pub enum Role {
23    /// Serving role
24    Serving,
25    /// Streaming role
26    Streaming,
27    /// Both serving and streaming role
28    #[default]
29    Both,
30    /// No specific role, mostly for temporary usage like risectl or testing.
31    #[value(skip)]
32    None,
33}
34
35impl Role {
36    pub fn for_streaming(&self) -> bool {
37        match self {
38            Role::Serving => false,
39            Role::Streaming => true,
40            Role::Both => true,
41            Role::None => false,
42        }
43    }
44
45    pub fn for_serving(&self) -> bool {
46        match self {
47            Role::Serving => true,
48            Role::Streaming => false,
49            Role::Both => true,
50            Role::None => false,
51        }
52    }
53}