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

Remove @available annotation from async APIs. #98

Merged
merged 2 commits into from
Nov 3, 2021
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 .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
swift: ["5.4.3", "5.3.3", "5.2.5"]
swift: ["5.4.3", "5.3.3"]
runs-on: ${{ matrix.os }}
steps:
- uses: marcprux/setup-swift@a990bc57c514a77d232b645843ade099af21aa5e
Expand Down
17 changes: 13 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/swift-server/async-http-client.git",
"state": {
"branch": null,
"revision": "8fa7f082b155ea325bcf7b2dbffaf81d4eea1ae4",
"version": "1.5.1"
"revision": "1081b0b0541f535ca088acdb56f5ca5598bc6247",
"version": "1.6.3"
}
},
{
Expand Down Expand Up @@ -46,13 +46,22 @@
"version": "1.10.2"
}
},
{
"package": "swift-nio-http2",
"repositoryURL": "https://github.com/apple/swift-nio-http2.git",
"state": {
"branch": null,
"revision": "326f7f9a8c8c8402e3691adac04911cac9f9d87f",
"version": "1.18.4"
}
},
{
"package": "swift-nio-ssl",
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
"state": {
"branch": null,
"revision": "044f90dfa0a7015446b40f5e578b06343ae1affe",
"version": "2.16.0"
"revision": "5e68c1ded15619bb281b273fa8c2d8fd7f7b2b7d",
"version": "2.16.1"
}
},
{
Expand Down
3 changes: 3 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import PackageDescription

let package = Package(
name: "smoke-http",
platforms: [
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13)
],
products: [
.library(
name: "SmokeHTTPClient",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<img src="https://github.com/amzn/smoke-http/actions/workflows/swift.yml/badge.svg?branch=main" alt="Build - Main Branch">
</a>
<a href="http://swift.org">
<img src="https://img.shields.io/badge/swift-5.2|5.3|5.4|5.5-orange.svg?style=flat" alt="Swift 5.2, 5.3, 5.4 and 5.5 Tested">
<img src="https://img.shields.io/badge/swift-5.3|5.4|5.5-orange.svg?style=flat" alt="Swift 5.3, 5.4 and 5.5 Tested">
</a>
<img src="https://img.shields.io/badge/ubuntu-18.04|20.04-yellow.svg?style=flat" alt="Ubuntu 18.04 and 20.04 Tested">
<img src="https://img.shields.io/badge/CentOS-8-yellow.svg?style=flat" alt="CentOS 8 Tested">
Expand Down
10 changes: 1 addition & 9 deletions Sources/SmokeHTTPClient/HTTPClientRetryConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,7 @@ public struct HTTPClientRetryConfiguration {

if jitter {
if boundedMsInterval > 0 {
#if swift(>=4.2)
return RetryInterval.random(in: 0 ..< boundedMsInterval)
#else
#if os(Linux)
return RetryInterval(random() % Int(boundedMsInterval))
#else
return arc4random_uniform(boundedMsInterval)
#endif
#endif
return RetryInterval.random(in: 0 ..< boundedMsInterval)
} else {
return 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,33 @@
// SmokeHTTPClient
//

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

import Foundation
import NIO
import NIOHTTP1

// Copy of extension from SwiftNIO; can be removed when the version in SwiftNIO removes its @available attribute
internal extension EventLoopFuture {
/// Get the value/error from an `EventLoopFuture` in an `async` context.
///
/// This function can be used to bridge an `EventLoopFuture` into the `async` world. Ie. if you're in an `async`
/// function and want to get the result of this future.
@inlinable
func get() async throws -> Value {
return try await withUnsafeThrowingContinuation { cont in
self.whenComplete { result in
switch result {
case .success(let value):
cont.resume(returning: value)
case .failure(let error):
cont.resume(throwing: error)
}
}
}
}
}

public extension HTTPOperationsClient {

/**
Expand All @@ -36,7 +57,6 @@ public extension HTTPOperationsClient {
- Returns: the response body.
- Throws: If an error occurred during the request.
*/
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
func executeRetriableWithOutput<InputType, OutputType,
InvocationReportingType: HTTPClientInvocationReporting, HandlerDelegateType: HTTPClientInvocationDelegate>(
endpointOverride: URL? = nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// SmokeHTTPClient
//

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

import Foundation
import NIO
Expand All @@ -35,7 +35,6 @@ public extension HTTPOperationsClient {
- retryOnError: function that should return if the provided error is retryable.
- Throws: If an error occurred during the request.
*/
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
func executeRetriableWithoutOutput<InputType,
InvocationReportingType: HTTPClientInvocationReporting, HandlerDelegateType: HTTPClientInvocationDelegate>(
endpointOverride: URL? = nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// SmokeHTTPClient
//

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

import Foundation
import NIO
Expand All @@ -35,7 +35,6 @@ public extension HTTPOperationsClient {
- Returns: the response body.
- Throws: If an error occurred during the request.
*/
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
func executeWithOutput<InputType, OutputType,
InvocationReportingType: HTTPClientInvocationReporting, HandlerDelegateType: HTTPClientInvocationDelegate>(
endpointOverride: URL? = nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// SmokeHTTPClient
//

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

import Foundation
import NIO
Expand All @@ -35,7 +35,6 @@ public extension HTTPOperationsClient {
- invocationContext: context to use for this invocation.
- Throws: If an error occurred during the request.
*/
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
func executeWithoutOutput<InputType,
InvocationReportingType: HTTPClientInvocationReporting, HandlerDelegateType: HTTPClientInvocationDelegate>(
endpointOverride: URL? = nil,
Expand Down