[SERVER-68536] Add a future_util::whenAnyThat Created: 03/Aug/22  Updated: 04/Aug/22  Resolved: 04/Aug/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: George Wangensteen Assignee: Erin McNulty
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Sprint: Service Arch 2022-08-08, Service Arch 2022-08-22
Participants:

 Description   

Right now, we have a helper function future_util::whenAny that takes as argument a vector of Future<T> and returns a SemiFuture that resolves when the first of the input futures resolves along with its index in the input vector.

This function is useful but doesn't allow for any selectivity about how the input futures resolve. For example, we might want a future that resolves when any of the input futures resolve with success, i.e. whenAnySucceeds. To allow for that sort of selectivity, add a whenAnyThat helper that takes a predicate to evaluate against each result of the input futures and only resolves the output future when either:

-> one of the input futures resolves with a result that satisfies the predicate

-> all of the input futures resolve



 Comments   
Comment by Erin McNulty [ 04/Aug/22 ]

Decided to implement as a impl-specific function in doHedgedRequest.

Generated at Thu Feb 08 06:11:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.