-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🤞🏼 Rephrase async code as PromiseKit Promises #362
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I want to get the release out before we make this change. Also want to give time to review it properly. |
Fixes #344. With the async logic now described in terms of promises, implementing retry logic was pretty straightforward. caraman@mac ~/s/mas (promisekit)> swift run mas install 462062816
==> Downloading Microsoft PowerPoint
Warning: The Internet connection appears to be offline.
Trying again up to 2 more times.
==> Downloading Microsoft PowerPoint
Warning: The Internet connection appears to be offline.
Trying again up to 1 more time.
==> Downloading Microsoft PowerPoint
###################################################--------- 85.0% Installing |
4 tasks
phatblat
requested changes
May 9, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One idea for the tests
phatblat
approved these changes
May 12, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RE: #346 (comment)
Using Combine would seem to be the future-proof option, as that's the API Apple has produced for asynchronous programming. However, we can't use Apple's Combine yet because it requires macOS 10.15. There are some open source implementations that support older macOS releases.
🔴 CombineX failed
swift build
.🟡 I made some progress with OpenCombine, but got stuck when I found that it doesn't yet implement
merge
.So, here's the async code rephrased as PromiseKit promises.
👍🏼 Pros:
mas
andMasKit
.👎🏼 Cons:
MasKit.initialize
configures PromiseKit for use in a console app, where we regularly wait on the main queue for promises to complete on the global queue.main.swift
and all test case entry points invokeMasKit.initialize
.mas
executable (arm64, release) increases in size by ~388 KiB, or ~53%. I might be able to reduce this with further investigation, but considering we just shed ~13 MiB fromMasKit.framework
, I think it's probably fine.I'm open to keeping this or dropping it. I'll leave it up to your best judgment, @phatblat.
ℹ️ Commit fb01f5b is here only to maintain existing behavior. With this commit, commands that download (or purchase) multiple apps will continue to attempt all downloads even if an earlier download fails. Without this commit, we'll stop downloading at the first failure. I'm inclined to think the behavior without this commit (failing fast) is what users would expect, but perhaps it's common for one download to fail while others succeed for reasons unrelated to network failures. If you agree, feel free to pop that commit off the stack, or ask me to do so, before merging.