Skip to content

Commit 95b7710

Browse files
dennycdVignesh2208
authored andcommitted
Revert "Adding flow control support API for GRPCUnaryProtoCall (grpc#26969)" (grpc#27047)
This reverts commit 52fece3.
1 parent b0bc1a0 commit 95b7710

File tree

3 files changed

+7
-202
lines changed

3 files changed

+7
-202
lines changed

src/objective-c/ProtoRPC/ProtoRPC.h

-27
Original file line numberDiff line numberDiff line change
@@ -126,33 +126,6 @@ NS_ASSUME_NONNULL_BEGIN
126126
*/
127127
- (void)cancel;
128128

129-
/**
130-
* Finish the RPC request and half-close the call. The server may still send messages and/or
131-
* trailers to the client. This method should only be used when flow control is enabled. If flow
132-
* control is not enabled, It will be automatically called upon message received.
133-
*/
134-
- (void)finish;
135-
136-
/**
137-
* Tell gRPC to receive another message.
138-
*
139-
* This method should only be used when flow control is enabled. If flow control is enabled, gRPC
140-
* will only receive additional messages after the user indicates so by using either
141-
* receiveNextMessage: or receiveNextMessages: methods. If flow control is not enabled, messages
142-
* will be automatically received after the previous one is delivered.
143-
*/
144-
- (void)receiveNextMessage;
145-
146-
/**
147-
* Tell gRPC to receive another N message.
148-
*
149-
* This method should only be used when flow control is enabled. If flow control is enabled, the
150-
* messages received from the server are buffered in gRPC until the user want to receive the next
151-
* message. If flow control is not enabled, messages will be automatically received after the
152-
* previous one is delivered.
153-
*/
154-
- (void)receiveNextMessages:(NSUInteger)numberOfMessages;
155-
156129
@end
157130

158131
/** A client-streaming RPC call with Protobuf. */

src/objective-c/ProtoRPC/ProtoRPC.m

+5-29
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@
2727
#import <RxLibrary/GRXWriteable.h>
2828
#import <RxLibrary/GRXWriter+Transformations.h>
2929

30-
#pragma mark - GRPCStreamingProtoCall
31-
32-
@interface GRPCStreamingProtoCall () <GRPCResponseHandler>
33-
34-
@property(nonatomic, readonly) GRPCCallOptions *callOptions;
35-
36-
@end
37-
3830
@implementation GRPCUnaryResponseHandler {
3931
void (^_responseHandler)(id, NSError *);
4032
dispatch_queue_t _responseDispatchQueue;
@@ -108,35 +100,25 @@ - (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
108100

109101
- (void)start {
110102
[_call start];
103+
[_call receiveNextMessage];
111104
[_call writeMessage:_message];
112-
113-
if (!_call.callOptions.flowControlEnabled) {
114-
[_call finish];
115-
}
105+
[_call finish];
116106
}
117107

118108
- (void)cancel {
119109
[_call cancel];
120110
}
121111

122-
- (void)finish {
123-
[_call finish];
124-
}
125-
126-
#pragma mark - GRPCControllableProtoCallFlow
112+
@end
127113

128-
- (void)receiveNextMessage {
129-
[_call receiveNextMessage];
130-
}
131-
- (void)receiveNextMessages:(NSUInteger)numberOfMessages {
132-
[_call receiveNextMessages:numberOfMessages];
133-
}
114+
@interface GRPCStreamingProtoCall () <GRPCResponseHandler>
134115

135116
@end
136117

137118
@implementation GRPCStreamingProtoCall {
138119
GRPCRequestOptions *_requestOptions;
139120
id<GRPCProtoResponseHandler> _handler;
121+
GRPCCallOptions *_callOptions;
140122
Class _responseClass;
141123

142124
GRPCCall2 *_call;
@@ -244,8 +226,6 @@ - (void)finish {
244226
[copiedCall finish];
245227
}
246228

247-
#pragma mark - GRPCControllableProtoCallFlow
248-
249229
- (void)receiveNextMessage {
250230
[self receiveNextMessages:1];
251231
}
@@ -257,8 +237,6 @@ - (void)receiveNextMessages:(NSUInteger)numberOfMessages {
257237
[copiedCall receiveNextMessages:numberOfMessages];
258238
}
259239

260-
#pragma mark - GRPCResponseHandler
261-
262240
- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata {
263241
@synchronized(self) {
264242
if (initialMetadata != nil &&
@@ -336,8 +314,6 @@ - (void)didWriteData {
336314
}
337315
}
338316

339-
#pragma mark - GRPCDispatchable
340-
341317
- (dispatch_queue_t)dispatchQueue {
342318
return _dispatchQueue;
343319
}

src/objective-c/tests/InteropTests/InteropTests.m

+2-146
Original file line numberDiff line numberDiff line change
@@ -701,87 +701,6 @@ - (void)testLargeUnaryRPCWithV2API {
701701
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
702702
}
703703

704-
- (void)testUnaryRPCWithV2APIFlowControl {
705-
XCTAssertNotNil([[self class] host]);
706-
__weak XCTestExpectation *expectReceive =
707-
[self expectationWithDescription:@"LargeUnaryWithV2API received message"];
708-
__weak XCTestExpectation *expectComplete =
709-
[self expectationWithDescription:@"LargeUnaryWithV2API received complete"];
710-
711-
const int responseSize = 123;
712-
RMTSimpleRequest *request = [RMTSimpleRequest message];
713-
request.responseType = RMTPayloadType_Compressable;
714-
request.responseSize = responseSize;
715-
request.payload.body = [NSMutableData dataWithLength:456];
716-
717-
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
718-
// For backwards compatibility
719-
options.transportType = [[self class] transportType];
720-
options.transport = [[self class] transport];
721-
options.PEMRootCertificates = [[self class] PEMRootCertificates];
722-
options.hostNameOverride = [[self class] hostNameOverride];
723-
options.flowControlEnabled = YES;
724-
725-
GRPCUnaryProtoCall *call = [_service
726-
unaryCallWithMessage:request
727-
responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
728-
messageCallback:^(id message) {
729-
XCTAssertNotNil(message);
730-
if (message) {
731-
RMTSimpleResponse *expectedResponse =
732-
[RMTSimpleResponse message];
733-
expectedResponse.payload.type = RMTPayloadType_Compressable;
734-
expectedResponse.payload.body =
735-
[NSMutableData dataWithLength:responseSize];
736-
XCTAssertEqualObjects(message, expectedResponse);
737-
[expectReceive fulfill];
738-
[call finish];
739-
}
740-
}
741-
closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
742-
XCTAssertNil(error, @"Unexpected error: %@", error);
743-
[expectComplete fulfill];
744-
}]
745-
callOptions:options];
746-
[call start];
747-
[call receiveNextMessage];
748-
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
749-
}
750-
751-
- (void)testUnaryRPCWithV2APIFlowControlNotReceivingMessage {
752-
XCTAssertNotNil([[self class] host]);
753-
754-
__weak XCTestExpectation *expectTimeout =
755-
[self expectationWithDescription:
756-
@"testUnaryRPCWithV2APIFlowControlNotReceivingMessage received timeout"];
757-
758-
RMTSimpleRequest *request = [RMTSimpleRequest message];
759-
request.responseType = RMTPayloadType_Compressable;
760-
request.responseSize = 123;
761-
request.payload.body = [NSMutableData dataWithLength:456];
762-
763-
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
764-
// For backwards compatibility
765-
options.transportType = [[self class] transportType];
766-
options.transport = [[self class] transport];
767-
options.PEMRootCertificates = [[self class] PEMRootCertificates];
768-
options.hostNameOverride = [[self class] hostNameOverride];
769-
options.flowControlEnabled = YES;
770-
771-
GRPCUnaryProtoCall *call = [_service
772-
unaryCallWithMessage:request
773-
responseHandler:[[InteropTestsBlockCallbacks alloc]
774-
initWithInitialMetadataCallback:nil
775-
messageCallback:^(id message) {
776-
XCTFail("Not expected to receive message");
777-
}
778-
closeCallback:nil]
779-
callOptions:options];
780-
[call start];
781-
XCTWaiterResult result = [XCTWaiter waitForExpectations:@[ expectTimeout ] timeout:5];
782-
XCTAssertEqual(XCTWaiterResultTimedOut, result, @"Unexpected waiter result %@", @(result));
783-
}
784-
785704
- (void)testConcurrentRPCsWithErrorsWithV2API {
786705
NSMutableArray *completeExpectations = [NSMutableArray array];
787706
NSMutableArray *calls = [NSMutableArray array];
@@ -1159,72 +1078,9 @@ - (void)testPingPongRPCWithV2API {
11591078
[self waitForExpectationsWithTimeout:STREAMING_CALL_TEST_TIMEOUT handler:nil];
11601079
}
11611080

1162-
- (void)testPingPongUnaryRPCWithFlowControl {
1081+
- (void)testPingPongRPCWithFlowControl {
11631082
XCTAssertNotNil([[self class] host]);
1164-
__weak XCTestExpectation *expectation =
1165-
[self expectationWithDescription:@"UnaryPingPongWithV2API"];
1166-
1167-
NSNumber *requestSize = @321;
1168-
NSArray *responseSizes = @[ @123, @234 ];
1169-
1170-
RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message];
1171-
request.payload.body = [NSMutableData dataWithLength:requestSize.unsignedIntegerValue];
1172-
for (NSNumber *responseSize in responseSizes) {
1173-
RMTResponseParameters *parameters = [RMTResponseParameters message];
1174-
parameters.size = responseSize.intValue;
1175-
[request.responseParametersArray addObject:parameters];
1176-
}
1177-
1178-
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
1179-
// For backwards compatibility
1180-
options.transportType = [[self class] transportType];
1181-
options.transport = [[self class] transport];
1182-
options.PEMRootCertificates = [[self class] PEMRootCertificates];
1183-
options.hostNameOverride = [[self class] hostNameOverride];
1184-
options.flowControlEnabled = YES;
1185-
1186-
__block GRPCUnaryProtoCall *call = nil;
1187-
__block int receivedMessageCount = 0;
1188-
1189-
id messageHandler = ^(id message) {
1190-
NSLog(@"received message %@", @(receivedMessageCount));
1191-
XCTAssertLessThan(receivedMessageCount, responseSizes.count,
1192-
"More than expected messages received");
1193-
id expected =
1194-
[RMTStreamingOutputCallResponse messageWithPayloadSize:responseSizes[receivedMessageCount]];
1195-
XCTAssertEqualObjects(message, expected);
1196-
1197-
receivedMessageCount += 1;
1198-
if (receivedMessageCount < responseSizes.count) {
1199-
[call receiveNextMessage];
1200-
} else {
1201-
[call finish];
1202-
}
1203-
};
1204-
1205-
id closeHandler = ^(NSDictionary *trailingMetadata, NSError *error) {
1206-
XCTAssertNil(error, @"Finished with unexpected error: %@", error);
1207-
[expectation fulfill];
1208-
};
1209-
1210-
InteropTestsBlockCallbacks *handler =
1211-
[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
1212-
messageCallback:messageHandler
1213-
closeCallback:closeHandler
1214-
writeMessageCallback:nil];
1215-
1216-
call = [_service streamingOutputCallWithMessage:request
1217-
responseHandler:handler
1218-
callOptions:options];
1219-
[call start];
1220-
[call receiveNextMessage];
1221-
[self waitForExpectationsWithTimeout:STREAMING_CALL_TEST_TIMEOUT handler:nil];
1222-
}
1223-
1224-
- (void)testPingPongStreamingRPCWithFlowControl {
1225-
XCTAssertNotNil([[self class] host]);
1226-
__weak XCTestExpectation *expectation =
1227-
[self expectationWithDescription:@"StreamingPingPongWithV2API"];
1083+
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPongWithV2API"];
12281084

12291085
NSArray *requests = @[ @27182, @8, @1828, @45904 ];
12301086
NSArray *responses = @[ @31415, @9, @2653, @58979 ];

0 commit comments

Comments
 (0)