mirror of
https://github.com/apple/swift-nio-extras.git
synced 2025-05-14 00:42:41 +08:00
HTTPResumableUpload contains the core logic. It uses an event loop to synchronize its state internally. Some methods are safe to call from off of that event loop and have been moved to a new sendable view. The HTTPResumableUpload type is marked as explicitly not sendable. As such, most other types now hold on to the sendable view and use that as the interface to HTTPResumableUpload. HTTPResumableUploadChannel must be sendable (it's a Channel) and now uses safe abstractions (where possible).
301 lines
10 KiB
Swift
301 lines
10 KiB
Swift
// swift-tools-version:5.8
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2017-2024 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import PackageDescription
|
|
|
|
let strictConcurrencyDevelopment = false
|
|
|
|
let strictConcurrencySettings: [SwiftSetting] = {
|
|
var initialSettings: [SwiftSetting] = []
|
|
initialSettings.append(contentsOf: [
|
|
.enableUpcomingFeature("StrictConcurrency"),
|
|
.enableUpcomingFeature("InferSendableFromCaptures"),
|
|
])
|
|
|
|
if strictConcurrencyDevelopment {
|
|
// -warnings-as-errors here is a workaround so that IDE-based development can
|
|
// get tripped up on -require-explicit-sendable.
|
|
initialSettings.append(.unsafeFlags(["-require-explicit-sendable", "-warnings-as-errors"]))
|
|
}
|
|
|
|
return initialSettings
|
|
}()
|
|
|
|
var targets: [PackageDescription.Target] = [
|
|
.target(
|
|
name: "NIOExtras",
|
|
dependencies: [
|
|
.product(name: "NIO", package: "swift-nio"),
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.target(
|
|
name: "NIOHTTPCompression",
|
|
dependencies: [
|
|
"CNIOExtrasZlib",
|
|
.product(name: "NIO", package: "swift-nio"),
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.executableTarget(
|
|
name: "HTTPServerWithQuiescingDemo",
|
|
dependencies: [
|
|
"NIOExtras",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOPosix", package: "swift-nio"),
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.executableTarget(
|
|
name: "NIOWritePCAPDemo",
|
|
dependencies: [
|
|
"NIOExtras",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOPosix", package: "swift-nio"),
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.executableTarget(
|
|
name: "NIOWritePartialPCAPDemo",
|
|
dependencies: [
|
|
"NIOExtras",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOPosix", package: "swift-nio"),
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.executableTarget(
|
|
name: "NIOExtrasPerformanceTester",
|
|
dependencies: [
|
|
"NIOExtras",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOPosix", package: "swift-nio"),
|
|
.product(name: "NIOEmbedded", package: "swift-nio"),
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.target(
|
|
name: "NIOSOCKS",
|
|
dependencies: [
|
|
.product(name: "NIO", package: "swift-nio"),
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.executableTarget(
|
|
name: "NIOSOCKSClient",
|
|
dependencies: [
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOPosix", package: "swift-nio"),
|
|
"NIOSOCKS",
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.target(
|
|
name: "CNIOExtrasZlib",
|
|
dependencies: [],
|
|
linkerSettings: [
|
|
.linkedLibrary("z")
|
|
]
|
|
),
|
|
.testTarget(
|
|
name: "NIOExtrasTests",
|
|
dependencies: [
|
|
"NIOExtras",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOEmbedded", package: "swift-nio"),
|
|
.product(name: "NIOPosix", package: "swift-nio"),
|
|
.product(name: "NIOTestUtils", package: "swift-nio"),
|
|
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.testTarget(
|
|
name: "NIOHTTPCompressionTests",
|
|
dependencies: [
|
|
"CNIOExtrasZlib",
|
|
"NIOHTTPCompression",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOEmbedded", package: "swift-nio"),
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.testTarget(
|
|
name: "NIOSOCKSTests",
|
|
dependencies: [
|
|
"NIOSOCKS",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOEmbedded", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.target(
|
|
name: "NIONFS3",
|
|
dependencies: [
|
|
.product(name: "NIOCore", package: "swift-nio")
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.testTarget(
|
|
name: "NIONFS3Tests",
|
|
dependencies: [
|
|
"NIONFS3",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOEmbedded", package: "swift-nio"),
|
|
.product(name: "NIOTestUtils", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.target(
|
|
name: "NIOHTTPTypes",
|
|
dependencies: [
|
|
.product(name: "HTTPTypes", package: "swift-http-types"),
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.target(
|
|
name: "NIOHTTPTypesHTTP1",
|
|
dependencies: [
|
|
"NIOHTTPTypes",
|
|
.product(name: "NIOHTTP1", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.target(
|
|
name: "NIOHTTPTypesHTTP2",
|
|
dependencies: [
|
|
"NIOHTTPTypes",
|
|
.product(name: "NIOHTTP2", package: "swift-nio-http2"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.testTarget(
|
|
name: "NIOHTTPTypesHTTP1Tests",
|
|
dependencies: [
|
|
"NIOHTTPTypesHTTP1"
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.testTarget(
|
|
name: "NIOHTTPTypesHTTP2Tests",
|
|
dependencies: [
|
|
"NIOHTTPTypesHTTP2"
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.target(
|
|
name: "NIOResumableUpload",
|
|
dependencies: [
|
|
"NIOHTTPTypes",
|
|
.product(name: "HTTPTypes", package: "swift-http-types"),
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "StructuredFieldValues", package: "swift-http-structured-headers"),
|
|
.product(name: "Atomics", package: "swift-atomics"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.executableTarget(
|
|
name: "NIOResumableUploadDemo",
|
|
dependencies: [
|
|
"NIOResumableUpload",
|
|
"NIOHTTPTypesHTTP1",
|
|
.product(name: "HTTPTypes", package: "swift-http-types"),
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOPosix", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.testTarget(
|
|
name: "NIOResumableUploadTests",
|
|
dependencies: [
|
|
"NIOResumableUpload",
|
|
.product(name: "NIOEmbedded", package: "swift-nio"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.target(
|
|
name: "NIOHTTPResponsiveness",
|
|
dependencies: [
|
|
"NIOHTTPTypes",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "HTTPTypes", package: "swift-http-types"),
|
|
.product(name: "Algorithms", package: "swift-algorithms"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
.testTarget(
|
|
name: "NIOHTTPResponsivenessTests",
|
|
dependencies: [
|
|
"NIOHTTPResponsiveness",
|
|
"NIOHTTPTypes",
|
|
.product(name: "NIOCore", package: "swift-nio"),
|
|
.product(name: "NIOEmbedded", package: "swift-nio"),
|
|
.product(name: "HTTPTypes", package: "swift-http-types"),
|
|
],
|
|
swiftSettings: strictConcurrencySettings
|
|
),
|
|
]
|
|
|
|
let package = Package(
|
|
name: "swift-nio-extras",
|
|
products: [
|
|
.library(name: "NIOExtras", targets: ["NIOExtras"]),
|
|
.library(name: "NIOSOCKS", targets: ["NIOSOCKS"]),
|
|
.library(name: "NIOHTTPCompression", targets: ["NIOHTTPCompression"]),
|
|
.library(name: "NIOHTTPTypes", targets: ["NIOHTTPTypes"]),
|
|
.library(name: "NIOHTTPTypesHTTP1", targets: ["NIOHTTPTypesHTTP1"]),
|
|
.library(name: "NIOHTTPTypesHTTP2", targets: ["NIOHTTPTypesHTTP2"]),
|
|
.library(name: "NIOResumableUpload", targets: ["NIOResumableUpload"]),
|
|
.library(name: "NIOHTTPResponsiveness", targets: ["NIOHTTPResponsiveness"]),
|
|
],
|
|
dependencies: [
|
|
.package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"),
|
|
.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.27.0"),
|
|
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.3.0"),
|
|
.package(url: "https://github.com/apple/swift-http-structured-headers.git", from: "1.2.0"),
|
|
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.2.0"),
|
|
.package(url: "https://github.com/apple/swift-algorithms.git", from: "1.2.0"),
|
|
|
|
],
|
|
targets: targets
|
|
)
|
|
|
|
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
|
|
for target in package.targets {
|
|
switch target.type {
|
|
case .regular, .test, .executable:
|
|
var settings = target.swiftSettings ?? []
|
|
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
|
|
settings.append(.enableUpcomingFeature("MemberImportVisibility"))
|
|
target.swiftSettings = settings
|
|
case .macro, .plugin, .system, .binary:
|
|
() // not applicable
|
|
@unknown default:
|
|
() // we don't know what to do here, do nothing
|
|
}
|
|
}
|
|
// --- END: STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
|