Skip to content

Commit

Permalink
Merge branch 'main' into day/TraceLogs
Browse files Browse the repository at this point in the history
  • Loading branch information
dayaffe authored Jan 9, 2025
2 parents 03736da + 47ff1bb commit 4ec930c
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let package = Package(
],
dependencies: {
var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/awslabs/aws-crt-swift.git", exact: "0.40.0"),
.package(url: "https://github.com/awslabs/aws-crt-swift.git", exact: "0.42.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
]
let isDocCEnabled = ProcessInfo.processInfo.environment["AWS_SWIFT_SDK_ENABLE_DOCC"] != nil
Expand Down
2 changes: 1 addition & 1 deletion Package.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.106.0
0.108.0
2 changes: 1 addition & 1 deletion Package.version.next
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.107.0
0.109.0
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import protocol Foundation.StreamDelegate
/// `InputStream` is exposed as a property, and may be used to stream the data to other components.
///
/// Used to permit SDK streaming request bodies to be used with `URLSession`-based HTTP requests.
class FoundationStreamBridge: NSObject, StreamDelegate {
class FoundationStreamBridge: NSObject, StreamDelegate, @unchecked Sendable {

/// The max number of bytes to buffer between the `ReadableStream` and the Foundation `OutputStream`
/// at any given time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Logging

/// Implement this protocol and add an instance of the implementation to `SDKLoggingSystem` to use custom log handlers.
public protocol SDKLogHandlerFactory {
public protocol SDKLogHandlerFactory: Sendable {
var label: String { get }
func construct(label: String) -> LogHandler
}
2 changes: 1 addition & 1 deletion Sources/ClientRuntime/Telemetry/Logging/SDKLogLevel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Logging

/// Wrapper for Logger.Level; used by SDKLoggingSystem.
public enum SDKLogLevel: String, Codable, CaseIterable {
public enum SDKLogLevel: String, Codable, CaseIterable, Sendable {
case trace
case debug
case info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,26 @@ class PackageManifestGenerator(val ctx: ProtocolGenerator.GenerationContext) {
writer.write(".library(name: \$S, targets: [\$S])", ctx.settings.moduleName, ctx.settings.moduleName)
}

val externalDependencies = dependencies.filter {
it.getProperty("url", String::class.java).getOrNull() != null ||
it.getProperty("scope", String::class.java).getOrNull() != null
}
val externalDependencies = dependencies
.filter {
it.getProperty("url", String::class.java).getOrNull() != null ||
it.getProperty("scope", String::class.java).getOrNull() != null
}

val dependenciesByURL = externalDependencies
.distinctBy {
it.getProperty("url", String::class.java).getOrNull()
?: "${it.getProperty("scope", String::class.java).get()}.${it.packageName}"
}
.sorted()
.sortedBy { it.targetName() }

writer.openBlock("dependencies: [", "],") {
dependenciesByURL.forEach { writePackageDependency(writer, it) }
}

val dependenciesByTarget = externalDependencies
.distinctBy { it.expectProperty("target", String::class.java) + it.packageName }
.sorted()
.distinctBy { it.targetName() + it.packageName }
.sortedBy { it.targetName() }

writer.openBlock("targets: [", "]") {
writer.openBlock(".target(", "),") {
Expand Down Expand Up @@ -84,11 +86,15 @@ class PackageManifestGenerator(val ctx: ProtocolGenerator.GenerationContext) {

private fun writeTargetDependency(writer: SwiftWriter, dependency: SymbolDependency) {
writer.openBlock(".product(", "),") {
val target = dependency.expectProperty("target", String::class.java)
val target = dependency.targetName()
writer.write("name: \$S,", target)
val scope = dependency.getProperty("scope", String::class.java).getOrNull()
val packageName = scope?.let { "$it.${dependency.packageName}" } ?: dependency.packageName
writer.write("package: \$S", packageName)
}
}
}

private fun SymbolDependency.targetName(): String {
return expectProperty("target", String::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,24 @@ class StructureGenerator(
val hasMembers = membersSortedByName.isNotEmpty()

if (hasMembers) {
writer.openBlock("public init(", ")") {
writer.write("public init(")
writer.indent {
for ((index, member) in membersSortedByName.withIndex()) {
val (memberName, memberSymbol) = memberShapeDataContainer.getOrElse(member) { Pair(null, null) }
if (memberName == null || memberSymbol == null) continue
val terminator = if (index == membersSortedByName.size - 1) "" else ","
writer.write("\$L: \$D$terminator", memberName, memberSymbol)
}
}
writer.openBlock("{", "}") {
writer.write(") {")
writer.indent {
val path = "properties.".takeIf { error } ?: ""
membersSortedByName.forEach {
val (memberName, _) = memberShapeDataContainer.getOrElse(it) { return@forEach }
writer.write("self.$path\$L = \$L", memberName, memberName)
}
}
writer.write("}")
} else {
writer.write("public init() { }")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public struct MyTestOperationInput: Swift.Sendable {
public init(
bar: ExampleClientTypes.RenamedGreeting? = nil
)
{
) {
self.bar = bar
}
}
Expand All @@ -54,8 +53,7 @@ public struct MyTestOperationOutput: Swift.Sendable {
public init(
baz: ExampleClientTypes.GreetingStruct? = nil
)
{
) {
self.baz = baz
}
}
Expand Down Expand Up @@ -83,8 +81,7 @@ extension ExampleClientTypes {
public init(
hi: Swift.String? = nil
)
{
) {
self.hi = hi
}
}
Expand Down Expand Up @@ -113,8 +110,7 @@ extension ExampleClientTypes {
public init(
salutation: Swift.String? = nil
)
{
) {
self.salutation = salutation
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public struct EnumInputInput: Swift.Sendable {
public init(
enumHeader: ExampleClientTypes.MyEnum? = nil,
nestedWithEnum: ExampleClientTypes.NestedEnum? = nil
)
{
) {
self.enumHeader = enumHeader
self.nestedWithEnum = nestedWithEnum
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public struct MyStruct: Swift.Sendable {
bar: Swift.Int = 0,
baz: Swift.Int? = nil,
foo: Swift.String? = nil
)
{
) {
self.bar = bar
self.baz = baz
self.foo = foo
Expand Down Expand Up @@ -110,8 +109,7 @@ public struct PrimitiveTypesInput: Swift.Sendable {
primitiveShortVal: Swift.Int16 = 0,
shortVal: Swift.Int16? = nil,
str: Swift.String? = nil
)
{
) {
self.booleanVal = booleanVal
self.byteVal = byteVal
self.doubleVal = doubleVal
Expand Down Expand Up @@ -154,8 +152,7 @@ public struct RecursiveShapesInputOutputNested1: Swift.Sendable {
public init(
foo: Swift.String? = nil,
nested: RecursiveShapesInputOutputNested2? = nil
)
{
) {
self.foo = foo
self.nested = nested
}
Expand All @@ -168,8 +165,7 @@ public struct RecursiveShapesInputOutputNested2: Swift.Sendable {
public init(
bar: Swift.String? = nil,
recursiveMember: RecursiveShapesInputOutputNested1? = nil
)
{
) {
self.bar = bar
self.recursiveMember = recursiveMember
}
Expand All @@ -181,8 +177,7 @@ public struct RecursiveShapesInputOutput: Swift.Sendable {
public init(
nested: RecursiveShapesInputOutputNested1? = nil
)
{
) {
self.nested = nested
}
}
Expand Down Expand Up @@ -211,8 +206,7 @@ public struct RecursiveShapesInputOutputNestedList1: Swift.Sendable {
public init(
foo: Swift.String? = nil,
recursiveList: [RecursiveShapesInputOutputNested2]? = nil
)
{
) {
self.foo = foo
self.recursiveList = recursiveList
}
Expand All @@ -225,8 +219,7 @@ public struct RecursiveShapesInputOutputNested2: Swift.Sendable {
public init(
bar: Swift.String? = nil,
recursiveMember: RecursiveShapesInputOutputNested1? = nil
)
{
) {
self.bar = bar
self.recursiveMember = recursiveMember
}
Expand All @@ -238,8 +231,7 @@ public struct RecursiveShapesInputOutputLists: Swift.Sendable {
public init(
nested: RecursiveShapesInputOutputNested1? = nil
)
{
) {
self.nested = nested
}
}
Expand Down Expand Up @@ -282,8 +274,7 @@ public struct MyError: ClientRuntime.ModeledError, ClientRuntime.ServiceError, C
public init(
baz: Swift.Int? = nil,
message: Swift.String? = nil
)
{
) {
self.properties.baz = baz
self.properties.message = message
}
Expand Down Expand Up @@ -333,8 +324,7 @@ public struct JsonListsInput: Swift.Sendable {
stringList: [Swift.String]? = nil,
stringSet: Swift.Set<Swift.String>? = nil,
timestampList: [Foundation.Date]? = nil
)
{
) {
self.booleanList = booleanList
self.integerList = integerList
self.nestedStringList = nestedStringList
Expand Down Expand Up @@ -382,8 +372,7 @@ public struct JsonMapsInput: Swift.Sendable {
sparseNumberMap: [Swift.String: Swift.Int?]? = nil,
sparseStringMap: [Swift.String: Swift.String?]? = nil,
sparseStructMap: [Swift.String: ExampleClientTypes.GreetingStruct?]? = nil
)
{
) {
self.denseBooleanMap = denseBooleanMap
self.denseNumberMap = denseNumberMap
self.denseStringMap = denseStringMap
Expand Down Expand Up @@ -420,8 +409,7 @@ public struct JsonMapsOutput: Swift.Sendable {
sparseNumberMap: [Swift.String: Swift.Int?]? = nil,
sparseStringMap: [Swift.String: Swift.String?]? = nil,
sparseStructMap: [Swift.String: ExampleClientTypes.GreetingStruct?]? = nil
)
{
) {
self.denseBooleanMap = denseBooleanMap
self.denseNumberMap = denseNumberMap
self.denseStringMap = denseStringMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public struct RecursiveShapesInput: Swift.Sendable {
public init(
nested: ExampleClientTypes.RecursiveShapesInputOutputNested1? = nil
)
{
) {
self.nested = nested
}
}
Expand All @@ -74,8 +73,7 @@ public struct RecursiveShapesOutput: Swift.Sendable {
public init(
nested: ExampleClientTypes.RecursiveShapesInputOutputNested1? = nil
)
{
) {
self.nested = nested
}
}
Expand All @@ -95,8 +93,7 @@ extension ExampleClientTypes {
public init(
foo: Swift.String? = nil,
nested: ExampleClientTypes.RecursiveShapesInputOutputNested2? = nil
)
{
) {
self.foo = foo
self.nested = nested
}
Expand All @@ -116,8 +113,7 @@ extension ExampleClientTypes {
public init(
bar: Swift.String? = nil,
recursiveMember: ExampleClientTypes.RecursiveShapesInputOutputNested1? = nil
)
{
) {
self.bar = bar
self.recursiveMember = recursiveMember
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public struct ListOfMapsOperationInput: Swift.Sendable {
public init(
targetMaps: [[Swift.String: [Swift.String]]]? = nil
)
{
) {
self.targetMaps = targetMaps
}
}
Expand Down

0 comments on commit 4ec930c

Please sign in to comment.