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
1 change: 1 addition & 0 deletions packages/edge/api/actor/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub async fn actor_for_env(
.op(pegboard::ops::actor::get::Input {
actor_ids: vec![actor_id],
endpoint_type,
allow_errors: false,
})
.await?;
let actor = unwrap_with!(actors_res.actors.into_iter().next(), ACTOR_NOT_FOUND);
Expand Down
3 changes: 3 additions & 0 deletions packages/edge/api/actor/src/route/actors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async fn get_inner(
.op(pegboard::ops::actor::get::Input {
actor_ids: vec![actor_id],
endpoint_type: query.endpoint_type.map(ApiInto::api_into),
allow_errors: false,
})
.await?;
let actor = unwrap_with!(actors_res.actors.first(), ACTOR_NOT_FOUND);
Expand Down Expand Up @@ -255,6 +256,7 @@ pub async fn create(
.op(pegboard::ops::actor::get::Input {
actor_ids: vec![actor_id],
endpoint_type: query.endpoint_type.map(ApiInto::api_into),
allow_errors: false,
})
.await?;
let actor = unwrap_with!(actors_res.actors.first(), ACTOR_NOT_FOUND);
Expand Down Expand Up @@ -584,6 +586,7 @@ async fn list_actors_inner(
.global_endpoint_type
.endpoint_type
.map(ApiInto::api_into),
allow_errors: false,
})
.await?;
actors_res.actors.sort_by_key(|x| -x.create_ts);
Expand Down
13 changes: 13 additions & 0 deletions packages/edge/services/pegboard/src/ops/actor/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub struct Input {
/// If the datacenter has a parent hostname, will use hostname endpoint. Otherwise, will use
/// path endpoint.
pub endpoint_type: Option<crate::types::EndpointType>,

pub allow_errors: bool,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Missing documentation for allow_errors field to explain when it should be used and potential implications.

Suggested change
pub allow_errors: bool,
/// When true, errors fetching individual actors will be logged and skipped instead of failing the entire operation.
/// This is useful for bulk operations where partial failures are acceptable.
pub allow_errors: bool,

}

#[derive(Debug)]
Expand Down Expand Up @@ -192,6 +194,17 @@ pub async fn pegboard_actor_get(ctx: &OperationCtx, input: &Input) -> GlobalResu
}))
})
.buffer_unordered(1024)
.map(|x| match x {
Ok(x) => Ok(x),
Err(err) => {
if input.allow_errors {
tracing::warn!(?err, "failed to fetch actor");
Ok(None)
} else {
Err(err)
}
}
})
.try_filter_map(|x| std::future::ready(Ok(x)))
.try_collect::<Vec<_>>()
.await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub async fn run_from_env(
.op(pegboard::ops::actor::get::Input {
actor_ids,
endpoint_type: None,
allow_errors: true,
})
.await?;

Expand Down
Loading