File tree 12 files changed +68
-8
lines changed
Examples/BackgroundTasks/Sources
Tests/AWSLambdaRuntimeCoreTests
12 files changed +68
-8
lines changed Original file line number Diff line number Diff line change 13
13
//===----------------------------------------------------------------------===//
14
14
15
15
import AWSLambdaRuntime
16
+
17
+ #if canImport(FoundationEssentials)
18
+ import FoundationEssentials
19
+ #else
16
20
import Foundation
21
+ #endif
17
22
18
23
struct BackgroundProcessingHandler : LambdaWithBackgroundProcessingHandler {
19
24
struct Input : Decodable {
Original file line number Diff line number Diff line change 14
14
15
15
import AWSLambdaRuntimeCore
16
16
17
+ #if canImport(FoundationEssentials)
18
+ import FoundationEssentials
19
+ #else
17
20
import struct Foundation. Date
21
+ #endif
18
22
19
23
extension LambdaContext {
20
24
var deadlineDate : Date {
Original file line number Diff line number Diff line change 26
26
//
27
27
//===----------------------------------------------------------------------===//
28
28
29
- import Foundation
30
29
import NIOCore
31
30
31
+ #if canImport(FoundationEssentials)
32
+ import FoundationEssentials
33
+ #else
34
+ import Foundation
35
+ #endif
36
+
32
37
// This is NIO's `NIOFoundationCompat` module which at the moment only adds `ByteBuffer` utility methods
33
38
// for Foundation's `Data` type.
34
39
//
Original file line number Diff line number Diff line change 12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
- import Foundation
16
15
import Logging
17
16
import NIOConcurrencyHelpers
18
17
import NIOCore
19
18
19
+ #if canImport(FoundationEssentials)
20
+ import FoundationEssentials
21
+ #else
22
+ import Foundation
23
+ #endif
24
+
20
25
// We need `@unchecked` Sendable here, as `NIOLockedValueBox` does not understand `sending` today.
21
26
// We don't want to use `NIOLockedValueBox` here anyway. We would love to use Mutex here, but this
22
27
// sadly crashes the compiler today.
Original file line number Diff line number Diff line change 12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
- import Foundation
15
+ import Dispatch
16
16
import NIOCore
17
17
import NIOHTTP1
18
18
import NIOPosix
19
19
20
+ #if canImport(FoundationEssentials)
21
+ import FoundationEssentials
22
+ #else
23
+ import Foundation
24
+ #endif
25
+
20
26
struct MockServer {
21
27
private let group : EventLoopGroup
22
28
private let host : String
Original file line number Diff line number Diff line change 12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
- import Foundation
16
15
import NIOHTTP1
17
16
import Testing
18
17
19
18
@testable import AWSLambdaRuntimeCore
20
19
20
+ #if canImport(FoundationEssentials)
21
+ import FoundationEssentials
22
+ #else
23
+ import Foundation
24
+ #endif
25
+
21
26
@Suite
22
27
struct InvocationTest {
23
28
@Test
Original file line number Diff line number Diff line change 13
13
//===----------------------------------------------------------------------===//
14
14
15
15
import AWSLambdaRuntimeCore
16
- import Foundation
17
16
import Logging
18
17
import NIOCore
19
18
19
+ #if canImport(FoundationEssentials)
20
+ import FoundationEssentials
21
+ #else
22
+ import Foundation
23
+ #endif
24
+
20
25
struct LambdaMockWriter : LambdaRuntimeClientResponseStreamWriter {
21
26
var underlying : LambdaMockClient
22
27
Original file line number Diff line number Diff line change 12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
- import Foundation
16
15
import NIOCore
17
16
import Testing
18
17
19
18
@testable import AWSLambdaRuntimeCore
20
19
20
+ #if canImport(FoundationEssentials)
21
+ import FoundationEssentials
22
+ #else
23
+ import Foundation
24
+ #endif
25
+
21
26
@Suite ( " LambdaRequestID tests " )
22
27
struct LambdaRequestIDTest {
23
28
@Test
@@ -100,6 +105,7 @@ struct LambdaRequestIDTest {
100
105
#expect( buffer. readableBytes == readableBeforeRead)
101
106
}
102
107
108
+ #if os(macOS)
103
109
@Test
104
110
func testInitFromNSStringSuccess( ) {
105
111
let nsString = NSMutableString ( capacity: 16 )
@@ -121,6 +127,7 @@ struct LambdaRequestIDTest {
121
127
#expect( requestID? . uuidString == LambdaRequestID ( uuidString: nsString as String ) ? . uuidString)
122
128
#expect( requestID? . uppercased == nsString as String )
123
129
}
130
+ #endif
124
131
125
132
@Test
126
133
func testUnparse( ) {
Original file line number Diff line number Diff line change 12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
- import Foundation
16
15
import Logging
17
16
import NIOCore
18
17
import Testing
19
18
20
19
@testable import AWSLambdaRuntimeCore
21
20
21
+ #if canImport(FoundationEssentials)
22
+ import FoundationEssentials
23
+ #else
24
+ import Foundation
25
+ #endif
26
+
22
27
@Suite
23
28
struct LambdaRunLoopTests {
24
29
struct MockEchoHandler : StreamingLambdaHandler {
Original file line number Diff line number Diff line change 12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
- import Foundation // for JSON
16
15
import Logging
17
16
import NIOCore
18
17
import NIOHTTP1
19
18
import NIOPosix
20
19
21
20
@testable import AWSLambdaRuntimeCore
22
21
22
+ #if canImport(FoundationEssentials)
23
+ import FoundationEssentials
24
+ #else
25
+ import Foundation
26
+ #endif
27
+
23
28
func withMockServer< Result> (
24
29
behaviour: some LambdaServerBehavior ,
25
30
port: Int = 0 ,
Original file line number Diff line number Diff line change 12
12
//
13
13
//===----------------------------------------------------------------------===//
14
14
15
+ #if canImport(FoundationEssentials)
16
+ import FoundationEssentials
17
+ #else
15
18
import Foundation
19
+ #endif
16
20
17
21
extension Date {
18
22
var millisSinceEpoch : Int64 {
Original file line number Diff line number Diff line change @@ -253,7 +253,11 @@ Background tasks allow code to execute asynchronously after the main response ha
253
253
Here is an example of a minimal function that waits 10 seconds after it returned a response but before the handler returns.
254
254
``` swift
255
255
import AWSLambdaRuntime
256
+ #if canImport (FoundationEssentials )
257
+ import FoundationEssentials
258
+ #else
256
259
import Foundation
260
+ #endif
257
261
258
262
struct BackgroundProcessingHandler : LambdaWithBackgroundProcessingHandler {
259
263
struct Input : Decodable {
You can’t perform that action at this time.
0 commit comments