Skip to content

Commit

Permalink
Clean up and soft-deprecate AsyncKit (#106)
Browse files Browse the repository at this point in the history
* Soft-deprecate the package, bump to latest Swift requirement (matching Vapor), clean up CI and DocC docs
* Ditch old @available stanzas
* Fix the future operators (just 'cause)
* Factor out a ton of common code in the tests, reduce imports, set default log level to the now-standard info
* Speed up the future queue tests by a lot (no one should be using the darn thing, why should we spend forever testing it?)
  • Loading branch information
gwynne committed Oct 31, 2023
1 parent eab9edf commit 7ece208
Show file tree
Hide file tree
Showing 39 changed files with 389 additions and 652 deletions.
39 changes: 0 additions & 39 deletions .github/CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
with:
package_name: async-kit
modules: AsyncKit
pathsToInvalidate: /async-kit
pathsToInvalidate: /asynckit/*
11 changes: 0 additions & 11 deletions .github/workflows/projectboard.yml

This file was deleted.

17 changes: 10 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request: { branches: ['*'] }
push: { branches: ['main'] }
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
push: { branches: [ main ] }

env:
LOG_LEVEL: info
SWIFT_DETERMINISTIC_HASHING: 1

jobs:
unit-tests:
uses: vapor/ci/.github/workflows/run-unit-tests.yml@reusable-workflows
with:
with_coverage: true
with_tsan: true
with_public_api_check: ${{ github.event_name == 'pull_request' }}
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
14 changes: 8 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.6
// swift-tools-version:5.7
import PackageDescription

let package = Package(
Expand All @@ -13,15 +13,17 @@ let package = Package(
.library(name: "AsyncKit", targets: ["AsyncKit"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.46.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-algorithms.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.61.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.3"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.5"),
.package(url: "https://github.com/apple/swift-algorithms.git", from: "1.1.0"),
],
targets: [
.target(name: "AsyncKit", dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOEmbedded", package: "swift-nio"),
.product(name: "NIOPosix", package: "swift-nio"),
.product(name: "Collections", package: "swift-collections"),
.product(name: "Algorithms", package: "swift-algorithms"),
]),
Expand Down
43 changes: 19 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
<p align="center">
<img
src="https://user-images.githubusercontent.com/1342803/59048834-b2ce3680-8854-11e9-9446-78f5b07cf5fd.png"
height="64" alt="AsyncKit"
>
<br>
<br>
<a href="https://docs.vapor.codes/4.0/">
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
</a>
<a href="https://discord.gg/vapor">
<img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat">
</a>
<a href="https://github.com/vapor/async-kit/blob/main/LICENSE">
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
</a>
<a href="https://github.com/vapor/async-kit/actions/workflows/test.yml">
<img src="https://github.com/vapor/async-kit/actions/workflows/test.yml/badge.svg?event=push" alt="CI">
</a>
<a href="https://codecov.io/github/vapor/async-kit">
<img src="https://codecov.io/github/vapor/async-kit/branch/main/graph/badge.svg?token=yDzzHja8lt">
</a>
<a href="https://swift.org">
<img src="http://img.shields.io/badge/swift-5.6-brightgreen.svg" alt="Swift 5.6">
</a>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/async-kit/assets/1130717/4e9050ac-bf8b-4c4d-9d30-51b3d4cbc2e4">
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/async-kit/assets/1130717/474c4282-bf80-4473-919e-3019925ba530">
<img src="https://github.com/vapor/async-kit/assets/1130717/474c4282-bf80-4473-919e-3019925ba530" height="96" alt="AsyncKit">
</picture>
<br>
<br>
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
<a href="https://github.com/vapor/async-kit/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/async-kit/test.yml?event=push&style=for-the-badge&logo=github&label=test&logoColor=%23ccc" alt="Continuous Integration"></a>
<a href="https://codecov.io/github/vapor/async-kit"><img src="https://img.shields.io/codecov/c/github/vapor/async-kit?style=for-the-badge&logo=codecov&label=Codecov&token=yDzzHja8lt"></a>
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift57up.svg" alt="Swift 5.7+"></a>
</p>

<br>

_**AsyncKit is a legacy package; its use is not recommended in new projects.**_

This package provides a set of utilities for working with [EventLoopFuture](https://swiftpackageindex.com/apple/swift-nio/main/documentation/niocore/eventloopfuture)s and other related pre-Concurrency support APIs.
21 changes: 21 additions & 0 deletions Sources/AsyncKit/Docs.docc/images/vapor-asynckit-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
142 changes: 140 additions & 2 deletions Sources/AsyncKit/Docs.docc/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,145 @@
# ``AsyncKit``

AsyncKit provides a number of extensions to both Swift's Concurrency primitives and NIO's futures to make working with them easier. The long-term goal is to migrate away from this package as Swift Concurrency adds support for working in an asynchronous environment easy.
@Metadata {
@TitleHeading(Package)
}

Provides a set of utilities for working with EventLoopFutures and other pre-Concurrency support APIs.

## Overview

More to follow...
_**AsyncKit is a legacy package; its use is not recommended in new projects.**_

AsyncKit provides a number of extensions to both Swift's Concurrency primitives and NIO's futures to make working with them easier. The long-term goal is to migrate away from this package as Swift Concurrency adds support for working in an asynchronous environment easy.

See references below for usage details.

## Topics

### Legacy connection pools

- ``EventLoopConnectionPool``
- ``EventLoopGroupConnectionPool``
- ``ConnectionPoolSource``
- ``ConnectionPoolItem``
- ``ConnectionPoolError``
- ``ConnectionPoolTimeoutError``

### Optionals

- ``strictMap(_:_:)``
- ``strictMap(_:_:_:)``
- ``strictMap(_:_:_:_:)``
- ``strictMap(_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)``
- ``strictMap(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)``

### EventLoop and EventLoopGroup

- ``NIOCore/EventLoop/flatten(_:)-6gsl5``
- ``NIOCore/EventLoop/flatten(_:)-7tski``
- ``NIOCore/EventLoopGroup/future()``
- ``NIOCore/EventLoopGroup/future(error:)``
- ``NIOCore/EventLoopGroup/future(_:)``
- ``NIOCore/EventLoopGroup/future(result:)``
- ``NIOCore/EventLoopGroup/tryFuture(_:)``

### EventLoopFuture

- ``EventLoopFutureQueue``
- ``NIOCore/EventLoopFuture/mapEach(_:)-3wa2g``
- ``NIOCore/EventLoopFuture/mapEach(_:)-9cwjy``
- ``NIOCore/EventLoopFuture/mapEachCompact(_:)-2vkmo``
- ``NIOCore/EventLoopFuture/mapEachCompact(_:)-4sfs3``
- ``NIOCore/EventLoopFuture/mapEachFlat(_:)-9kgfr``
- ``NIOCore/EventLoopFuture/mapEachFlat(_:)-783z2``
- ``NIOCore/EventLoopFuture/flatMapEach(on:_:)-9yail``
- ``NIOCore/EventLoopFuture/flatMapEach(on:_:)-8yhpe``
- ``NIOCore/EventLoopFuture/flatMapEachCompact(on:_:)``
- ``NIOCore/EventLoopFuture/flatMapEachThrowing(_:)``
- ``NIOCore/EventLoopFuture/flatMapEachCompactThrowing(_:)``
- ``NIOCore/EventLoopFuture/sequencedFlatMapEach(_:)-29ak2``
- ``NIOCore/EventLoopFuture/sequencedFlatMapEach(_:)-6d82b``
- ``NIOCore/EventLoopFuture/sequencedFlatMapEachCompact(_:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/whenTheySucceed(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:file:line:)``
- ``NIOCore/EventLoopFuture/guard(_:else:)``
- ``NIOCore/EventLoopFuture/flatMapAlways(file:line:_:)``
- ``NIOCore/EventLoopFuture/nonempty(orError:)``
- ``NIOCore/EventLoopFuture/nonemptyMap(_:)``
- ``NIOCore/EventLoopFuture/nonemptyMap(or:_:)``
- ``NIOCore/EventLoopFuture/nonemptyFlatMapThrowing(_:)``
- ``NIOCore/EventLoopFuture/nonemptyFlatMapThrowing(or:_:)``
- ``NIOCore/EventLoopFuture/nonemptyFlatMap(_:)``
- ``NIOCore/EventLoopFuture/nonemptyFlatMap(or:_:)``
- ``NIOCore/EventLoopFuture/nonemptyFlatMap(orFlat:_:)``
- ``NIOCore/EventLoopFuture/optionalMap(_:)``
- ``NIOCore/EventLoopFuture/optionalFlatMap(_:)-1lhnd``
- ``NIOCore/EventLoopFuture/optionalFlatMap(_:)-1c1gn``
- ``NIOCore/EventLoopFuture/optionalFlatMapThrowing(_:)``
- ``NIOCore/EventLoopFuture/transform(to:)-7agus``
- ``NIOCore/EventLoopFuture/transform(to:)-3k9qv``
- ``NIOCore/EventLoopFuture/tryFlatMap(file:line:_:)``

### EventLoopFuture operators

- ``NIOCore/EventLoopFuture/+(_:_:)-48eo2``
- ``NIOCore/EventLoopFuture/+(_:_:)-78tv8``
- ``NIOCore/EventLoopFuture/+=(_:_:)-3854m``
- ``NIOCore/EventLoopFuture/+=(_:_:)-1t7oh``
<!--- ``NIOCore/EventLoopFuture/-(_:_:)-92wyb``-->
<!--- ``NIOCore/EventLoopFuture/-=(_:_:)-4sy59``-->
<!--- ``NIOCore/EventLoopFuture/-(_:_:)-6djhk``-->
<!--- ``NIOCore/EventLoopFuture/-=(_:_:)-3v817``-->
- ``NIOCore/EventLoopFuture/*(_:_:)``
- ``NIOCore/EventLoopFuture/*=(_:_:)``
<!--- ``NIOCore/EventLoopFuture//(_:_:)``-->
<!--- ``NIOCore/EventLoopFuture//=(_:_:)``-->
- ``NIOCore/EventLoopFuture/%(_:_:)``
- ``NIOCore/EventLoopFuture/%=(_:_:)``
- ``NIOCore/EventLoopFuture/<(_:_:)``
- ``NIOCore/EventLoopFuture/<=(_:_:)``
- ``NIOCore/EventLoopFuture/>(_:_:)``
- ``NIOCore/EventLoopFuture/>=(_:_:)``
- ``NIOCore/EventLoopFuture/<<(_:_:)``
- ``NIOCore/EventLoopFuture/<<=(_:_:)``
- ``NIOCore/EventLoopFuture/>>(_:_:)``
- ``NIOCore/EventLoopFuture/>>=(_:_:)``
- ``NIOCore/EventLoopFuture/&(_:_:)``
- ``NIOCore/EventLoopFuture/&=(_:_:)``
- ``NIOCore/EventLoopFuture/|(_:_:)``
- ``NIOCore/EventLoopFuture/|=(_:_:)``
- ``NIOCore/EventLoopFuture/^(_:_:)``
- ``NIOCore/EventLoopFuture/^=(_:_:)``
- ``NIOCore/EventLoopFuture/~(_:)``
21 changes: 21 additions & 0 deletions Sources/AsyncKit/Docs.docc/theme-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"theme": {
"aside": { "border-radius": "6px", "border-style": "double", "border-width": "3px" },
"border-radius": "0",
"button": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
"code": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
"color": {
"asynckit": "#808080",
"documentation-intro-fill": "radial-gradient(circle at top, var(--color-asynckit) 30%, #000 100%)",
"documentation-intro-accent": "var(--color-asynckit)",
"logo-base": { "dark": "#fff", "light": "#000" },
"logo-shape": { "dark": "#000", "light": "#fff" },
"fill": { "dark": "#000", "light": "#fff" }
},
"icons": { "technology": "/asynckit/images/vapor-asynckit-logo.svg" }
},
"features": {
"quickNavigation": { "enable": true },
"i18n": { "enable": true }
}
}
3 changes: 1 addition & 2 deletions Sources/AsyncKit/EventLoop/EventLoop+Concurrency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ extension EventLoop {
///
/// This function can be used to bridge the `async` world into an `EventLoop`.
///
/// This method is deprecated. Call ``EventLoop/makeFutureWithTask(_:)`` directly
/// This method is deprecated. Call `EventLoop.makeFutureWithTask(_:)` directly
/// instead.
///
/// - parameters:
/// - body: The `async` function to run.
/// - returns: An `EventLoopFuture` which is completed when `body` finishes. On
/// success the future has the result returned by `body`; if `body` throws an
/// error, the future is failed with that error.
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
@available(*, deprecated, renamed: "makeFutureWithTask(_:)")
@inlinable
public func performWithTask<Value>(
Expand Down
2 changes: 1 addition & 1 deletion Sources/AsyncKit/EventLoop/EventLoop+Flatten.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NIO
import NIOCore

extension EventLoop {
/// Returns a new `EventLoopFuture` that succeeds only when all the provided futures succeed.
Expand Down
2 changes: 1 addition & 1 deletion Sources/AsyncKit/EventLoop/EventLoop+Future.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NIO
import NIOCore

extension EventLoopGroup {
/// Creates a new, succeeded `EventLoopFuture` from the worker's event loop with a `Void` value.
Expand Down
Loading

0 comments on commit 7ece208

Please sign in to comment.