From 8eb9fb13228f82b35929be09500e7a97852cc224 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Sun, 1 Mar 2026 13:04:57 +0100 Subject: [PATCH] propagate isSingleConcurrencyMode from Lambda to LambadRuntime and LambdaManagedRuntime --- Sources/AWSLambdaRuntime/Lambda.swift | 28 +++++++++++++++++-- .../ManagedRuntime/LambdaManagedRuntime.swift | 6 ++-- .../Runtime/LambdaRuntime.swift | 12 +++++--- .../LambdaRunLoopTests.swift | 6 ++-- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/Sources/AWSLambdaRuntime/Lambda.swift b/Sources/AWSLambdaRuntime/Lambda.swift index c4bcf39f..8bc014b8 100644 --- a/Sources/AWSLambdaRuntime/Lambda.swift +++ b/Sources/AWSLambdaRuntime/Lambda.swift @@ -36,7 +36,7 @@ public enum Lambda { *, deprecated, message: - "This method will be removed in a future major version update. Use runLoop(runtimeClient:handler:loggingConfiguration:logger:) instead." + "This method will be removed in a future major version update. Use runLoop(runtimeClient:handler:loggingConfiguration:logger:isSingleConcurrencyMode:) instead." ) @inlinable package static func runLoop( @@ -48,16 +48,40 @@ public enum Lambda { runtimeClient: runtimeClient, handler: handler, loggingConfiguration: LoggingConfiguration(logger: logger), - logger: logger + logger: logger, + isSingleConcurrencyMode: true ) } + @available( + *, + deprecated, + message: + "This method will be removed in a future major version update. Use runLoop(runtimeClient:handler:loggingConfiguration:logger:isSingleConcurrencyMode:) instead." + ) @inlinable package static func runLoop( runtimeClient: RuntimeClient, handler: Handler, loggingConfiguration: LoggingConfiguration, logger: Logger + ) async throws where Handler: StreamingLambdaHandler { + try await self.runLoop( + runtimeClient: runtimeClient, + handler: handler, + loggingConfiguration: LoggingConfiguration(logger: logger), + logger: logger, + isSingleConcurrencyMode: true + ) + } + + @inlinable + package static func runLoop( + runtimeClient: RuntimeClient, + handler: Handler, + loggingConfiguration: LoggingConfiguration, + logger: Logger, + isSingleConcurrencyMode: Bool ) async throws where Handler: StreamingLambdaHandler { var handler = handler diff --git a/Sources/AWSLambdaRuntime/ManagedRuntime/LambdaManagedRuntime.swift b/Sources/AWSLambdaRuntime/ManagedRuntime/LambdaManagedRuntime.swift index 0ad06cba..dce263e8 100644 --- a/Sources/AWSLambdaRuntime/ManagedRuntime/LambdaManagedRuntime.swift +++ b/Sources/AWSLambdaRuntime/ManagedRuntime/LambdaManagedRuntime.swift @@ -96,7 +96,8 @@ public final class LambdaManagedRuntime: Sendable where Handler: Stream handler: self.handler, eventLoop: self.eventLoop, loggingConfiguration: self.loggingConfiguration, - logger: self.logger + logger: self.logger, + isSingleConcurrencyMode: true ) } else { @@ -113,7 +114,8 @@ public final class LambdaManagedRuntime: Sendable where Handler: Stream handler: self.handler, eventLoop: self.eventLoop, loggingConfiguration: self.loggingConfiguration, - logger: logger + logger: logger, + isSingleConcurrencyMode: false ) } } diff --git a/Sources/AWSLambdaRuntime/Runtime/LambdaRuntime.swift b/Sources/AWSLambdaRuntime/Runtime/LambdaRuntime.swift index 953ec98e..1375cf60 100644 --- a/Sources/AWSLambdaRuntime/Runtime/LambdaRuntime.swift +++ b/Sources/AWSLambdaRuntime/Runtime/LambdaRuntime.swift @@ -105,7 +105,8 @@ public final class LambdaRuntime: Sendable where Handler: StreamingLamb handler: handler, eventLoop: self.eventLoop, loggingConfiguration: self.loggingConfiguration, - logger: self.logger + logger: self.logger, + isSingleConcurrencyMode: true ) } else { @@ -126,7 +127,8 @@ public final class LambdaRuntime: Sendable where Handler: StreamingLamb handler: Handler, eventLoop: EventLoop, loggingConfiguration: LoggingConfiguration, - logger: Logger + logger: Logger, + isSingleConcurrencyMode: Bool ) async throws { let ipAndPort = endpoint.split(separator: ":", maxSplits: 1) @@ -143,7 +145,8 @@ public final class LambdaRuntime: Sendable where Handler: StreamingLamb runtimeClient: runtimeClient, handler: handler, loggingConfiguration: loggingConfiguration, - logger: logger + logger: logger, + isSingleConcurrencyMode: isSingleConcurrencyMode ) } } catch { @@ -193,7 +196,8 @@ public final class LambdaRuntime: Sendable where Handler: StreamingLamb runtimeClient: runtimeClient, handler: handler, loggingConfiguration: loggingConfiguration, - logger: logger + logger: logger, + isSingleConcurrencyMode: true ) } } diff --git a/Tests/AWSLambdaRuntimeTests/LambdaRunLoopTests.swift b/Tests/AWSLambdaRuntimeTests/LambdaRunLoopTests.swift index d2484f2a..5e1face8 100644 --- a/Tests/AWSLambdaRuntimeTests/LambdaRunLoopTests.swift +++ b/Tests/AWSLambdaRuntimeTests/LambdaRunLoopTests.swift @@ -69,7 +69,8 @@ struct LambdaRunLoopTests { runtimeClient: mockClient, handler: mockEchoHandler, loggingConfiguration: LoggingConfiguration(logger: logger), - logger: logger + logger: logger, + isSingleConcurrencyMode: true ) } @@ -100,7 +101,8 @@ struct LambdaRunLoopTests { runtimeClient: mockClient, handler: failingHandler, loggingConfiguration: LoggingConfiguration(logger: logger), - logger: logger + logger: logger, + isSingleConcurrencyMode: true ) }