Skip to content

Commit

Permalink
feat: add core type and kube driver api
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin committed Jun 13, 2024
1 parent dfcdf8b commit 25a9727
Show file tree
Hide file tree
Showing 17 changed files with 457 additions and 334 deletions.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ anyhow = "1.0.86"
serde = {version ="1.0.203", features = ["derive"]}
serde_json = {version = "1.0.117"}
bimap = "0.6.3"
uuid = {version="1.8.0", features = ["v4","serde"]}
uuid = {version="1.8.0", features = ["v4","serde"]}
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
kube = { version = "0.91.0", features = ["runtime", "derive"] }
k8s-openapi = { version = "0.22.0", features = ["latest"] }

[dev-dependencies]
arrayvec = {version="0.7.4", features= ["serde"]}
28 changes: 0 additions & 28 deletions docs/graph.json

This file was deleted.

87 changes: 87 additions & 0 deletions docs/详细设计.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# 详细设计


## spec配置定义
```json
{
"name": "example",
"version": "v1",
"dag": [
{
"id": "5c42b900-a87f-45e3-ba06-c40d94ad5ba2",
"name": "ComputeUnit1",
"dependency": [

],
"spec": {
"cmd": [
"ls"
],
"image": ""
},
"channel": {
"spec": {
"cmd": [
"bufsize",
"1024"
],
"image": "jiaozifs:"
}
}
},
{
"id": "353fc5bf-697e-4221-8487-6ab91915e2a1",
"name": "ComputeUnit2",
"node_type": "ComputeUnit",
"dependency": [
"5c42b900-a87f-45e3-ba06-c40d94ad5ba2"
],
"spec": {
"cmd": [
"ls"
],
"image": ""
}
}
]
}
```

## Graph

1. 节点= 节点+数据管道(可选)

## job 控制器

追踪整个job的运行状态,处理重试,日志,状态收集的问题的问题

## Pipe流控制器

负责pipeline的部署,及状态监控

## 节点控制

控制节点和数据管道的部署,操纵及状态监控
* deploy
* status
* monitor

# 节点接口设计

## 节点程序接口设计

* init
* start
* restart
* pause
* stop
* subscribe

## 数据通道程序接口设计

* init
* start
* restart
* pause
* stop
* subscribe
66 changes: 66 additions & 0 deletions src/core/cnode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
use super::{MachineSpec, GID};
use serde::{Deserialize, Serialize};

// Channel use to definite data transfer channel
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Channel {
pub spec: MachineSpec,
}

// ComputeUnit used to define logic for data generation, transformer, ouput.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ComputeUnit<ID>
where
ID: GID,
{
#[serde(bound(deserialize = ""))]
pub id: ID,

pub name: String,

pub spec: MachineSpec,

pub channel: Option<Channel>,

#[serde(bound(deserialize = ""))]
pub(crate) dependency: Vec<ID>,
}

#[cfg(test)]
mod tests {
use super::*;
use uuid::Uuid;

#[test]
fn test_from_str() {
xxx();
}

fn xxx() -> ComputeUnit<Uuid> {
let json_str = r#"
{
"id": "5c42b900-a87f-45e3-ba06-c40d94ad5ba2",
"name": "ComputeUnit1",
"dependency": [
],
"spec": {
"cmd": [
"ls"
],
"image": ""
},
"channel": {
"spec": {
"cmd": [
"ls"
],
"image": ""
}
}
}
"#
.to_owned();
serde_json::from_str::<ComputeUnit<Uuid>>(&json_str).unwrap()
}
}
5 changes: 5 additions & 0 deletions src/core/id.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use serde::{Deserialize, Serialize};
use std::hash::Hash;
use std::marker::Send;

pub trait GID = Eq + Clone + Copy + Hash + Send + Sync + Serialize + for<'de> Deserialize<'de>;
7 changes: 7 additions & 0 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mod cnode;
mod id;
mod spec;

pub use cnode::*;
pub use id::*;
pub use spec::*;
8 changes: 8 additions & 0 deletions src/core/spec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use serde::{Deserialize, Serialize};

// MachineSpec container information for deploy and running in cloud
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MachineSpec {
pub image: String,
pub cmd: Vec<String>,
}
12 changes: 0 additions & 12 deletions src/dag/base.rs

This file was deleted.

22 changes: 0 additions & 22 deletions src/dag/channel.rs

This file was deleted.

24 changes: 0 additions & 24 deletions src/dag/cnode.rs

This file was deleted.

Loading

0 comments on commit 25a9727

Please sign in to comment.