Skip to content

Commit a9152da

Browse files
committed
Refactor server related code in its own module.
1 parent 4c9c06e commit a9152da

File tree

5 files changed

+689
-651
lines changed

5 files changed

+689
-651
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use stackable_operator::kvp::ObjectLabels;
2+
use strum::Display;
3+
4+
use crate::{
5+
connect::crd::{CONNECT_CONTROLLER_NAME, CONNECT_SERVER_ROLE_NAME},
6+
crd::constants::{APP_NAME, OPERATOR_NAME},
7+
};
8+
9+
const DUMMY_SPARK_CONNECT_GROUP_NAME: &str = "default";
10+
11+
pub fn labels<'a, T>(scs: &'a T, app_version_label: &'a str, role: &'a str) -> ObjectLabels<'a, T> {
12+
ObjectLabels {
13+
owner: scs,
14+
app_name: APP_NAME,
15+
app_version: app_version_label,
16+
operator_name: OPERATOR_NAME,
17+
controller_name: CONNECT_CONTROLLER_NAME,
18+
role,
19+
role_group: DUMMY_SPARK_CONNECT_GROUP_NAME,
20+
}
21+
}
22+
23+
// The dead code annotation is to shut up complains about missing Executor instantiations
24+
// These will come in the future.
25+
#[allow(dead_code)]
26+
#[derive(Clone, Debug, Display)]
27+
#[strum(serialize_all = "lowercase")]
28+
pub enum SparkConnectRole {
29+
Server,
30+
Executor,
31+
}
32+
33+
pub fn object_name(stacklet_name: &str, role: SparkConnectRole) -> String {
34+
match role {
35+
SparkConnectRole::Server => format!("{}-{}", stacklet_name, CONNECT_SERVER_ROLE_NAME),
36+
SparkConnectRole::Executor => todo!(),
37+
}
38+
}

0 commit comments

Comments
 (0)