Skip to content
Merged
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
7 changes: 1 addition & 6 deletions engine/packages/pegboard/src/workflows/serverless/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,13 @@ enum OutboundReqOutput {
#[timeout = u64::MAX]
async fn outbound_req(ctx: &ActivityCtx, input: &OutboundReqInput) -> Result<OutboundReqOutput> {
let mut term_signal = TermSignal::get();
let mut drain_sub = ctx
.subscribe::<Drain>(("workflow_id", ctx.workflow_id()))
.await?;

loop {
metrics::SERVERLESS_OUTBOUND_REQ_ACTIVE
.with_label_values(&[&input.namespace_id.to_string(), &input.runner_name])
.inc();

let res = outbound_req_inner(ctx, input, &mut term_signal, &mut drain_sub).await;
let res = outbound_req_inner(ctx, input, &mut term_signal).await;

metrics::SERVERLESS_OUTBOUND_REQ_ACTIVE
.with_label_values(&[&input.namespace_id.to_string(), &input.runner_name])
Expand Down Expand Up @@ -203,7 +200,6 @@ async fn outbound_req_inner(
ctx: &ActivityCtx,
input: &OutboundReqInput,
term_signal: &mut TermSignal,
drain_sub: &mut message::SubscriptionHandle<Drain>,
) -> Result<OutboundReqOutput> {
if is_runner_draining(ctx, input.receiver_wf_id).await? {
return Ok(OutboundReqOutput::Draining { drain_sent: false });
Expand Down Expand Up @@ -438,7 +434,6 @@ async fn outbound_req_inner(
}
},
_ = tokio::time::sleep(sleep_until_drain) => {}
_ = drain_sub.next() => {}
_ = term_signal.recv() => {}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ pub async fn pegboard_serverless_receiver(ctx: &mut WorkflowCtx, input: &Input)
.send()
.await?;

// if the connection is currently running an outbound req, this will be received
ctx.msg(conn::Drain {})
.topic(("workflow_id", conn_wf_id))
.send()
.await?;
ctx.removed::<Message<conn::Drain>>().await?;

// Wait for connection wf to complete so this wf's state remains readable
ctx.workflow::<conn::Input>(conn_wf_id).output().await?;
Expand Down
Loading