Skip to content

Commit abb15a7

Browse files
committed
Use {request,response}{s,stream} consistently
Motivation: Some of the new async-await APIs are inconsistent in their use of 'requests' vs 'requestStream' and 'responses' vs 'responseStream'. We should name things consistently. Modifications: - Rename 'requests' to 'requestStream' in generated server code - Rename 'responses' to 'responseStream' in client calls Result: More consistent naming.
1 parent ccdf3fd commit abb15a7

File tree

12 files changed

+105
-86
lines changed

12 files changed

+105
-86
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches: [main]
55
pull_request:
6-
branches: [main, async-await, 1.4.1-async-await]
6+
branches: [main, 1.6.0-async-await]
77
jobs:
88
preflight:
99
name: License Header and Formatting Checks
@@ -25,7 +25,7 @@ jobs:
2525
matrix:
2626
include:
2727
- image: swift:5.5-focal
28-
swift-test-flags: "--enable-test-discovery --sanitize=thread"
28+
swift-test-flags: "--enable-test-discovery"
2929
- image: swift:5.4-focal
3030
swift-test-flags: "--enable-test-discovery --sanitize=thread"
3131
- image: swift:5.3-focal
@@ -52,14 +52,6 @@ jobs:
5252
matrix:
5353
include:
5454
- image: swift:5.5-focal
55-
env:
56-
MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_10_requests: 503000
57-
MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_1_request: 215000
58-
MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_10_small_requests: 112000
59-
MAX_ALLOCS_ALLOWED_embedded_server_bidi_1k_rpcs_1_small_request: 67000
60-
MAX_ALLOCS_ALLOWED_embedded_server_unary_1k_rpcs_1_small_request: 63000
61-
MAX_ALLOCS_ALLOWED_unary_1k_ping_pong: 204000
62-
- image: swift:5.4-focal
6355
env:
6456
MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_10_requests: 504000
6557
MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_1_request: 216000

Sources/Examples/Echo/Implementation/EchoAsyncProvider.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ public final class EchoAsyncProvider: Echo_EchoAsyncProvider {
4545
}
4646

