Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ let packageDependencies: [Package.Dependency] = [
url: "https://github.com/apple/swift-distributed-tracing.git",
from: "1.0.0"
),
.package(
url: "https://github.com/swiftlang/swift-testing.git",
branch: "release/6.0"
),
].appending(
.package(
url: "https://github.com/apple/swift-nio-ssl.git",
Expand Down Expand Up @@ -147,6 +151,13 @@ extension Target.Dependency {
static var dequeModule: Self { .product(name: "DequeModule", package: "swift-collections") }
static var atomics: Self { .product(name: "Atomics", package: "swift-atomics") }
static var tracing: Self { .product(name: "Tracing", package: "swift-distributed-tracing") }
static var testing: Self {
.product(
name: "Testing",
package: "swift-testing",
condition: .when(platforms: [.linux]) // Already included in the toolchain on Darwin
)
}

static var grpcCore: Self { .target(name: "GRPCCore") }
static var grpcInProcessTransport: Self { .target(name: "GRPCInProcessTransport") }
Expand Down Expand Up @@ -402,6 +413,10 @@ extension Target {
.grpcInProcessTransport,
.dequeModule,
.protobuf,
.testing,
],
resources: [
.copy("Configuration/Inputs")
],
swiftSettings: [.swiftLanguageMode(.v6), .enableUpcomingFeature("ExistentialAny")]
)
Expand Down
1 change: 1 addition & 0 deletions Sources/GRPCCore/Configuration/MethodConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ extension MethodConfig: Codable {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.names, forKey: .name)
try container.encodeIfPresent(self.waitForReady, forKey: .waitForReady)
try container.encodeIfPresent(
self.timeout.map { GoogleProtobufDuration(duration: $0) },
forKey: .timeout
Expand Down
19 changes: 19 additions & 0 deletions Sources/GRPCCore/RPCError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,25 @@ extension RPCError {
public var description: String {
String(describing: self.wrapped)
}

package static let all: [Self] = [
.cancelled,
.unknown,
.invalidArgument,
.deadlineExceeded,
.notFound,
.alreadyExists,
.permissionDenied,
.resourceExhausted,
.failedPrecondition,
.aborted,
.outOfRange,
.unimplemented,
.internalError,
.unavailable,
.dataLoss,
.unauthenticated,
]
}
}

Expand Down
20 changes: 20 additions & 0 deletions Sources/GRPCCore/Status.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@ extension Status {
public var description: String {
String(describing: self.wrapped)
}

package static let all: [Self] = [
.ok,
.cancelled,
.unknown,
.invalidArgument,
.deadlineExceeded,
.notFound,
.alreadyExists,
.permissionDenied,
.resourceExhausted,
.failedPrecondition,
.aborted,
.outOfRange,
.unimplemented,
.internalError,
.unavailable,
.dataLoss,
.unauthenticated,
]
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"maxAttempts": 1,
"hedgingDelay": "1s",
"nonFatalStatusCodes": ["ABORTED"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"maxAttempts": 3,
"hedgingDelay": "1s",
"nonFatalStatusCodes": ["ABORTED"]
}
12 changes: 12 additions & 0 deletions Tests/GRPCCoreTests/Configuration/Inputs/method_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": [
{
"service": "echo.Echo",
"method": "Get"
}
],
"waitForReady": true,
"timeout": "1s",
"maxRequestMessageBytes": 1024,
"maxResponseMessageBytes": 2048
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"service": "foo.bar",
"method": "baz"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"service": "foo.bar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"maxAttempts": 3,
"initialBackoff": "1s",
"maxBackoff": "3s",
"backoffMultiplier": -1.6,
"retryableStatusCodes": ["ABORTED", "UNAVAILABLE"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"maxAttempts": 3,
"initialBackoff": "0s",
"maxBackoff": "3s",
"backoffMultiplier": 1.6,
"retryableStatusCodes": ["ABORTED", "UNAVAILABLE"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"maxAttempts": 1,
"initialBackoff": "1s",
"maxBackoff": "3s",
"backoffMultiplier": 1.6,
"retryableStatusCodes": ["ABORTED", "UNAVAILABLE"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"maxAttempts": 3,
"initialBackoff": "1s",
"maxBackoff": "0s",
"backoffMultiplier": 1.6,
"retryableStatusCodes": ["ABORTED", "UNAVAILABLE"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"maxAttempts": 3,
"initialBackoff": "1s",
"maxBackoff": "3s",
"backoffMultiplier": 1.6,
"retryableStatusCodes": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"maxAttempts": 3,
"initialBackoff": "1s",
"maxBackoff": "3s",
"backoffMultiplier": 1.6,
"retryableStatusCodes": ["ABORTED", "UNAVAILABLE"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": [
{
"service": "echo.Echo",
"method": "Get"
}
],
"waitForReady": true,
"timeout": "1s",
"maxRequestMessageBytes": 1024,
"maxResponseMessageBytes": 2048,
"hedgingPolicy": {
"maxAttempts": 3,
"hedgingDelay": "42s",
"nonFatalStatusCodes": [
"ABORTED",
"UNIMPLEMENTED"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": [
{
"service": "echo.Echo",
"method": "Get"
}
],
"waitForReady": true,
"timeout": "1s",
"maxRequestMessageBytes": 1024,
"maxResponseMessageBytes": 2048,
"retryPolicy": {
"maxAttempts": 3,
"initialBackoff": "1s",
"maxBackoff": "3s",
"backoffMultiplier": 1.6,
"retryableStatusCodes": [
"ABORTED",
"UNIMPLEMENTED"
]
}
}
Loading
Loading