Skip to content

Commit

Permalink
[WIP] rust
Browse files Browse the repository at this point in the history
  • Loading branch information
lemaitre-aneo committed May 13, 2024
1 parent 9eb4d72 commit d893ed4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/rust/armonik/src/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub mod sessions;
pub mod submitter;
pub mod tasks;
pub mod versions;
pub mod worker;

pub use configuration::Configuration;
pub use count::Count;
Expand Down
44 changes: 44 additions & 0 deletions packages/rust/armonik/src/objects/worker/health_check.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use crate::api::v3;

#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Request {}

super::super::impl_convert!(
struct Request = v3::Empty {
}
);

#[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Response {
#[default]
Unknown = 0,
Serving = 1,
NotServing = 2,
}

impl From<i32> for Response {
fn from(value: i32) -> Self {
match value {
0 => Self::Unknown,
1 => Self::Serving,
2 => Self::NotServing,
_ => Self::Unknown,
}
}
}

impl From<Response> for v3::worker::HealthCheckReply {
fn from(value: Response) -> Self {
Self {
status: value as i32,
}
}
}

impl From<v3::worker::HealthCheckReply> for Response {
fn from(value: v3::worker::HealthCheckReply) -> Self {
value.status.into()
}
}

super::super::impl_convert!(req Response : v3::worker::HealthCheckReply);
2 changes: 2 additions & 0 deletions packages/rust/armonik/src/objects/worker/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod health_check;
pub mod process;
15 changes: 15 additions & 0 deletions packages/rust/armonik/src/objects/worker/process.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use super::super::Output;

use crate::api::v3;

pub struct Response {
pub communication_token: String,
pub output: Output,
}

super::super::impl_convert!(
struct Response = v3::worker::ProcessReply {
communication_token,
output = option output,
}
);

0 comments on commit d893ed4

Please sign in to comment.