1616import Foundation
1717import OpenAPIRuntime
1818import OpenAPILambda
19+ // import ServiceLifecycle
1920
2021@main
2122struct QuoteServiceImpl : APIProtocol , OpenAPILambdaHttpApi {
@@ -25,8 +26,28 @@ struct QuoteServiceImpl: APIProtocol, OpenAPILambdaHttpApi {
2526 }
2627
2728 static func main( ) async throws {
28- let lambdaRuntime = try LambdaRuntime ( body: Self . handler ( ) )
29- try await lambdaRuntime. run ( )
29+ // when you just need to run the Lambda function, call run()
30+ try await Self . run ( )
31+
32+ // when you need to have access to the runtime for advanced usage (dependency injection, Service LifeCycle, etc)
33+ // create the LambdaRuntime and run it
34+
35+ // here is an example with Service Lifecycle
36+ // Add the follwing in Package.swift
37+ // .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.0"),
38+ // and
39+ // .product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
40+ // Add `import ServiceLifecycle` at the top of this file`
41+
42+ // let lambdaRuntime = try LambdaRuntime(body: Self.handler())
43+ // try await lambdaRuntime.run()
44+ // let serviceGroup = ServiceGroup(
45+ // services: [lambdaRuntime],
46+ // gracefulShutdownSignals: [.sigterm],
47+ // cancellationSignals: [.sigint],
48+ // logger: Logger(label: "ServiceGroup")
49+ // )
50+ // try await serviceGroup.run()
3051 }
3152
3253 func getQuote( _ input: Operations . getQuote . Input ) async throws -> Operations . getQuote . Output {
0 commit comments