-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add jz runner and base controller and data protocol
- Loading branch information
hunjixin
committed
Jun 16, 2024
1 parent
38d1ea5
commit 8c30815
Showing
15 changed files
with
317 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,57 @@ | ||
[workspace] | ||
members = [ | ||
"jz_runner", | ||
] | ||
|
||
[workspace.package] | ||
repository = "https://github.com/GitDataAI/jz-action" | ||
license = "MIT OR Apache-2.0" | ||
edition = "2021" | ||
include = [ | ||
"build.rs", | ||
"src/**/*", | ||
"Cargo.toml", | ||
"LICENSE*", | ||
"README.md", | ||
] | ||
|
||
[workspace.dependencies] | ||
anyhow = "1.0.86" | ||
tracing = "0.1.40" | ||
tracing-subscriber = "0.3" | ||
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] } | ||
tokio-retry = "0.3" | ||
tokio-stream = "0.1.15" | ||
tonic = "0.11.0" | ||
|
||
|
||
[package] | ||
name = "jz-action" | ||
name = "jz_action" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
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"]} | ||
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"] } | ||
handlebars = "5.1.2" | ||
tracing = "0.1.40" | ||
tracing-subscriber = "0.3" | ||
tokio-retry = "0.3" | ||
prost = "0.12.6" | ||
|
||
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } | ||
tokio-retry = {workspace = true} | ||
tokio-stream = {workspace = true} | ||
anyhow = {workspace = true} | ||
tracing = {workspace = true} | ||
tracing-subscriber = {workspace = true} | ||
tonic = {workspace = true} | ||
|
||
[dev-dependencies] | ||
arrayvec = {version="0.7.4", features= ["serde"]} | ||
arrayvec = {version="0.7.4", features= ["serde"]} | ||
|
||
[build-dependencies] | ||
tonic-build = "0.11.0" | ||
log= "0.4.21" | ||
env_logger="0.11.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
env_logger::init(); | ||
|
||
let protos = [ | ||
"src/network/protos/helloworld.proto", | ||
"src/network/protos/common.proto", | ||
"src/network/protos/datatransfer.proto", | ||
"src/network/protos/nodecontroller.proto", | ||
]; | ||
|
||
let proto_dir = "src/network/protos"; | ||
tonic_build::configure().compile(&protos, &[proto_dir])?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "jz_runner" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
jz_action = { path = "../"} | ||
|
||
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } | ||
tokio-retry = {workspace = true} | ||
tokio-stream = {workspace = true} | ||
anyhow = {workspace = true} | ||
tracing = {workspace = true} | ||
tracing-subscriber = {workspace = true} | ||
tonic = {workspace = true} | ||
|
||
clap = {version="4.5.7", features=["derive"]} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
mod unit; | ||
|
||
use jz_action::network::datatransfer::data_stream_server::DataStreamServer; | ||
use jz_action::network::nodecontroller::node_controller_server::NodeControllerServer; | ||
|
||
use anyhow::{anyhow, Result}; | ||
use clap::Parser; | ||
use std::str::FromStr; | ||
use tonic::{transport::Server, Request, Response, Status}; | ||
use tracing::{info, Level}; | ||
|
||
use unit::{DataNodeControllerServer, UnitDataStrean}; | ||
#[derive(Debug, Parser)] | ||
#[command( | ||
name = "jz_runner", | ||
version = "0.0.1", | ||
author = "Author Name <github.com/GitDataAI/jz-action>", | ||
about = "embed in k8s images" | ||
)] | ||
struct Args { | ||
#[arg(short, long, default_value = "INFO")] | ||
log_level: String, | ||
|
||
#[arg(long, default_value = "[::1]:25431")] | ||
host_port: String, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let args = Args::parse(); | ||
tracing_subscriber::fmt() | ||
.with_max_level(Level::from_str(&args.log_level)?) | ||
.try_init() | ||
.map_err(|e| anyhow!("{}", e))?; | ||
|
||
let addr = args.host_port.parse()?; | ||
let node_controller = DataNodeControllerServer::default(); | ||
let unit_data_stream = UnitDataStrean::default(); | ||
|
||
Server::builder() | ||
.add_service(NodeControllerServer::new(node_controller)) | ||
.add_service(DataStreamServer::new(unit_data_stream)) | ||
.serve(addr) | ||
.await?; | ||
info!("node listening on {}", addr); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use jz_action::network::common::Empty; | ||
use jz_action::network::datatransfer::data_stream_server::DataStream; | ||
use jz_action::network::datatransfer::DataBatch; | ||
use jz_action::network::nodecontroller::node_controller_server::NodeController; | ||
|
||
use std::result::Result; | ||
use tokio_stream::wrappers::ReceiverStream; | ||
use tonic::{Request, Response, Status}; | ||
|
||
#[derive(Default)] | ||
pub(crate) struct DataNodeControllerServer {} | ||
|
||
#[tonic::async_trait] | ||
impl NodeController for DataNodeControllerServer { | ||
async fn pause(&self, _request: Request<Empty>) -> Result<Response<Empty>, Status> { | ||
todo!() | ||
} | ||
async fn restart(&self, _request: Request<Empty>) -> Result<Response<Empty>, Status> { | ||
todo!() | ||
} | ||
async fn stop(&self, _request: Request<Empty>) -> Result<Response<Empty>, Status> { | ||
todo!() | ||
} | ||
} | ||
|
||
#[derive(Default)] | ||
pub(crate) struct UnitDataStrean {} | ||
|
||
#[tonic::async_trait] | ||
impl DataStream for UnitDataStrean { | ||
type subscribe_new_dataStream = ReceiverStream<Result<DataBatch, Status>>; | ||
|
||
async fn subscribe_new_data( | ||
&self, | ||
_request: Request<Empty>, | ||
) -> Result<Response<Self::subscribe_new_dataStream>, Status> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
use crate::core::GID; | ||
use crate::Dag; | ||
use crate::dag::Dag; | ||
use anyhow::Result; | ||
use std::{ | ||
future::Future, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.