vapor / async-kit

Sugary extensions for the SwiftNIO library
MIT License
71 stars 25 forks source link

Add "sequenced" variants of flatMapEach() and flatMapEachCompact() #73

Closed gwynne closed 3 years ago

gwynne commented 3 years ago

These new variants guarantee two specific behaviors:

  1. The futures returned for each element of the iterated sequence will be executed singularly and strictly in order. Only one will run at a time, and the order in which they run will match that returned by the transformation callback.

  2. If any one of the futures should fail, no other futures will begin execution, even if they were ready to do so.

Additional changes:

codecov-io commented 3 years ago

Codecov Report

Merging #73 (47e4dfa) into master (6184c6c) will increase coverage by 0.20%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #73      +/-   ##
==========================================
+ Coverage   94.76%   94.97%   +0.20%     
==========================================
  Files          23       23              
  Lines        1204     1254      +50     
==========================================
+ Hits         1141     1191      +50     
  Misses         63       63              
Flag Coverage Δ
unittests 94.97% <100.00%> (+0.20%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...s/AsyncKit/EventLoopFuture/Future+Collection.swift 100.00% <100.00%> (ø)
Tests/AsyncKitTests/Future+CollectionTests.swift 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6184c6c...47e4dfa. Read the comment docs.

MrMage commented 3 years ago

I think Vapor used to have methods for this already. Or was that only in Vapor 3's "core" repository? I might also be mistaken completely.

But I wonder if the SwiftNIO people would be interested in taking this as a PR for their repo, so that it can benefit everyone by default. At least in the past they used to be fairly open to such additions, IIRC. /cc @weissi @lukasa

tanner0101 commented 3 years ago

These changes are now available in 1.3.0