Skip to content

Commit

Permalink
CLI: use newly-added InstanceId::none()
Browse files Browse the repository at this point in the history
Also: improve readability of "function invoke"
  • Loading branch information
ccicconetti committed Sep 11, 2023
1 parent 2d91b34 commit fef7053
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 9 additions & 0 deletions edgeless_api/src/function_instance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
pub type NodeId = uuid::Uuid;
pub type NodeLocalComponentId = uuid::Uuid;

const NODE_ID_NONE: uuid::Uuid = uuid::uuid!("00000000-0000-0000-0000-fffe00000000");
const FUNCTION_ID_NONE: uuid::Uuid = uuid::uuid!("00000000-0000-0000-0000-fffd00000000");

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct InstanceId {
pub node_id: NodeId,
Expand All @@ -15,6 +18,12 @@ impl InstanceId {
function_id: uuid::Uuid::new_v4(),
}
}
pub fn none() -> Self {
Self {
node_id: NODE_ID_NONE,
function_id: FUNCTION_ID_NONE,
}
}
}

#[derive(Debug, Clone)]
Expand Down
10 changes: 2 additions & 8 deletions edgeless_cli/src/edgeless_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,13 @@ async fn main() -> anyhow::Result<()> {
node_id: uuid::Uuid::parse_str(&node_id)?,
function_id: uuid::Uuid::parse_str(&function_id)?,
},
source: edgeless_api::function_instance::InstanceId {
node_id: uuid::uuid!("00000000-0000-0000-0000-ffff00000000"),
function_id: uuid::uuid!("00000000-0000-0000-0000-ffff00000000"),
},
source: edgeless_api::function_instance::InstanceId::none(),
stream_id: 0,
data: match event_type.as_str() {
"cast" => edgeless_api::invocation::EventData::Cast(payload),
_ => edgeless_api::invocation::EventData::Err,
_ => return Err(anyhow::anyhow!("invalid event type: {}", event_type)),
},
};
if let edgeless_api::invocation::EventData::Err = event.data {
return Err(anyhow::anyhow!("invalid event type: {}", event_type));
}
match edgeless_api::invocation::InvocationAPI::handle(&mut client, event).await {
Ok(_) => println!("event casted"),
Err(err) => return Err(anyhow::anyhow!("error casting the event: {}", err)),
Expand Down

0 comments on commit fef7053

Please sign in to comment.