So I am curious about something. I'm playing around with the new-ish v2 Swift for Lambda package and trying to adapt my v1 code for v2. In the v1 days, if I had a client (let's call it Vapor's MySQLKit client because that's what it is), I could get a reference to the Lambda event loop by implementing init(context: LambdaInitializationContext) for my LambdaHandler and then asking for context.eventLoop. The cool thing about that is that I could use that event loop to setup the MySQLKit client:
// Use the same (NIO) event loop that the AWS handler uses for MySQL
// queries ... this is okay since any MySQL protocol handling will not
// block the event loop
self.pool = EventLoopGroupConnectionPool(
source: mySQLConnectionSource,
on: context.eventLoop
)
I gather that in Swift4Lambda v2, there is a conscious move away from EventLoops…but it still looks like EventLoops are being used…at least for now…and certainly they're still needed to setup MySQLKit. Now I see that I could, in principle, do something like this:
let runtime = LambdaRuntime(body: handler.handle)
let eventLoop = runtime.eventLoop
…buuuuut, even though eventLoop is a property of LambdaRuntime, it's inaccessible.
Now, of course, I could just explicitly create an EventLoopGroup for MySQLKit…that should totally work…but I always thought it was kind of clever to piggyback on Lambda's event loop since it already exists. I am wondering whether this is still do-able in the v2 world.
I hope this makes sense.