Skip to content

Commit

Permalink
init client
Browse files Browse the repository at this point in the history
Signed-off-by: remzi <[email protected]>
  • Loading branch information
HaoYang670 committed Jan 24, 2025
1 parent 981cb26 commit 87a27c1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
6 changes: 1 addition & 5 deletions rucat_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ edition = "2021"

[dependencies]
rucat_common = {path = "../rucat_common"}
serde_json = "1.0.135"
tonic = "0.12.3"
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }
tracing = {"version" = "0.1.41"}
tracing-subscriber = {"version" = "0.3.19"}
reqwest = { version = "0.12.12", features = ["json"] }
16 changes: 16 additions & 0 deletions rucat_client/examples/engine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use ::rucat_client::engine::create_engine;
use ::rucat_common::engine::{CreateEngineRequest, EngineType};
use rucat_common::tokio;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let request = CreateEngineRequest {
name: "spark0".to_owned(),
engine_type: EngineType::Spark,
version: "3.0.0".to_owned(),
config: None,
};
let id = create_engine(&request).await?;
println!("Engine created with id: {}", id);
Ok(())
}
16 changes: 16 additions & 0 deletions rucat_client/src/engine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Functions for managing the engine.
use ::rucat_common::engine::{CreateEngineRequest, EngineId};

pub async fn create_engine(request: &CreateEngineRequest) -> Result<EngineId, reqwest::Error> {
let client = reqwest::Client::new();
let id: EngineId = client
.post("http://localhost:3000/engine")
.json(request)
.send()
.await?
.json()
.await?;

Ok(id)
}
1 change: 1 addition & 0 deletions rucat_client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod engine;
27 changes: 0 additions & 27 deletions rucat_client/src/main.rs

This file was deleted.

0 comments on commit 87a27c1

Please sign in to comment.