-
Notifications
You must be signed in to change notification settings - Fork 0
Remove BreezeLambdaService #8
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ public actor BreezeLambdaAPI<T: BreezeCodable>: Service { | |
let timeout: TimeAmount | ||
private let serviceGroup: ServiceGroup | ||
private let apiConfig: any APIConfiguring | ||
private let dynamoDBService: BreezeDynamoDBService | ||
|
||
/// Initializes the BreezeLambdaAPI with the provided API configuration. | ||
/// - Parameter apiConfig: An object conforming to `APIConfiguring` that provides the necessary configuration for the Breeze API. | ||
|
@@ -63,19 +64,18 @@ public actor BreezeLambdaAPI<T: BreezeCodable>: Service { | |
logger: logger | ||
) | ||
let operation = try apiConfig.operation() | ||
let dynamoDBService = await BreezeDynamoDBService( | ||
self.dynamoDBService = BreezeDynamoDBService( | ||
config: config, | ||
httpConfig: httpConfig, | ||
logger: logger | ||
) | ||
let breezeLambdaService = BreezeLambdaService<T>( | ||
dynamoDBService: dynamoDBService, | ||
operation: operation, | ||
logger: logger | ||
) | ||
let dbManager = dynamoDBService.dbManager | ||
let breezeApi = BreezeLambdaHandler<T>(dbManager: dbManager, operation: operation) | ||
let runtime = LambdaRuntime(body: breezeApi.handle) | ||
self.serviceGroup = ServiceGroup( | ||
services: [breezeLambdaService], | ||
gracefulShutdownSignals: [.sigterm, .sigint], | ||
services: [runtime, dynamoDBService], | ||
gracefulShutdownSignals: [.sigint], | ||
cancellationSignals: [.sigterm], | ||
logger: logger | ||
) | ||
} catch { | ||
|
@@ -90,7 +90,12 @@ public actor BreezeLambdaAPI<T: BreezeCodable>: Service { | |
/// The internal ServiceGroup will handle the lifecycle of the BreezeLambdaAPI, including starting and stopping the service gracefully. | ||
public func run() async throws { | ||
logger.info("Starting BreezeLambdaAPI...") | ||
try await serviceGroup.run() | ||
do { | ||
try await serviceGroup.run() | ||
} catch { | ||
try dynamoDBService.syncShutdown() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the life cycle group must do that. You should not shutdown() or cancel() a service part of the group There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, it does unless there is a failure condition. Without this |
||
throw error | ||
} | ||
logger.info("BreezeLambdaAPI is stopped successfully") | ||
} | ||
} |
This file was deleted.
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.
Are you shutting down immediately at run() ? Does it work ? Why ?
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.
The function
try await gracefulShutdown()
waits until graceful shutdown is triggered as documented in ServiceLifecyclehttps://swiftpackageindex.com/swift-server/swift-service-lifecycle/main/documentation/servicelifecycle/gracefulshutdown()