Skip to content

Explicitly only use FoundationEssentials where possible #436

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

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
use only FoundationEssentials
  • Loading branch information
t089 committed Dec 20, 2024
commit f101c60b3aa41de822e5c0b16ac04ab39c27035b
4 changes: 4 additions & 0 deletions Examples/BackgroundTasks/Sources/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//===----------------------------------------------------------------------===//

import AWSLambdaRuntime
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

struct BackgroundProcessingHandler: LambdaWithBackgroundProcessingHandler {
struct Input: Decodable {
Expand Down
4 changes: 4 additions & 0 deletions Sources/AWSLambdaRuntime/Vendored/ByteBuffer-foundation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import NIOCore

// This is NIO's `NIOFoundationCompat` module which at the moment only adds `ByteBuffer` utility methods
Expand Down
4 changes: 4 additions & 0 deletions Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Logging
import NIOConcurrencyHelpers
import NIOCore
Expand Down
5 changes: 5 additions & 0 deletions Sources/MockServer/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import NIOCore
import NIOHTTP1
import NIOPosix
import Dispatch

struct MockServer {
private let group: EventLoopGroup
Expand Down
4 changes: 4 additions & 0 deletions Tests/AWSLambdaRuntimeCoreTests/InvocationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import NIOHTTP1
import Testing

Expand Down
4 changes: 4 additions & 0 deletions Tests/AWSLambdaRuntimeCoreTests/LambdaMockClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//===----------------------------------------------------------------------===//

import AWSLambdaRuntimeCore
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Logging
import NIOCore

Expand Down
6 changes: 6 additions & 0 deletions Tests/AWSLambdaRuntimeCoreTests/LambdaRequestIDTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import NIOCore
import Testing

Expand Down Expand Up @@ -100,6 +104,7 @@ struct LambdaRequestIDTest {
#expect(buffer.readableBytes == readableBeforeRead)
}

#if os(macOS)
@Test
func testInitFromNSStringSuccess() {
let nsString = NSMutableString(capacity: 16)
Expand All @@ -121,6 +126,7 @@ struct LambdaRequestIDTest {
#expect(requestID?.uuidString == LambdaRequestID(uuidString: nsString as String)?.uuidString)
#expect(requestID?.uppercased == nsString as String)
}
#endif

@Test
func testUnparse() {
Expand Down
4 changes: 4 additions & 0 deletions Tests/AWSLambdaRuntimeCoreTests/LambdaRunLoopTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Logging
import NIOCore
import Testing
Expand Down
6 changes: 5 additions & 1 deletion Tests/AWSLambdaRuntimeCoreTests/MockLambdaServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

import Foundation // for JSON
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Logging
import NIOCore
import NIOHTTP1
Expand Down
4 changes: 4 additions & 0 deletions Tests/AWSLambdaRuntimeCoreTests/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension Date {
var millisSinceEpoch: Int64 {
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ Background tasks allow code to execute asynchronously after the main response ha
Here is an example of a minimal function that waits 10 seconds after it returned a response but before the handler returns.
```swift
import AWSLambdaRuntime
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

struct BackgroundProcessingHandler: LambdaWithBackgroundProcessingHandler {
struct Input: Decodable {
Expand Down