4747
public func collect(
48-
requests: GRPCAsyncRequestStream<Echo_EchoRequest>,
48+
requestStream: GRPCAsyncRequestStream<Echo_EchoRequest>,
4949
context: GRPCAsyncServerCallContext
5050
) async throws -> Echo_EchoResponse {
51-
let text = try await requests.reduce(into: "Swift echo collect:") { result, request in
51+
let text = try await requestStream.reduce(into: "Swift echo collect:") { result, request in
5252
result += " \(request.text)"
5353
}
5454

5555
return .with { $0.text = text }
5656
}
5757

5858
public func update(
59-
requests: GRPCAsyncRequestStream<Echo_EchoRequest>,
59+
requestStream: GRPCAsyncRequestStream<Echo_EchoRequest>,
6060
responseStream: GRPCAsyncResponseStreamWriter<Echo_EchoResponse>,
6161
context: GRPCAsyncServerCallContext
6262
) async throws {
6363
var counter = 0
64-
for try await request in requests {
64+
for try await request in requestStream {
6565
let text = "Swift echo update (\(counter)): \(request.text)"
6666
try await responseStream.send(.with { $0.text = text })
6767
counter += 1

Sources/Examples/Echo/Model/echo.grpc.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,13 @@ public protocol Echo_EchoAsyncProvider: CallHandlerProvider {
574574

575575
/// Collects a stream of messages and returns them concatenated when the caller closes.
576576
@Sendable func collect(
577-
requests: GRPCAsyncRequestStream<Echo_EchoRequest>,
577+
requestStream: GRPCAsyncRequestStream<Echo_EchoRequest>,
578578
context: GRPCAsyncServerCallContext
579579
) async throws -> Echo_EchoResponse
580580

581581
/// Streams back messages as they are received in an input stream.
582582
@Sendable func update(
583-
requests: GRPCAsyncRequestStream<Echo_EchoRequest>,
583+
requestStream: GRPCAsyncRequestStream<Echo_EchoRequest>,
584584
responseStream: GRPCAsyncResponseStreamWriter<Echo_EchoResponse>,
585585
context: GRPCAsyncServerCallContext
586586
) async throws
@@ -625,7 +625,7 @@ extension Echo_EchoAsyncProvider {
625625
requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
626626
responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
627627
interceptors: self.interceptors?.makeCollectInterceptors() ?? [],
628-
wrapping: self.collect(requests:context:)
628+
wrapping: self.collect(requestStream:context:)
629629
)
630630

631631
case "Update":
@@ -634,7 +634,7 @@ extension Echo_EchoAsyncProvider {
634634
requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
635635
responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
636636
interceptors: self.interceptors?.makeUpdateInterceptors() ?? [],
637-
wrapping: self.update(requests:responseStream:context:)
637+
wrapping: self.update(requestStream:responseStream:context:)
638638
)
639639

640640
default:

Sources/GRPC/AsyncAwaitSupport/GRPCAsyncBidirectionalStreamingCall.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public struct GRPCAsyncBidirectionalStreamingCall<Request, Response> {
2828
public let requestStream: GRPCAsyncRequestStreamWriter<Request>
2929

3030
/// The stream of responses from the server.
31-
public let responses: GRPCAsyncResponseStream<Response>
31+
public let responseStream: GRPCAsyncResponseStream<Response>
3232

3333
/// The options used to make the RPC.
3434
public var options: CallOptions {
@@ -79,7 +79,7 @@ public struct GRPCAsyncBidirectionalStreamingCall<Request, Response> {
7979
self.call = call
8080
self.responseParts = StreamingResponseParts(on: call.eventLoop) { _ in }
8181
self.responseSource = PassthroughMessageSource<Response, Error>()
82-
self.responses = .init(PassthroughMessageSequence(consuming: self.responseSource))
82+
self.responseStream = .init(PassthroughMessageSequence(consuming: self.responseSource))
8383
self.requestStream = call.makeRequestStreamWriter()
8484
}
8585

Sources/GRPC/AsyncAwaitSupport/GRPCAsyncServerStreamingCall.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public struct GRPCAsyncServerStreamingCall<Request, Response> {
2525
private let responseSource: PassthroughMessageSource<Response, Error>
2626

2727
/// The stream of responses from the server.
28-
public let responses: GRPCAsyncResponseStream<Response>
28+
public let responseStream: GRPCAsyncResponseStream<Response>
2929

3030
/// The options used to make the RPC.
3131
public var options: CallOptions {
@@ -78,7 +78,7 @@ public struct GRPCAsyncServerStreamingCall<Request, Response> {
7878
// invoke the `call`.
7979
self.responseParts = StreamingResponseParts(on: call.eventLoop) { _ in }
8080
self.responseSource = PassthroughMessageSource<Response, Error>()
81-
self.responses = .init(PassthroughMessageSequence(consuming: self.responseSource))
81+
self.responseStream = .init(PassthroughMessageSequence(consuming: self.responseSource))
8282
}
8383

8484
/// We expose this as the only non-private initializer so that the caller

Sources/GRPC/AsyncAwaitSupport/GRPCClient+AsyncAwaitSupport.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ extension GRPCClient {
197197
request: request,
198198
callOptions: callOptions ?? self.defaultCallOptions,
199199
interceptors: interceptors
200-
).responses
200+
).responseStream
201201
}
202202

203203
public func performAsyncServerStreamingCall<Request: GRPCPayload, Response: GRPCPayload>(
@@ -212,7 +212,7 @@ extension GRPCClient {
212212
request: request,
213213
callOptions: callOptions ?? self.defaultCallOptions,
214214
interceptors: interceptors
215-
).responses
215+
).responseStream
216216
}
217217

218218
public func performAsyncClientStreamingCall<
@@ -441,7 +441,7 @@ extension GRPCClient {
441441
}
442442
}
443443
}
444-
return call.responses
444+
return call.responseStream
445445
}
446446
}
447447

0 commit comments

Comments
 (0)