Skip to content
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

Bump minimum Swift version to 5.7 #420

Merged
merged 3 commits into from
Oct 11, 2023
Merged
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
2 changes: 1 addition & 1 deletion 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
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ To depend on `swift-nio-http2`, put the following in the `dependencies` of your

.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.19.2"),

The most recent versions of SwiftNIO HTTP/2 support Swift 5.6 and newer. The minimum Swift version supported for SwiftNIO HTTP/2 releases are detailed below:
The most recent versions of SwiftNIO HTTP/2 support Swift 5.7 and newer. The minimum Swift version supported for SwiftNIO HTTP/2 releases are detailed below:

SwiftNIO HTTP/2 | Minimum Swift Version
--------------------|----------------------
`1.0.0 ..< 1.18.0` | 5.0
`1.18.0 ..< 1.21.0` | 5.2
`1.21.0 ..< 1.23.0` | 5.4
`1.24.0 ..< 1.27.0` | 5.5.2
`1.27.0 ...` | 5.6
`1.27.0 ..< 1.29.0` | 5.6
`1.29.0 ...` | 5.7


### `swift-nio-http2` 0.x
Expand Down
25 changes: 0 additions & 25 deletions Sources/NIOHTTP2/DOSHeuristics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,13 @@ struct DOSHeuristics<DeadlineClock: NIODeadlineClock> {

private var resetFrameRateControlStateMachine: HTTP2ResetFrameRateControlStateMachine

#if swift(>=5.7)
internal init(maximumSequentialEmptyDataFrames: Int, maximumResetFrameCount: Int, resetFrameCounterWindow: TimeAmount, clock: DeadlineClock = RealNIODeadlineClock()) {
precondition(maximumSequentialEmptyDataFrames >= 0,
"maximum sequential empty data frames must be positive, got \(maximumSequentialEmptyDataFrames)")
self.maximumSequentialEmptyDataFrames = maximumSequentialEmptyDataFrames
self.receivedEmptyDataFrames = 0
self.resetFrameRateControlStateMachine = .init(countThreshold: maximumResetFrameCount, timeWindow: resetFrameCounterWindow, clock: clock)
}
#else
internal init(maximumSequentialEmptyDataFrames: Int, maximumResetFrameCount: Int, resetFrameCounterWindow: TimeAmount, clock: DeadlineClock) {
precondition(maximumSequentialEmptyDataFrames >= 0,
"maximum sequential empty data frames must be positive, got \(maximumSequentialEmptyDataFrames)")
self.maximumSequentialEmptyDataFrames = maximumSequentialEmptyDataFrames
self.receivedEmptyDataFrames = 0

self.resetFrameRateControlStateMachine = .init(countThreshold: maximumResetFrameCount, timeWindow: resetFrameCounterWindow, clock: clock)
}

internal init(maximumSequentialEmptyDataFrames: Int, maximumResetFrameCount: Int, resetFrameCounterWindow: TimeAmount) where DeadlineClock == RealNIODeadlineClock {
self.init(maximumSequentialEmptyDataFrames: maximumSequentialEmptyDataFrames, maximumResetFrameCount: maximumResetFrameCount, resetFrameCounterWindow: resetFrameCounterWindow, clock: RealNIODeadlineClock())
}
#endif
}


