-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add new LambdaRuntime #353
Conversation
|
||
/// The default EventLoop the Lambda is scheduled on. | ||
package static var defaultEventLoop: any EventLoop { | ||
get { | ||
NIOSingletons.posixEventLoopGroup.next() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must ensure that the eventLoop remains the same, in multiple invocations.
/// The default EventLoop the Lambda is scheduled on. | |
package static var defaultEventLoop: any EventLoop { | |
get { | |
NIOSingletons.posixEventLoopGroup.next() | |
} | |
} | |
/// The default EventLoop the Lambda is scheduled on. | |
package static let defaultEventLoop: any EventLoop = NIOSingletons.posixEventLoopGroup.next() |
Add test:
@Test
func testDefaultEventLoopRemainsTheSame() {
let eventLoop = Lambda.defaultEventLoop
#expect(eventLoop === Lambda.defaultEventLoop)
}
|
||
let ipAndPort = runtimeEndpoint.split(separator: ":", maxSplits: 1) | ||
let ip = String(ipAndPort[0]) | ||
let port = Int(ipAndPort[1])! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should throw an error here, if the second part is not an Int. .invalidPort
.
let defaultHeaders: HTTPHeaders | ||
/// These headers must be sent along an invocation or initialization error report | ||
let errorHeaders: HTTPHeaders | ||
/// These headers must be sent along an invocation or initialization error report |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code comment is not true.
… codable initializers.
… update env var missing error name
extension NewLambdaRuntime { | ||
/// Initialize an instance with a ``StreamingLambdaHandler`` in the form of a closure. | ||
/// - Parameter body: The handler in the form of a closure. | ||
package convenience init( | ||
body: @Sendable @escaping (ByteBuffer, LambdaResponseStreamWriter, NewLambdaContext) async throws -> Void | ||
) where Handler == StreamingClosureHandler { | ||
self.init(handler: StreamingClosureHandler(body: body)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be in the handler file I guess.
…wift in AWSLambdaRuntimeCore
Motivation:
As part of the implementation of the v2 API (#339), a new
LambdaRuntimeClient
was added (#348) and theLambda.runLoop
function added (#347).This PR adds the
LambdaRuntime
which initializes aLambdaRuntimeClient
and calls theLambda.runLoop
function with it.Modifications:
LambdaRuntime
.defaultEventLoop
property toLambdaContext
.LambdaRuntime
.Result:
The runtime can now be used. A handler can be registered with
LambdaRuntime
and the runtime can be start listening for events through therun()
function.