Skip to content

Commit bab1a4d

Browse files
authored
Merge branch 'main' into sebsto/readme
2 parents a301109 + 25eb6e1 commit bab1a4d

File tree

12 files changed

+68
-8
lines changed

12 files changed

+68
-8
lines changed

Examples/BackgroundTasks/Sources/main.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import AWSLambdaRuntime
16+
17+
#if canImport(FoundationEssentials)
18+
import FoundationEssentials
19+
#else
1620
import Foundation
21+
#endif
1722

1823
struct BackgroundProcessingHandler: LambdaWithBackgroundProcessingHandler {
1924
struct Input: Decodable {

Sources/AWSLambdaRuntime/Context+Foundation.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414

1515
import AWSLambdaRuntimeCore
1616

17+
#if canImport(FoundationEssentials)
18+
import FoundationEssentials
19+
#else
1720
import struct Foundation.Date
21+
#endif
1822

1923
extension LambdaContext {
2024
var deadlineDate: Date {

Sources/AWSLambdaRuntime/Vendored/ByteBuffer-foundation.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@
2626
//
2727
//===----------------------------------------------------------------------===//
2828

29-
import Foundation
3029
import NIOCore
3130

31+
#if canImport(FoundationEssentials)
32+
import FoundationEssentials
33+
#else
34+
import Foundation
35+
#endif
36+
3237
// This is NIO's `NIOFoundationCompat` module which at the moment only adds `ByteBuffer` utility methods
3338
// for Foundation's `Data` type.
3439
//

Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
1615
import Logging
1716
import NIOConcurrencyHelpers
1817
import NIOCore
1918

19+
#if canImport(FoundationEssentials)
20+
import FoundationEssentials
21+
#else
22+
import Foundation
23+
#endif
24+
2025
// We need `@unchecked` Sendable here, as `NIOLockedValueBox` does not understand `sending` today.
2126
// We don't want to use `NIOLockedValueBox` here anyway. We would love to use Mutex here, but this
2227
// sadly crashes the compiler today.

Sources/MockServer/main.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
15+
import Dispatch
1616
import NIOCore
1717
import NIOHTTP1
1818
import NIOPosix
1919

20+
#if canImport(FoundationEssentials)
21+
import FoundationEssentials
22+
#else
23+
import Foundation
24+
#endif
25+
2026
struct MockServer {
2127
private let group: EventLoopGroup
2228
private let host: String

Tests/AWSLambdaRuntimeCoreTests/InvocationTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
1615
import NIOHTTP1
1716
import Testing
1817

1918
@testable import AWSLambdaRuntimeCore
2019

20+
#if canImport(FoundationEssentials)
21+
import FoundationEssentials
22+
#else
23+
import Foundation
24+
#endif
25+
2126
@Suite
2227
struct InvocationTest {
2328
@Test

Tests/AWSLambdaRuntimeCoreTests/LambdaMockClient.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import AWSLambdaRuntimeCore
16-
import Foundation
1716
import Logging
1817
import NIOCore
1918

19+
#if canImport(FoundationEssentials)
20+
import FoundationEssentials
21+
#else
22+
import Foundation
23+
#endif
24+
2025
struct LambdaMockWriter: LambdaRuntimeClientResponseStreamWriter {
2126
var underlying: LambdaMockClient
2227

Tests/AWSLambdaRuntimeCoreTests/LambdaRequestIDTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
1615
import NIOCore
1716
import Testing
1817

1918
@testable import AWSLambdaRuntimeCore
2019

20+
#if canImport(FoundationEssentials)
21+
import FoundationEssentials
22+
#else
23+
import Foundation
24+
#endif
25+
2126
@Suite("LambdaRequestID tests")
2227
struct LambdaRequestIDTest {
2328
@Test
@@ -100,6 +105,7 @@ struct LambdaRequestIDTest {
100105
#expect(buffer.readableBytes == readableBeforeRead)
101106
}
102107

108+
#if os(macOS)
103109
@Test
104110
func testInitFromNSStringSuccess() {
105111
let nsString = NSMutableString(capacity: 16)
@@ -121,6 +127,7 @@ struct LambdaRequestIDTest {
121127
#expect(requestID?.uuidString == LambdaRequestID(uuidString: nsString as String)?.uuidString)
122128
#expect(requestID?.uppercased == nsString as String)
123129
}
130+
#endif
124131

125132
@Test
126133
func testUnparse() {

Tests/AWSLambdaRuntimeCoreTests/LambdaRunLoopTests.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation
1615
import Logging
1716
import NIOCore
1817
import Testing
1918

2019
@testable import AWSLambdaRuntimeCore
2120

21+
#if canImport(FoundationEssentials)
22+
import FoundationEssentials
23+
#else
24+
import Foundation
25+
#endif
26+
2227
@Suite
2328
struct LambdaRunLoopTests {
2429
struct MockEchoHandler: StreamingLambdaHandler {

Tests/AWSLambdaRuntimeCoreTests/MockLambdaServer.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
import Foundation // for JSON
1615
import Logging
1716
import NIOCore
1817
import NIOHTTP1
1918
import NIOPosix
2019

2120
@testable import AWSLambdaRuntimeCore
2221

22+
#if canImport(FoundationEssentials)
23+
import FoundationEssentials
24+
#else
25+
import Foundation
26+
#endif
27+
2328
func withMockServer<Result>(
2429
behaviour: some LambdaServerBehavior,
2530
port: Int = 0,

Tests/AWSLambdaRuntimeCoreTests/Utils.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#if canImport(FoundationEssentials)
16+
import FoundationEssentials
17+
#else
1518
import Foundation
19+
#endif
1620

1721
extension Date {
1822
var millisSinceEpoch: Int64 {

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ Background tasks allow code to execute asynchronously after the main response ha
290290
Here is an example of a minimal function that waits 10 seconds after it returned a response but before the handler returns.
291291
```swift
292292
import AWSLambdaRuntime
293+
#if canImport(FoundationEssentials)
294+
import FoundationEssentials
295+
#else
293296
import Foundation
297+
#endif
294298

295299
struct BackgroundProcessingHandler: LambdaWithBackgroundProcessingHandler {
296300
struct Input: Decodable {

0 commit comments

Comments
 (0)