Skip to content

Commit 6d98c23

Browse files
committed
fix(pegboard): wait for actor allocation not creation
1 parent 3b1c588 commit 6d98c23

File tree

2 files changed

+18
-6
lines changed
  • packages/edge

2 files changed

+18
-6
lines changed

packages/edge/api/actor/src/route/actors.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ pub async fn create(
150150

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

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

160-
async move { create_sub.next().await }.boxed()
160+
async move { allocated_sub.next().await }.boxed()
161161
};
162162
let mut ready_sub = ctx
163163
.subscribe::<pegboard::workflows::actor::Ready>(("actor_id", actor_id))
@@ -238,9 +238,9 @@ pub async fn create(
238238
.dispatch()
239239
.await?;
240240

241-
// Wait for create/ready, fail, or destroy
241+
// Wait for allocated/ready, fail, or destroy
242242
tokio::select! {
243-
res = create_fut => { res?; },
243+
res = allocated_fut => { res?; },
244244
res = ready_sub.next() => { res?; },
245245
res = fail_sub.next() => {
246246
let msg = res?;

packages/edge/services/pegboard/src/workflows/actor/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ pub async fn pegboard_actor(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResul
146146
return Ok(());
147147
};
148148

149+
ctx.msg(Allocated {
150+
client_id: res.client_id,
151+
})
152+
.tag("actor_id", input.actor_id)
153+
.send()
154+
.await?;
155+
149156
let state_res = ctx
150157
.loope(
151158
runtime::State::new(res.client_id, res.client_workflow_id, input.image_id),
@@ -447,6 +454,11 @@ pub async fn pegboard_actor(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResul
447454
#[message("pegboard_actor_create_complete")]
448455
pub struct CreateComplete {}
449456

457+
#[message("pegboard_actor_allocated")]
458+
pub struct Allocated {
459+
pub client_id: Uuid,
460+
}
461+
450462
#[message("pegboard_actor_failed")]
451463
pub struct Failed {
452464
pub message: String,

0 commit comments

Comments
 (0)