Skip to content

Commit

Permalink
Merge pull request #128 from amzn/code_cleanup_conditional_compilation
Browse files Browse the repository at this point in the history
Code cleanup: Remove conditional compilation for unsupported Swift versions
  • Loading branch information
tachyonics committed Sep 8, 2023
2 parents bb0fb34 + 2137785 commit 744d16f
Show file tree
Hide file tree
Showing 26 changed files with 5 additions and 143 deletions.
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"repositoryURL": "https://github.com/swift-server/async-http-client.git",
"state": {
"branch": null,
"revision": "78db67e5bf4a8543075787f228e8920097319281",
"version": "1.18.0"
"revision": "16f7e62c08c6969899ce6cc277041e868364e5cf",
"version": "1.19.0"
}
},
{
"package": "smoke-http",
"repositoryURL": "https://github.com/amzn/smoke-http.git",
"state": {
"branch": null,
"revision": "84e6805ca07f9e4d7c39fbf61b7feff0484ee67f",
"version": "2.21.0"
"revision": "0176ddefd733d27a4b98e5249b1a4ef236107eb5",
"version": "2.22.0"
}
},
{
Expand Down
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.4
// swift-tools-version:5.6
//
// Copyright 2018-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
Expand Down
14 changes: 0 additions & 14 deletions Sources/SmokeHTTP1/StandardSmokeHTTP1Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import SmokeInvocation

private struct ServerShutdownDetails {
let completionHandlers: [() -> Void]
#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)
let awaitingContinuations: [CheckedContinuation<Void, Error>]
#endif
}

/**
Expand All @@ -53,9 +51,7 @@ public class StandardSmokeHTTP1Server<HTTP1RequestHandlerType: HTTP1RequestHandl
case shutDown
}
private var shutdownCompletionHandlers: [() -> Void] = []
#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)
private var shutdownWaitingContinuations: [CheckedContinuation<Void, Error>] = []
#endif
private var serverState: State = .initialized
private var stateLock: NSLock = NSLock()

Expand Down Expand Up @@ -243,10 +239,8 @@ public class StandardSmokeHTTP1Server<HTTP1RequestHandlerType: HTTP1RequestHandl
// execute all the completion handlers
serverShutdownDetails.completionHandlers.forEach { self.shutdownCompletionHandlerInvocationStrategy.invoke(handler: $0) }

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)
// resume any continuations
serverShutdownDetails.awaitingContinuations.forEach { $0.resume(returning: ()) }
#endif

if self.ownEventLoopGroup {
try self.eventLoopGroup.syncShutdownGracefully()
Expand All @@ -273,7 +267,6 @@ public class StandardSmokeHTTP1Server<HTTP1RequestHandlerType: HTTP1RequestHandl
}
}

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)
public func untilShutdown() async throws {
return try await withCheckedThrowingContinuation { cont in
if !addContinuationIfShutdown(newContinuation: cont) {
Expand All @@ -284,7 +277,6 @@ public class StandardSmokeHTTP1Server<HTTP1RequestHandlerType: HTTP1RequestHandl
}
}
}
#endif

/**
Blocks until the server has been shutdown and all completion handlers
Expand Down Expand Up @@ -393,14 +385,10 @@ public class StandardSmokeHTTP1Server<HTTP1RequestHandlerType: HTTP1RequestHandl
let completionHandlers = self.shutdownCompletionHandlers
self.shutdownCompletionHandlers = []

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)
let waitingContinuations = self.shutdownWaitingContinuations
self.shutdownWaitingContinuations = []

return ServerShutdownDetails(completionHandlers: completionHandlers, awaitingContinuations: waitingContinuations)
#else
return ServerShutdownDetails(completionHandlers: completionHandlers)
#endif
}

/**
Expand Down Expand Up @@ -447,7 +435,6 @@ public class StandardSmokeHTTP1Server<HTTP1RequestHandlerType: HTTP1RequestHandl
return false
}

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)
public func addContinuationIfShutdown(newContinuation: CheckedContinuation<Void, Error>) -> Bool {
stateLock.lock()
defer {
Expand All @@ -462,5 +449,4 @@ public class StandardSmokeHTTP1Server<HTTP1RequestHandlerType: HTTP1RequestHandl

return false
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperations
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import Logging
import Tracing
Expand Down Expand Up @@ -84,5 +82,3 @@ public extension OperationHandler {
ignoreInvocationStrategy: true)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperations
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import Logging
import Tracing
Expand Down Expand Up @@ -88,5 +86,3 @@ public extension OperationHandler {
ignoreInvocationStrategy: true)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperations
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import Logging
import Tracing
Expand Down Expand Up @@ -90,5 +88,3 @@ public extension OperationHandler {
ignoreInvocationStrategy: true)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperations
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import Logging
import Tracing
Expand Down Expand Up @@ -94,5 +92,3 @@ public extension OperationHandler {
ignoreInvocationStrategy: true)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import SmokeInvocation
import SmokeOperations
import Logging

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

/**
A protocol for initialization SmokeFramework-based applications that require a per-invocation context.
Expand Down Expand Up @@ -63,4 +61,3 @@ public extension SmokeAsyncPerInvocationContextInitializer {
return SmokeReportingConfiguration()
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import SmokeInvocation
import SmokeOperations
import Logging

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

/**
A protocol for initialization SmokeFramework-based applications that require a static context.
Expand Down Expand Up @@ -61,4 +59,3 @@ public extension SmokeAsyncStaticContextInitializer {
return SmokeReportingConfiguration()
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperationsHTTP1
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import SmokeOperations
import NIOHTTP1
Expand Down Expand Up @@ -150,5 +148,3 @@ public extension SmokeHTTP1HandlerSelector {
operationDelegate: operationDelegate)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperationsHTTP1
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import SmokeOperations
import NIOHTTP1
Expand Down Expand Up @@ -158,5 +156,3 @@ public extension SmokeHTTP1HandlerSelector {
allowedErrors: allowedErrors)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperationsHTTP1
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import SmokeOperations
import NIOHTTP1
Expand Down Expand Up @@ -163,5 +161,3 @@ public extension SmokeHTTP1HandlerSelector {
addHandlerForOperation(operationIdentifer, httpMethod: httpMethod, handler: handler)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperationsHTTP1
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import SmokeOperations
import NIOHTTP1
Expand Down Expand Up @@ -195,5 +193,3 @@ public extension SmokeHTTP1HandlerSelector {
addHandlerForOperation(operationIdentifer, httpMethod: httpMethod, handler: handler)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperationsHTTP1
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import SmokeOperations
import NIOHTTP1
Expand Down Expand Up @@ -167,5 +165,3 @@ public extension SmokeHTTP1HandlerSelector {
addHandlerForOperation(operationIdentifer, httpMethod: httpMethod, handler: handler)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// SmokeOperationsHTTP1
//

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

import Foundation
import SmokeOperations
import NIOHTTP1
Expand Down Expand Up @@ -199,5 +197,3 @@ public extension SmokeHTTP1HandlerSelector {
addHandlerForOperation(operationIdentifer, httpMethod: httpMethod, handler: handler)
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import Foundation
import SmokeOperationsHTTP1
import SmokeHTTP1

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

public protocol SmokeAsyncServerPerInvocationContextInitializer: SmokeAsyncPerInvocationContextInitializer {

var port: Int { get }
Expand Down Expand Up @@ -51,4 +49,3 @@ public extension SmokeAsyncServerPerInvocationContextInitializer {
return false
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import Foundation
import SmokeOperationsHTTP1
import SmokeHTTP1

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

public protocol SmokeAsyncServerStaticContextInitializer: SmokeAsyncStaticContextInitializer {

var port: Int { get }
Expand Down Expand Up @@ -51,4 +49,3 @@ public extension SmokeAsyncServerStaticContextInitializer {
return false
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ public extension SmokeHTTP1Server {
}
}

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)
static func runAsOperationServer<InitializerType: SmokeAsyncServerStaticContextInitializer, TraceContextType>(
_ factory: @escaping (EventLoopGroup) async throws -> InitializerType) async
where InitializerType.SelectorType.DefaultOperationDelegateType.InvocationReportingType == SmokeServerInvocationReporting<TraceContextType>,
Expand Down Expand Up @@ -450,5 +449,4 @@ public extension SmokeHTTP1Server {
logger.error("Operations Server lifecycle error: '\(error)'")
}
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import SmokeOperationsHTTP1
import SmokeHTTP1
import SmokeOperations

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

/**
A protocol that is derived from `SmokeAsyncServerPerInvocationContextInitializerV3` that uses the `StandardSmokeHTTP1HandlerSelector`
type as the `SelectorType` and `JSONPayloadHTTP1OperationDelegate` as the `DefaultOperationDelegateType`.
Expand All @@ -33,11 +31,7 @@ public protocol StandardJSONSmokeAsyncServerPerInvocationContextInitializer: Smo
StandardSmokeHTTP1HandlerSelector<ContextType, JSONPayloadHTTP1OperationDelegate<SmokeInvocationTraceContext>,
OperationIdentifer> {
associatedtype ContextType
#if swift(>=5.6)
associatedtype OperationIdentifer
#else
associatedtype OperationIdentifer: OperationIdentity
#endif

typealias OperationsInitializerType = ((inout StandardSmokeHTTP1HandlerSelector<ContextType, JSONPayloadHTTP1OperationDelegate<SmokeInvocationTraceContext>, OperationIdentifer>) -> Void)
}
Expand All @@ -57,5 +51,3 @@ public extension StandardJSONSmokeAsyncServerPerInvocationContextInitializer {
return JSONPayloadHTTP1OperationDelegate()
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import SmokeOperationsHTTP1
import SmokeHTTP1
import SmokeOperations

#if (os(Linux) && compiler(>=5.5)) || (!os(Linux) && compiler(>=5.5.2)) && canImport(_Concurrency)

/**
A protocol that is derived from `SmokeAsyncServerStaticContextInitializerV3` that uses the `StandardSmokeHTTP1HandlerSelector`
type as the `SelectorType` and `JSONPayloadHTTP1OperationDelegate` as the `DefaultOperationDelegateType`.
Expand All @@ -33,11 +31,7 @@ public protocol StandardJSONSmokeAsyncServerStaticContextInitializer: SmokeAsync
StandardSmokeHTTP1HandlerSelector<ContextType, JSONPayloadHTTP1OperationDelegate<SmokeInvocationTraceContext>,
OperationIdentifer> {
associatedtype ContextType
#if swift(>=5.6)
associatedtype OperationIdentifer
#else
associatedtype OperationIdentifer: OperationIdentity
#endif

typealias OperationsInitializerType = ((inout StandardSmokeHTTP1HandlerSelector<ContextType, JSONPayloadHTTP1OperationDelegate<SmokeInvocationTraceContext>, OperationIdentifer>) -> Void)
}
Expand All @@ -57,5 +51,3 @@ public extension StandardJSONSmokeAsyncServerStaticContextInitializer {
return JSONPayloadHTTP1OperationDelegate()
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ public protocol StandardJSONSmokeServerPerInvocationContextInitializer: SmokeSer
StandardSmokeHTTP1HandlerSelector<ContextType, JSONPayloadHTTP1OperationDelegate<SmokeInvocationTraceContext>,
OperationIdentifer> {
associatedtype ContextType
#if swift(>=5.6)
associatedtype OperationIdentifer
#else
associatedtype OperationIdentifer: OperationIdentity
#endif

typealias OperationsInitializerType = ((inout StandardSmokeHTTP1HandlerSelector<ContextType, JSONPayloadHTTP1OperationDelegate<SmokeInvocationTraceContext>, OperationIdentifer>) -> Void)
}
Expand Down

0 comments on commit 744d16f

Please sign in to comment.