Skip to content

Commit 1948755

Browse files
Merge pull request #3 from swift-serverless/fix-unstable-tests
Fix Unstable Tests & Improve Documentation
2 parents 1ed45af + a839d42 commit 1948755

24 files changed

+318
-77
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ generate_docc:
4949
--hosting-base-path "https://swift-serverless.github.io/BreezeLambdaDynamoDBAPI/BreezeDynamoDBService/" \
5050
--output-path docs/BreezeDynamoDBService
5151

52+
preview_docc_lambda_api:
53+
swift package --disable-sandbox preview-documentation --target BreezeLambdaAPI
54+
55+
preview_docc_dynamo_db_service:
56+
swift package --disable-sandbox preview-documentation --target BreezeDynamoDBService
57+
5258
coverage:
5359
llvm-cov export $(TEST_PACKAGE) \
5460
--instr-profile=$(SWIFT_BIN_PATH)/codecov/default.profdata \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Add the dependency `BreezeLambdaDynamoDBAPI` to a package:
1313

1414
```swift
15-
// swift-tools-version:5.7
15+
// swift-tools-version:6.1
1616
// The swift-tools-version declares the minimum version of Swift required to build this package.
1717

1818
import PackageDescription

Sources/BreezeDynamoDBService/BreezeCodable.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ import FoundationEssentials
1818
import Foundation
1919
#endif
2020

21-
/// CodableSendable is a protocol that combines Sendable and Codable.
21+
/// Protocol that combines Sendable and Codable.
2222
public protocol CodableSendable: Sendable, Codable { }
2323

24-
/// BreezeCodable is a protocol that extends CodableSendable to include properties
24+
/// Protocol that extends CodableSendable to include properties
2525
/// for a key, creation date, and update date.
26-
/// It is designed to be used with Breeze services that require these common fields
26+
///
27+
/// BreezeCodable is designed to be used with Breeze services that require these common fields
2728
/// for items stored in a database, such as DynamoDB.
2829
/// - Parameters:
2930
/// - key: A unique identifier for the item.

Sources/BreezeDynamoDBService/BreezeDynamoDBConfig.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
import SotoCore
1616

17-
/// BreezeDynamoDBConfig is a configuration structure for Breeze DynamoDB service.
18-
/// It contains the necessary parameters to connect to a DynamoDB instance, including the region, table name, key name, and an optional endpoint.
17+
/// Configuration structure for Breeze DynamoDB service.
18+
///
19+
/// BreezeDynamoDBConfig contains the necessary parameters to connect to a DynamoDB instance, including the region, table name, key name, and an optional endpoint.
1920
public struct BreezeDynamoDBConfig: Sendable {
2021

2122
/// Initializes a new instance of BreezeDynamoDBConfig.

Sources/BreezeDynamoDBService/BreezeDynamoDBManager.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import struct Foundation.Date
1616
import NIO
1717
import SotoDynamoDB
1818

19-
/// BreezeDynamoDBManager is a manager for handling DynamoDB operations in Breeze.
20-
/// It provides methods to create, read, update, delete, and list items in a DynamoDB table.
19+
/// Manager for handling DynamoDB operations in Breeze.
20+
///
21+
/// BreezeDynamoDBManager provides methods to create, read, update, delete, and list items in a DynamoDB table.
22+
///
2123
/// It conforms to the BreezeDynamoDBManaging protocol, which defines the necessary operations for Breeze's DynamoDB integration.
22-
/// - Note: This manager requires a DynamoDB instance, a table name, and a key name to operate.
24+
/// - Note: BreezeDynamoDBManager requires a DynamoDB instance, a table name, and a key name to operate.
2325
/// It uses the SotoDynamoDB library to interact with AWS DynamoDB services.
2426
public struct BreezeDynamoDBManager: BreezeDynamoDBManaging {
2527

Sources/BreezeDynamoDBService/BreezeDynamoDBManaging.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import SotoDynamoDB
1616

17-
/// BreezeDynamoDBManaging is a protocol that defines the methods for managing DynamoDB items.
17+
/// Defines the methods for managing DynamoDB items.
1818
public protocol BreezeDynamoDBManaging: Sendable {
1919
/// The keyName is the name of the primary key in the DynamoDB table.
2020
var keyName: String { get }
@@ -53,7 +53,6 @@ public protocol BreezeDynamoDBManaging: Sendable {
5353
/// Deletes an item from the DynamoDB table.
5454
/// - Parameter item: The item to delete, conforming to BreezeCodable.
5555
/// - Throws: An error if the item could not be deleted.
56-
/// - Returns: Void if the item was successfully deleted.
5756
/// - Note:
5857
/// - The item must conform to BreezeCodable.
5958
/// - The item must have the same primary key as an existing item in the table.

Sources/BreezeDynamoDBService/BreezeDynamoDBService.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ import AsyncHTTPClient
1717
import ServiceLifecycle
1818
import Logging
1919

20-
/// BreezeDynamoDBServing
21-
/// A protocol that defines the interface for a Breeze DynamoDB service.
22-
/// It provides methods to access the database manager and to gracefully shutdown the service.
20+
/// Defines the interface for a Breeze DynamoDB service.
21+
///
22+
/// Provides methods to access the database manager and to gracefully shutdown the service.
2323
public protocol BreezeDynamoDBServing: Actor {
2424
func dbManager() async -> BreezeDynamoDBManaging
2525
func gracefulShutdown() throws
2626
}
2727

28+
/// Provides methods to access the DynamoDB database manager and to gracefully shutdown the service.
2829
public actor BreezeDynamoDBService: BreezeDynamoDBServing {
2930

3031
private let dbManager: BreezeDynamoDBManaging
@@ -82,20 +83,27 @@ public actor BreezeDynamoDBService: BreezeDynamoDBServing {
8283
}
8384

8485
/// Gracefully shutdown the service and its components.
86+
///
8587
/// - Throws: An error if the shutdown process fails.
8688
/// This method ensures that the AWS client and HTTP client are properly shutdown before marking the service as shutdown.
8789
/// It also logs the shutdown process.
8890
/// This method is idempotent;
8991
/// - Important: This method must be called at leat once to ensure that resources are released properly. If the method is not called, it will lead to a crash.
9092
public func gracefulShutdown() throws {
9193
guard !isShutdown else { return }
94+
isShutdown = true
9295
logger.info("Stopping DynamoDBService...")
9396
try awsClient.syncShutdown()
9497
logger.info("DynamoDBService is stopped.")
9598
logger.info("Stopping HTTPClient...")
9699
try httpClient.syncShutdown()
97100
logger.info("HTTPClient is stopped.")
98-
isShutdown = true
101+
}
102+
103+
deinit {
104+
guard !isShutdown else { return }
105+
try? awsClient.syncShutdown()
106+
try? httpClient.syncShutdown()
99107
}
100108
}
101109

Sources/BreezeDynamoDBService/BreezeHTTPClientConfig.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
import Logging
1616
import NIOCore
1717

18-
/// BreezeClientServiceError defines the errors that can occur in the Breeze Client Service.
18+
/// Defines the errors that can occur in the Breeze Client Service.
1919
public enum BreezeClientServiceError: Error {
2020
case invalidHttpClient
2121
}
2222

23-
/// BreezeHTTPClientConfig is a configuration structure for the Breeze HTTP client.
23+
/// Configuration structure for the Breeze HTTP client.
2424
public struct BreezeHTTPClientConfig: Sendable {
2525

2626
/// Initializes a new instance of BreezeHTTPClientConfig.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"theme": {
3+
"color": {
4+
"header": "#DE5E44",
5+
"documentation-intro-title": "#FFFFFF",
6+
"documentation-intro-fill": "linear-gradient(30deg, #DE5E44, #A2331D)",
7+
"documentation-intro-accent": "#FFFFFF",
8+
"documentation-intro-eyebrow": "#FFFFFF",
9+
"link": "var(--color-header)"
10+
}
11+
}
12+
}

Sources/BreezeDynamoDBService/Foundation+Extension.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import class Foundation.DateFormatter
1616
import struct Foundation.Date
1717
import struct Foundation.TimeZone
1818

19-
/// This file contains extensions for DateFormatter, Date, and String to handle ISO 8601 date formatting and parsing.
19+
/// Entension to DateFormatter to handle ISO 8601.
20+
///
2021
/// These extensions provide a convenient way to convert between `Date` objects and their ISO 8601 string representations.
2122
extension DateFormatter {
2223
static var iso8061: DateFormatter {
@@ -27,6 +28,7 @@ extension DateFormatter {
2728
}
2829
}
2930

31+
/// Entension to Date to handle ISO 8601.
3032
extension Date {
3133
/// Returns a string representation of the date in ISO 8601 format.
3234
var iso8601: String {
@@ -35,6 +37,7 @@ extension Date {
3537
}
3638
}
3739

40+
/// Entension to String to handle ISO 8601.
3841
extension String {
3942
/// Attempts to parse the string as an ISO 8601 date.
4043
var iso8601: Date? {

0 commit comments

Comments
 (0)