Skip to content
Draft
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: 7 additions & 0 deletions engine/packages/api-peer/src/actors/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ pub async fn list(ctx: ApiCtx, _path: (), query: ListQuery) -> Result<ListRespon
// Sort by create ts desc
actors.sort_by_cached_key(|x| std::cmp::Reverse(x.create_ts));

// Apply cursor (cursor is the create_ts of the last actor returned in the previous page;
// we want strictly older actors since results are sorted desc by create_ts)
if let Some(cursor) = query.cursor.as_deref() {
let cursor_ts: i64 = cursor.parse()?;
actors.retain(|actor| actor.create_ts < cursor_ts);
}

// Apply limit
actors.truncate(query.limit.unwrap_or(100));

Expand Down
1 change: 1 addition & 0 deletions engine/packages/api-public/src/actors/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ async fn list_inner(ctx: ApiCtx, query: ListQuery) -> Result<ListResponse> {
query.namespace.clone(),
query.include_destroyed,
Some(limit),
query.cursor.clone(),
)
.await?;

Expand Down
4 changes: 3 additions & 1 deletion engine/packages/api-public/src/actors/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub async fn fetch_actors_by_ids(
namespace: String,
include_destroyed: Option<bool>,
limit: Option<usize>,
cursor: Option<String>,
) -> Result<Vec<Actor>> {
if actor_ids.is_empty() {
return Ok(Vec::new());
Expand All @@ -76,6 +77,7 @@ pub async fn fetch_actors_by_ids(
let namespace = namespace.clone();
let include_destroyed = include_destroyed;
let limit = limit;
let cursor = cursor.clone();

async move {
// Prepare peer query with actor_ids
Expand All @@ -87,7 +89,7 @@ pub async fn fetch_actors_by_ids(
actor_id: dc_actor_ids,
include_destroyed,
limit,
cursor: None,
cursor,
};

if dc_label == ctx.config().dc_label() {
Expand Down
1 change: 0 additions & 1 deletion engine/packages/engine/tests/envoy/api_actors_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,6 @@ fn list_cursor_across_datacenters() {
// Broken legacy Pegboard Runner coverage: full `runner::` sweep times out with
// `test timed out: Elapsed(())`.
#[test]
#[ignore = "cursor pagination off-by-one on final page"]
fn list_actor_ids_with_cursor_pagination() {
common::run(common::TestOpts::new(1).with_timeout(30), |ctx| async move {
let (namespace, _, _runner) =
Expand Down
Loading