Skip to content

Commit

Permalink
another name!
Browse files Browse the repository at this point in the history
  • Loading branch information
tomerd committed Dec 8, 2023
1 parent 729e0dc commit 178ce55
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
9 changes: 3 additions & 6 deletions Sources/AWSLambdaRuntimeCore/Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<some NonInitializingByteBufferLambdaHandler>
handlerProvider: @escaping (LambdaInitializationContext) -> EventLoopFuture<some LambdaRuntimeHandler>
) -> Result<Int, Error> {
let _run = { (configuration: LambdaConfiguration) -> Result<Int, Error> in
#if swift(<5.9)
Expand Down
6 changes: 3 additions & 3 deletions Sources/AWSLambdaRuntimeCore/LambdaHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
///
Expand Down
4 changes: 2 additions & 2 deletions Sources/AWSLambdaRuntimeCore/LambdaRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal final class LambdaRunner {
/// Run the user provided initializer. This *must* only be called once.
///
/// - Returns: An `EventLoopFuture<LambdaHandler>` fulfilled with the outcome of the initialization.
func initialize<Handler: NonInitializingByteBufferLambdaHandler>(
func initialize<Handler: LambdaRuntimeHandler>(
handlerProvider: @escaping (LambdaInitializationContext) -> EventLoopFuture<Handler>,
logger: Logger,
terminator: LambdaTerminator
Expand Down Expand Up @@ -63,7 +63,7 @@ internal final class LambdaRunner {
}
}

func run(handler: some NonInitializingByteBufferLambdaHandler, logger: Logger) -> EventLoopFuture<Void> {
func run(handler: some LambdaRuntimeHandler, logger: Logger) -> EventLoopFuture<Void> {
logger.debug("lambda invocation sequence starting")
// 1. request invocation from lambda runtime engine
self.isGettingNextInvocation = true
Expand Down
22 changes: 11 additions & 11 deletions Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Handler: NonInitializingByteBufferLambdaHandler> {
public final class LambdaRuntime<Handler: LambdaRuntimeHandler> {
private let eventLoop: EventLoop
private let shutdownPromise: EventLoopPromise<Int>
private let logger: Logger
Expand All @@ -37,7 +37,7 @@ public final class LambdaRuntime<Handler: NonInitializingByteBufferLambdaHandler
/// Create a new `LambdaRuntime`.
///
/// - parameters:
/// - handlerProvider: A provider of the ``ByteBufferLambdaHandler`` 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.
@usableFromInline
Expand All @@ -57,7 +57,7 @@ public final class LambdaRuntime<Handler: NonInitializingByteBufferLambdaHandler
/// Create a new `LambdaRuntime`.
///
/// - parameters:
/// - handlerProvider: A provider of the ``ByteBufferLambdaHandler`` 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.
init(
Expand Down Expand Up @@ -200,7 +200,7 @@ public final class LambdaRuntime<Handler: NonInitializingByteBufferLambdaHandler
private enum State {
case idle
case initializing
case active(LambdaRunner, any NonInitializingByteBufferLambdaHandler)
case active(LambdaRunner, any LambdaRuntimeHandler)
case shuttingdown
case shutdown

Expand Down Expand Up @@ -252,7 +252,7 @@ public enum LambdaRuntimeFactory {
_ handlerType: Handler.Type,
eventLoop: any EventLoop,
logger: Logger
) -> LambdaRuntime<some NonInitializingByteBufferLambdaHandler> {
) -> LambdaRuntime<some LambdaRuntimeHandler> {
LambdaRuntime<CodableLambdaHandler<Handler>>(
handlerProvider: CodableLambdaHandler<Handler>.makeHandler(context:),
eventLoop: eventLoop,
Expand All @@ -271,7 +271,7 @@ public enum LambdaRuntimeFactory {
_ handlerType: Handler.Type,
eventLoop: any EventLoop,
logger: Logger
) -> LambdaRuntime<some NonInitializingByteBufferLambdaHandler> {
) -> LambdaRuntime<some LambdaRuntimeHandler> {
LambdaRuntime<CodableEventLoopLambdaHandler<Handler>>(
handlerProvider: CodableEventLoopLambdaHandler<Handler>.makeHandler(context:),
eventLoop: eventLoop,
Expand All @@ -290,7 +290,7 @@ public enum LambdaRuntimeFactory {
_ handlerType: Handler.Type,
eventLoop: any EventLoop,
logger: Logger
) -> LambdaRuntime<some NonInitializingByteBufferLambdaHandler> {
) -> LambdaRuntime<some LambdaRuntimeHandler> {
LambdaRuntime<Handler>(
handlerProvider: Handler.makeHandler(context:),
eventLoop: eventLoop,
Expand All @@ -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<Handler: NonInitializingByteBufferLambdaHandler>(
public static func makeRuntime<Handler: LambdaRuntimeHandler>(
handlerProvider: @escaping (LambdaInitializationContext) -> EventLoopFuture<Handler>,
eventLoop: any EventLoop,
logger: Logger
Expand All @@ -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<Handler: NonInitializingByteBufferLambdaHandler>(
public static func makeRuntime<Handler: LambdaRuntimeHandler>(
handlerProvider: @escaping (LambdaInitializationContext) async throws -> Handler,
eventLoop: any EventLoop,
logger: Logger
Expand Down

0 comments on commit 178ce55

Please sign in to comment.