From 178ce559d5dfb8635f82a97bbba91a480192c911 Mon Sep 17 00:00:00 2001 From: tomer doron Date: Fri, 8 Dec 2023 13:17:59 -0800 Subject: [PATCH] another name! --- Sources/AWSLambdaRuntimeCore/Lambda.swift | 9 +++----- .../AWSLambdaRuntimeCore/LambdaHandler.swift | 6 ++--- .../AWSLambdaRuntimeCore/LambdaRunner.swift | 4 ++-- .../AWSLambdaRuntimeCore/LambdaRuntime.swift | 22 +++++++++---------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Sources/AWSLambdaRuntimeCore/Lambda.swift b/Sources/AWSLambdaRuntimeCore/Lambda.swift index a0aaaf38..5bd0adb9 100644 --- a/Sources/AWSLambdaRuntimeCore/Lambda.swift +++ b/Sources/AWSLambdaRuntimeCore/Lambda.swift @@ -89,18 +89,15 @@ public enum Lambda { Self.run(configuration: configuration, handlerProvider: handlerType.makeHandler(context:)) } - /// Run a Lambda defined by implementing the ``ByteBufferLambdaHandler`` protocol. - /// The Runtime will manage the Lambdas application lifecycle automatically. It will invoke the - /// ``ByteBufferLambdaHandler/makeHandler(context:)`` to create a new Handler. - /// + /// Run a Lambda defined by implementing the ``LambdaRuntimeHandler`` protocol. /// - parameters: /// - configuration: A Lambda runtime configuration object - /// - handlerProvider: A provider of the Handler to invoke. + /// - handlerProvider: A provider of the ``LambdaRuntimeHandler``` to invoke. /// /// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine. internal static func run( configuration: LambdaConfiguration = .init(), - handlerProvider: @escaping (LambdaInitializationContext) -> EventLoopFuture + handlerProvider: @escaping (LambdaInitializationContext) -> EventLoopFuture ) -> Result { let _run = { (configuration: LambdaConfiguration) -> Result in #if swift(<5.9) diff --git a/Sources/AWSLambdaRuntimeCore/LambdaHandler.swift b/Sources/AWSLambdaRuntimeCore/LambdaHandler.swift index 95dc2ebc..bc24e28c 100644 --- a/Sources/AWSLambdaRuntimeCore/LambdaHandler.swift +++ b/Sources/AWSLambdaRuntimeCore/LambdaHandler.swift @@ -398,7 +398,7 @@ extension EventLoopLambdaHandler { /// - note: This is a low level protocol designed to power the higher level ``EventLoopLambdaHandler`` and /// ``LambdaHandler`` based APIs. /// Most users are not expected to use this protocol. -public protocol ByteBufferLambdaHandler: NonInitializingByteBufferLambdaHandler { +public protocol ByteBufferLambdaHandler: LambdaRuntimeHandler { /// Create a Lambda handler for the runtime. /// /// Use this to initialize all your resources that you want to cache between invocations. This could be database @@ -433,7 +433,7 @@ extension ByteBufferLambdaHandler { } } -// MARK: - NonInitializingByteBufferLambdaHandler +// MARK: - LambdaRuntimeHandler /// An `EventLoopFuture` based processing protocol for a Lambda that takes a `ByteBuffer` and returns /// an optional `ByteBuffer` asynchronously. @@ -442,7 +442,7 @@ extension ByteBufferLambdaHandler { /// runtime with a handler outside the normal initialization of /// ``ByteBufferLambdaHandler``, ``EventLoopLambdaHandler`` and ``LambdaHandler`` based APIs. /// Most users are not expected to use this protocol. -public protocol NonInitializingByteBufferLambdaHandler { +public protocol LambdaRuntimeHandler { /// The Lambda handling method. /// Concrete Lambda handlers implement this method to provide the Lambda functionality. /// diff --git a/Sources/AWSLambdaRuntimeCore/LambdaRunner.swift b/Sources/AWSLambdaRuntimeCore/LambdaRunner.swift index 72d04848..9557f41f 100644 --- a/Sources/AWSLambdaRuntimeCore/LambdaRunner.swift +++ b/Sources/AWSLambdaRuntimeCore/LambdaRunner.swift @@ -33,7 +33,7 @@ internal final class LambdaRunner { /// Run the user provided initializer. This *must* only be called once. /// /// - Returns: An `EventLoopFuture` fulfilled with the outcome of the initialization. - func initialize( + func initialize( handlerProvider: @escaping (LambdaInitializationContext) -> EventLoopFuture, logger: Logger, terminator: LambdaTerminator @@ -63,7 +63,7 @@ internal final class LambdaRunner { } } - func run(handler: some NonInitializingByteBufferLambdaHandler, logger: Logger) -> EventLoopFuture { + func run(handler: some LambdaRuntimeHandler, logger: Logger) -> EventLoopFuture { logger.debug("lambda invocation sequence starting") // 1. request invocation from lambda runtime engine self.isGettingNextInvocation = true diff --git a/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift b/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift index 155690d9..381574dc 100644 --- a/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift +++ b/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift @@ -19,7 +19,7 @@ import NIOCore /// `LambdaRuntime` manages the Lambda process lifecycle. /// /// Use this API, if you build a higher level web framework which shall be able to run inside the Lambda environment. -public final class LambdaRuntime { +public final class LambdaRuntime { private let eventLoop: EventLoop private let shutdownPromise: EventLoopPromise private let logger: Logger @@ -37,7 +37,7 @@ public final class LambdaRuntime LambdaRuntime { + ) -> LambdaRuntime { LambdaRuntime>( handlerProvider: CodableLambdaHandler.makeHandler(context:), eventLoop: eventLoop, @@ -271,7 +271,7 @@ public enum LambdaRuntimeFactory { _ handlerType: Handler.Type, eventLoop: any EventLoop, logger: Logger - ) -> LambdaRuntime { + ) -> LambdaRuntime { LambdaRuntime>( handlerProvider: CodableEventLoopLambdaHandler.makeHandler(context:), eventLoop: eventLoop, @@ -290,7 +290,7 @@ public enum LambdaRuntimeFactory { _ handlerType: Handler.Type, eventLoop: any EventLoop, logger: Logger - ) -> LambdaRuntime { + ) -> LambdaRuntime { LambdaRuntime( handlerProvider: Handler.makeHandler(context:), eventLoop: eventLoop, @@ -301,11 +301,11 @@ public enum LambdaRuntimeFactory { /// Create a new `LambdaRuntime`. /// /// - parameters: - /// - handlerProvider: A provider of the ``CoreByteBufferLambdaHandler`` the `LambdaRuntime` will manage. + /// - handlerProvider: A provider of the ``Handler`` the `LambdaRuntime` will manage. /// - eventLoop: An `EventLoop` to run the Lambda on. /// - logger: A `Logger` to log the Lambda events. @inlinable - public static func makeRuntime( + public static func makeRuntime( handlerProvider: @escaping (LambdaInitializationContext) -> EventLoopFuture, eventLoop: any EventLoop, logger: Logger @@ -320,11 +320,11 @@ public enum LambdaRuntimeFactory { /// Create a new `LambdaRuntime`. /// /// - parameters: - /// - handlerProvider: A provider of the ``CoreByteBufferLambdaHandler`` the `LambdaRuntime` will manage. + /// - handlerProvider: A provider of the ``Handler`` the `LambdaRuntime` will manage. /// - eventLoop: An `EventLoop` to run the Lambda on. /// - logger: A `Logger` to log the Lambda events. @inlinable - public static func makeRuntime( + public static func makeRuntime( handlerProvider: @escaping (LambdaInitializationContext) async throws -> Handler, eventLoop: any EventLoop, logger: Logger