16
16
import Foundation
17
17
import OpenAPIRuntime
18
18
import OpenAPILambda
19
+ // import ServiceLifecycle
19
20
20
21
@main
21
22
struct QuoteServiceImpl : APIProtocol , OpenAPILambdaHttpApi {
@@ -25,8 +26,28 @@ struct QuoteServiceImpl: APIProtocol, OpenAPILambdaHttpApi {
25
26
}
26
27
27
28
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()
30
51
}
31
52
32
53
func getQuote( _ input: Operations . getQuote . Input ) async throws -> Operations . getQuote . Output {
0 commit comments