Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/edge/api/actor/src/route/actors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ pub async fn create(

tracing::info!(?actor_id, ?tags, "creating actor with tags");

let create_fut = if network.wait_ready.unwrap_or_default() {
let allocated_fut = if network.wait_ready.unwrap_or_default() {
std::future::pending().boxed()
} else {
let mut create_sub = ctx
.subscribe::<pegboard::workflows::actor::CreateComplete>(("actor_id", actor_id))
let mut allocated_sub = ctx
.subscribe::<pegboard::workflows::actor::Allocated>(("actor_id", actor_id))
.await?;

async move { create_sub.next().await }.boxed()
async move { allocated_sub.next().await }.boxed()
};
let mut ready_sub = ctx
.subscribe::<pegboard::workflows::actor::Ready>(("actor_id", actor_id))
Expand Down Expand Up @@ -238,9 +238,9 @@ pub async fn create(
.dispatch()
.await?;

// Wait for create/ready, fail, or destroy
// Wait for allocated/ready, fail, or destroy
tokio::select! {
res = create_fut => { res?; },
res = allocated_fut => { res?; },
res = ready_sub.next() => { res?; },
res = fail_sub.next() => {
let msg = res?;
Expand Down
12 changes: 12 additions & 0 deletions packages/edge/services/pegboard/src/workflows/actor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ pub async fn pegboard_actor(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResul
return Ok(());
};

ctx.v(2).msg(Allocated {
client_id: res.client_id,
})
.tag("actor_id", input.actor_id)
.send()
.await?;

let state_res = ctx
.loope(
runtime::State::new(res.client_id, res.client_workflow_id, input.image_id),
Expand Down Expand Up @@ -447,6 +454,11 @@ pub async fn pegboard_actor(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResul
#[message("pegboard_actor_create_complete")]
pub struct CreateComplete {}

#[message("pegboard_actor_allocated")]
pub struct Allocated {
pub client_id: Uuid,
}

#[message("pegboard_actor_failed")]
pub struct Failed {
pub message: String,
Expand Down
Loading