Skip to content

Commit d602fa3

Browse files
committed
Address Sendable checks
1 parent b8d89ca commit d602fa3

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Sources/AWSLambdaRuntimeCore/Lambda.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ import Logging
2323
import NIOCore
2424
import NIOPosix
2525

26+
// Workaround for earlier Swift versions.
27+
// Remove and replace `LambdaSendable` with `Sendable` once we fully embrace concurrency.
28+
#if swift(>= 5.5) && canImport(_Concurrency)
29+
public typealias LambdaSendable = Swift.Sendable
30+
#else
31+
public typealias LambdaSendable = Any
32+
#endif
33+
2634
public enum Lambda {
2735
public typealias Handler = ByteBufferLambdaHandler
2836

Sources/AWSLambdaRuntimeCore/LambdaContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import NIOCore
2121
extension Lambda {
2222
/// Lambda runtime initialization context.
2323
/// The Lambda runtime generates and passes the `InitializationContext` to the Lambda factory as an argument.
24-
public struct InitializationContext {
24+
public struct InitializationContext: LambdaSendable {
2525
/// `Logger` to log with
2626
///
2727
/// - note: The `LogLevel` can be configured using the `LOG_LEVEL` environment variable.
@@ -60,7 +60,7 @@ extension Lambda {
6060

6161
/// Lambda runtime context.
6262
/// The Lambda runtime generates and passes the `Context` to the Lambda handler as an argument.
63-
public struct LambdaContext: CustomDebugStringConvertible {
63+
public struct LambdaContext: CustomDebugStringConvertible, LambdaSendable {
6464
final class _Storage {
6565
var requestID: String
6666
var traceID: String

Sources/AWSLambdaRuntimeCore/LambdaHandler.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import NIOCore
2020
#if compiler(>=5.5) && canImport(_Concurrency)
2121
/// Strongly typed, processing protocol for a Lambda that takes a user defined `Event` and returns a user defined `Output` async.
2222
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
23-
public protocol LambdaHandler: EventLoopLambdaHandler {
23+
public protocol LambdaHandler: EventLoopLambdaHandler, Sendable {
2424
/// The Lambda initialization method
2525
/// Use this method to initialize resources that will be used in every request.
2626
///
@@ -69,8 +69,8 @@ extension LambdaHandler {
6969
/// The `EventLoopLambdaHandler` will execute the Lambda on the same `EventLoop` as the core runtime engine, making the processing faster but requires
7070
/// more care from the implementation to never block the `EventLoop`.
7171
public protocol EventLoopLambdaHandler: ByteBufferLambdaHandler {
72-
associatedtype Event
73-
associatedtype Output
72+
associatedtype Event: LambdaSendable
73+
associatedtype Output: LambdaSendable
7474

7575
/// The Lambda handling method
7676
/// Concrete Lambda handlers implement this method to provide the Lambda functionality.

0 commit comments

Comments
 (0)