Skip to content

Fix Sendable checking #240

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions Sources/AWSLambdaRuntimeCore/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ import Logging
import NIOCore
import NIOPosix

// Workaround for earlier Swift versions.
// Remove and replace `LambdaSendable` with `Sendable` once we fully embrace concurrency.
#if swift(>=5.5) && canImport(_Concurrency)
public typealias LambdaSendable = Swift.Sendable
#else
public typealias LambdaSendable = Any
#endif

public enum Lambda {
public typealias Handler = ByteBufferLambdaHandler

Expand Down
4 changes: 2 additions & 2 deletions Sources/AWSLambdaRuntimeCore/LambdaContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import NIOCore
extension Lambda {
/// Lambda runtime initialization context.
/// The Lambda runtime generates and passes the `InitializationContext` to the Lambda factory as an argument.
public struct InitializationContext {
public struct InitializationContext: LambdaSendable {
/// `Logger` to log with
///
/// - note: The `LogLevel` can be configured using the `LOG_LEVEL` environment variable.
Expand Down Expand Up @@ -60,7 +60,7 @@ extension Lambda {

/// Lambda runtime context.
/// The Lambda runtime generates and passes the `Context` to the Lambda handler as an argument.
public struct LambdaContext: CustomDebugStringConvertible {
public struct LambdaContext: CustomDebugStringConvertible, LambdaSendable {
final class _Storage {
var requestID: String
var traceID: String
Expand Down
4 changes: 2 additions & 2 deletions Sources/AWSLambdaRuntimeCore/LambdaHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import NIOCore
#if compiler(>=5.5) && canImport(_Concurrency)
/// Strongly typed, processing protocol for a Lambda that takes a user defined `Event` and returns a user defined `Output` async.
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
public protocol LambdaHandler: EventLoopLambdaHandler {
public protocol LambdaHandler: EventLoopLambdaHandler, Sendable {
/// The Lambda initialization method
/// Use this method to initialize resources that will be used in every request.
///
Expand Down Expand Up @@ -69,7 +69,7 @@ extension LambdaHandler {
/// The `EventLoopLambdaHandler` will execute the Lambda on the same `EventLoop` as the core runtime engine, making the processing faster but requires
/// more care from the implementation to never block the `EventLoop`.
public protocol EventLoopLambdaHandler: ByteBufferLambdaHandler {
associatedtype Event
associatedtype Event: LambdaSendable
associatedtype Output

/// The Lambda handling method
Expand Down