Expand Down Expand Up @@ -104,23 +89,13 @@ extension DOSHeuristics {
private var resetTimestamps: Deque<NIODeadline>
private var _state: ResetFrameRateControlState = .noneReceived

#if swift(>=5.7)
init(countThreshold: Int, timeWindow: TimeAmount, clock: DeadlineClock = RealNIODeadlineClock()) {
self.countThreshold = countThreshold
self.timeWindow = timeWindow
self.clock = clock

self.resetTimestamps = .init(minimumCapacity: self.countThreshold)
}
#else
init(countThreshold: Int, timeWindow: TimeAmount, clock: DeadlineClock) {
self.countThreshold = countThreshold
self.timeWindow = timeWindow
self.clock = clock

self.resetTimestamps = .init(minimumCapacity: self.countThreshold)
}
#endif

mutating func resetReceived() -> ResetFrameRateControlState {
self.garbageCollect()
Expand Down
7 changes: 0 additions & 7 deletions Sources/NIOHTTP2/HTTP2ChannelHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1033,17 +1033,10 @@ extension NIOHTTP2Handler {


extension NIOHTTP2Handler {
#if swift(>=5.7)
/// The type of all `inboundStreamInitializer` callbacks which do not need to return data.
public typealias StreamInitializer = NIOChannelInitializer
/// The type of NIO Channel initializer callbacks which need to return untyped data.
internal typealias StreamInitializerWithAnyOutput = @Sendable (Channel) -> EventLoopFuture<any Sendable>
#else
/// The type of all `inboundStreamInitializer` callbacks which need to return data.
public typealias StreamInitializer = NIOChannelInitializer
/// The type of NIO Channel initializer callbacks which need to return untyped data.
internal typealias StreamInitializerWithAnyOutput = (Channel) -> EventLoopFuture<any Sendable>
#endif

/// Creates a new ``NIOHTTP2Handler`` with a local multiplexer. (i.e. using
/// ``StreamMultiplexer``.)
Expand Down
7 changes: 0 additions & 7 deletions Sources/NIOHTTP2/HTTP2PipelineHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,10 @@ import NIOTLS
/// Configuring for servers is very similar.
public let NIOHTTP2SupportedALPNProtocols = ["h2", "http/1.1"]

#if swift(>=5.7)
/// The type of NIO Channel initializer callbacks which do not need to return data.
public typealias NIOChannelInitializer = @Sendable (Channel) -> EventLoopFuture<Void>
/// The type of NIO Channel initializer callbacks which need to return data.
public typealias NIOChannelInitializerWithOutput<Output> = @Sendable (Channel) -> EventLoopFuture<Output>
#else
/// The type of NIO Channel initializer callbacks which do not need to return data.
public typealias NIOChannelInitializer = (Channel) -> EventLoopFuture<Void>
/// The type of NIO Channel initializer callbacks which need to return data.
public typealias NIOChannelInitializerWithOutput<Output> = (Channel) -> EventLoopFuture<Output>
#endif

extension ChannelPipeline {
/// Configures a channel pipeline to perform a HTTP/2 secure upgrade.
Expand Down
2 changes: 1 addition & 1 deletion dev/update-alloc-limits-to-last-completed-ci-build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ url_prefix=${1-"https://ci.swiftserver.group/job/swift-nio-http2-2-"}
target_repo=${2-"$here/.."}
tmpdir=$(mktemp -d /tmp/.last-build_XXXXXX)

for f in swift56 swift57 swift58 swift59 nightly; do
for f in swift57 swift58 swift59 swift510 nightly; do
echo "$f"
url="$url_prefix$f-prb/lastCompletedBuild/consoleFull"
stripped=${f#"swift"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@ version: "3"
services:

runtime-setup:
image: swift-nio-http2:20.04-5.6
image: swift-nio-http2:22.04-5.10
build:
args:
ubuntu_version: "focal"
swift_version: "5.6"
base_image: "swiftlang/swift:nightly-5.10-jammy"
h2spec_version: "2.2.1"

unit-tests:
image: swift-nio-http2:20.04-5.6
image: swift-nio-http2:22.04-5.10

integration-tests:
image: swift-nio-http2:20.04-5.6
image: swift-nio-http2:22.04-5.10

performance-test:
image: swift-nio-http2:20.04-5.6
image: swift-nio-http2:22.04-5.10

h2spec:
image: swift-nio-http2:20.04-5.6
image: swift-nio-http2:22.04-5.10

documentation-check:
image: swift-nio-http2:20.04-5.6
image: swift-nio-http2:22.04-5.10

test:
image: swift-nio-http2:20.04-5.6
image: swift-nio-http2:22.04-5.10
environment:
- MAX_ALLOCS_ALLOWED_1k_requests_inline_interleaved=35150
- MAX_ALLOCS_ALLOWED_1k_requests_inline_noninterleaved=34100
Expand All @@ -47,6 +46,7 @@ services:
- MAX_ALLOCS_ALLOWED_hpack_decoding=5050
- MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent=293050
- MAX_ALLOCS_ALLOWED_stream_teardown_100_concurrent_inline=291750
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error

shell:
image: swift-nio-http2:20.04-5.6
image: swift-nio-http2:22.04-5.10
3 changes: 2 additions & 1 deletion docker/docker-compose.2204.59.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ services:
image: swift-nio-http2:22.04-5.9
build:
args:
base_image: "swiftlang/swift:nightly-5.9-jammy"
ubuntu_version: "jammy"
swift_version: "5.9"
h2spec_version: "2.2.1"

unit-tests:
Expand Down