Rerun clang-formatter-7

pull/22210/head
Esun Kim 5 years ago
parent 1a4c8df9b0
commit 415d41f9e8
  1. 12
      include/grpcpp/impl/codegen/server_context_impl.h
  2. 2
      include/grpcpp/server_posix_impl.h
  3. 2
      src/compiler/csharp_generator.cc
  4. 1
      src/compiler/objective_c_generator.cc
  5. 3
      src/compiler/objective_c_generator.h
  6. 2
      src/compiler/objective_c_generator_helpers.h
  7. 13
      src/core/ext/filters/client_channel/xds/xds_client_stats.cc
  8. 2
      src/core/lib/gpr/time_posix.cc
  9. 2
      src/core/lib/gprpp/fork.cc
  10. 5
      src/core/lib/iomgr/ev_epoll1_linux.cc
  11. 6
      src/core/lib/iomgr/ev_poll_posix.cc
  12. 6
      src/core/lib/transport/metadata.cc
  13. 2
      src/core/lib/transport/static_metadata.h
  14. 7
      src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
  15. 2
      src/objective-c/GRPCClient/GRPCCall+GID.h
  16. 8
      src/objective-c/GRPCClient/GRPCCall+Interceptor.m
  17. 5
      src/objective-c/GRPCClient/GRPCCall+Tests.m
  18. 8
      src/objective-c/GRPCClient/GRPCCall.h
  19. 12
      src/objective-c/GRPCClient/GRPCCall.m
  20. 4
      src/objective-c/GRPCClient/GRPCCallLegacy.h
  21. 45
      src/objective-c/GRPCClient/GRPCCallLegacy.m
  22. 4
      src/objective-c/GRPCClient/GRPCCallOptions.h
  23. 20
      src/objective-c/GRPCClient/GRPCCallOptions.m
  24. 10
      src/objective-c/GRPCClient/GRPCInterceptor.h
  25. 6
      src/objective-c/GRPCClient/GRPCInterceptor.m
  26. 4
      src/objective-c/GRPCClient/GRPCTransport.h
  27. 6
      src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h
  28. 5
      src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m
  29. 4
      src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h
  30. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h
  31. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h
  32. 6
      src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h
  33. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h
  34. 14
      src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m
  35. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h
  36. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h
  37. 8
      src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m
  38. 2
      src/objective-c/GRPCClient/private/GRPCTransport+Private.h
  39. 8
      src/objective-c/ProtoRPC/ProtoMethod.h
  40. 8
      src/objective-c/ProtoRPC/ProtoRPC.h
  41. 6
      src/objective-c/ProtoRPC/ProtoRPC.m
  42. 37
      src/objective-c/ProtoRPC/ProtoRPCLegacy.h
  43. 22
      src/objective-c/ProtoRPC/ProtoRPCLegacy.m
  44. 23
      src/objective-c/ProtoRPC/ProtoService.h
  45. 10
      src/objective-c/ProtoRPC/ProtoService.m
  46. 5
      src/objective-c/ProtoRPC/ProtoServiceLegacy.m
  47. 2
      src/objective-c/RxLibrary/GRXBufferedPipe.h
  48. 2
      src/objective-c/RxLibrary/GRXForwardingWriter.m
  49. 2
      src/objective-c/RxLibrary/GRXMappingWriter.m
  50. 4
      src/objective-c/RxLibrary/GRXWriteable.h
  51. 13
      src/objective-c/RxLibrary/GRXWriteable.m
  52. 2
      src/objective-c/examples/InterceptorSample/InterceptorSample/AppDelegate.h
  53. 8
      src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.h
  54. 7
      src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m
  55. 2
      src/objective-c/examples/Sample/Sample/AppDelegate.h
  56. 18
      src/objective-c/examples/Sample/Sample/ViewController.m
  57. 2
      src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h
  58. 7
      src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m
  59. 2
      src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h
  60. 7
      src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m
  61. 2
      src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h
  62. 2
      src/objective-c/manual_tests/AppDelegate.h
  63. 7
      src/objective-c/manual_tests/ViewController.m
  64. 21
      src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m
  65. 2
      src/objective-c/tests/Connectivity/ConnectivityTestingApp/main.m
  66. 2
      src/objective-c/tests/Hosts/ios-host/AppDelegate.h
  67. 176
      src/objective-c/tests/InteropTests/InteropTests.m
  68. 2
      src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.h
  69. 8
      src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m
  70. 9
      src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m
  71. 9
      src/objective-c/tests/MacTests/StressTests.m
  72. 8
      src/objective-c/tests/MacTests/StressTestsSSL.m
  73. 8
      src/objective-c/tests/PerfTests/PerfTests.m
  74. 2
      src/objective-c/tests/PerfTests/PerfTestsBlockCallbacks.h
  75. 8
      src/objective-c/tests/PerfTests/PerfTestsCFStreamSSL.m
  76. 8
      src/objective-c/tests/PerfTests/PerfTestsNoCFStreamSSL.m
  77. 129
      src/objective-c/tests/UnitTests/APIv2Tests.m
  78. 27
      src/objective-c/tests/UnitTests/ChannelTests.m
  79. 217
      src/objective-c/tests/UnitTests/GRPCClientTests.m
  80. 5
      src/objective-c/tests/UnitTests/NSErrorUnitTests.m
  81. 6
      src/objective-c/tests/UnitTests/TransportTests.m
  82. 2
      test/core/handshake/client_ssl.cc
  83. 2
      test/core/handshake/readahead_handshaker_server_ssl.cc
  84. 2
      test/core/handshake/server_ssl.cc
  85. 4
      test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc
  86. 2
      test/cpp/client/client_channel_stress_test.cc
  87. 2
      test/cpp/end2end/grpclb_end2end_test.cc
  88. 16
      test/cpp/end2end/mock_test.cc
  89. 6
      test/cpp/interop/stress_test.cc
  90. 2
      test/cpp/qps/client_async.cc
  91. 2
      test/cpp/server/load_reporter/load_data_store_test.cc

@ -513,9 +513,6 @@ class ServerContext : public ServerContextBase {
using ServerContextBase::AddInitialMetadata;
using ServerContextBase::AddTrailingMetadata;
using ServerContextBase::IsCancelled;
using ServerContextBase::SetLoadReportingCosts;
using ServerContextBase::TryCancel;
using ServerContextBase::auth_context;
using ServerContextBase::c_call;
using ServerContextBase::census_context;
@ -524,10 +521,13 @@ class ServerContext : public ServerContextBase {
using ServerContextBase::compression_level;
using ServerContextBase::compression_level_set;
using ServerContextBase::deadline;
using ServerContextBase::IsCancelled;
using ServerContextBase::peer;
using ServerContextBase::raw_deadline;
using ServerContextBase::set_compression_algorithm;
using ServerContextBase::set_compression_level;
using ServerContextBase::SetLoadReportingCosts;
using ServerContextBase::TryCancel;
// Sync/CQ-based Async ServerContext only
using ServerContextBase::AsyncNotifyWhenDone;
@ -555,9 +555,6 @@ class CallbackServerContext : public ServerContextBase {
using ServerContextBase::AddInitialMetadata;
using ServerContextBase::AddTrailingMetadata;
using ServerContextBase::IsCancelled;
using ServerContextBase::SetLoadReportingCosts;
using ServerContextBase::TryCancel;
using ServerContextBase::auth_context;
using ServerContextBase::c_call;
using ServerContextBase::census_context;
@ -566,10 +563,13 @@ class CallbackServerContext : public ServerContextBase {
using ServerContextBase::compression_level;
using ServerContextBase::compression_level_set;
using ServerContextBase::deadline;
using ServerContextBase::IsCancelled;
using ServerContextBase::peer;
using ServerContextBase::raw_deadline;
using ServerContextBase::set_compression_algorithm;
using ServerContextBase::set_compression_level;
using ServerContextBase::SetLoadReportingCosts;
using ServerContextBase::TryCancel;
// CallbackServerContext only
using ServerContextBase::DefaultReactor;

@ -37,6 +37,6 @@ void AddInsecureChannelFromFd(grpc::Server* server, int fd);
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
} // namespace grpc
} // namespace grpc_impl
#endif // GRPCPP_SERVER_POSIX_IMPL_H

@ -35,11 +35,11 @@ using grpc::protobuf::ServiceDescriptor;
using grpc::protobuf::io::Printer;
using grpc::protobuf::io::StringOutputStream;
using grpc_generator::GetMethodType;
using grpc_generator::MethodType;
using grpc_generator::METHODTYPE_BIDI_STREAMING;
using grpc_generator::METHODTYPE_CLIENT_STREAMING;
using grpc_generator::METHODTYPE_NO_STREAMING;
using grpc_generator::METHODTYPE_SERVER_STREAMING;
using grpc_generator::MethodType;
using grpc_generator::StringReplace;
using std::map;
using std::vector;

@ -28,7 +28,6 @@
using ::google::protobuf::compiler::objectivec::ClassName;
using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::MethodDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::protobuf::io::Printer;

@ -28,10 +28,9 @@ struct Parameters {
bool no_v1_compatibility;
};
using ::grpc::protobuf::FileDescriptor;
using ::grpc::string;
using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::string;
// Returns forward declaration of classes in the generated header file.
string GetAllMessageClasses(const FileDescriptor* file);

@ -27,9 +27,9 @@
namespace grpc_objective_c_generator {
using ::grpc::string;
using ::grpc::protobuf::FileDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
using ::grpc::string;
inline string MessageHeaderName(const FileDescriptor* file) {
return google::protobuf::compiler::objectivec::FilePath(file) + ".pbobjc.h";

@ -89,13 +89,12 @@ uint64_t GetAndResetCounter(Atomic<uint64_t>* from) {
XdsClusterLocalityStats::Snapshot
XdsClusterLocalityStats::GetSnapshotAndReset() {
Snapshot snapshot = {
GetAndResetCounter(&total_successful_requests_),
// Don't reset total_requests_in_progress because it's not
// related to a single reporting interval.
total_requests_in_progress_.Load(MemoryOrder::RELAXED),
GetAndResetCounter(&total_error_requests_),
GetAndResetCounter(&total_issued_requests_)};
Snapshot snapshot = {GetAndResetCounter(&total_successful_requests_),
// Don't reset total_requests_in_progress because it's
// not related to a single reporting interval.
total_requests_in_progress_.Load(MemoryOrder::RELAXED),
GetAndResetCounter(&total_error_requests_),
GetAndResetCounter(&total_issued_requests_)};
MutexLock lock(&backend_metrics_mu_);
snapshot.backend_metrics = std::move(backend_metrics_);
return snapshot;

@ -82,7 +82,7 @@ static gpr_timespec now_impl(gpr_clock_type clock_type) {
}
}
#else
/* For some reason Apple's OSes haven't implemented clock_gettime. */
/* For some reason Apple's OSes haven't implemented clock_gettime. */
#include <mach/mach.h>
#include <mach/mach_time.h>

@ -164,7 +164,7 @@ class ThreadState {
int count_;
};
} // namespace
} // namespace internal
void Fork::GlobalInit() {
if (!override_enabled_) {

@ -1116,9 +1116,8 @@ static grpc_error* pollset_kick(grpc_pollset* pollset,
}
SET_KICK_STATE(next_worker, KICKED);
goto done;
} else if (root_worker ==
next_worker && // only try and wake up a poller if
// there is no next worker
} else if (root_worker == next_worker && // only try and wake up a poller
// if there is no next worker
root_worker == (grpc_pollset_worker*)gpr_atm_no_barrier_load(
&g_active_poller)) {
GRPC_STATS_INC_POLLSET_KICK_WAKEUP_FD();

@ -307,9 +307,9 @@ static void fork_fd_list_add_wakeup_fd(grpc_cached_wakeup_fd* fd) {
}
}
/*******************************************************************************
* fd_posix.c
*/
/*******************************************************************************
* fd_posix.c
*/
#ifndef NDEBUG
#define REF_BY(fd, n, reason) ref_by(fd, n, reason, __FILE__, __LINE__)

@ -256,9 +256,9 @@ void grpc_mdctx_global_shutdown() {
abort();
}
}
// For ASAN builds, we don't want to crash here, because that will
// prevent ASAN from providing leak detection information, which is
// far more useful than this simple assertion.
// For ASAN builds, we don't want to crash here, because that will
// prevent ASAN from providing leak detection information, which is
// far more useful than this simple assertion.
#ifndef GRPC_ASAN_ENABLED
GPR_DEBUG_ASSERT(shard->count == 0);
#endif

@ -46,7 +46,7 @@ constexpr uint64_t kGrpcStaticMetadataInitCanary = 0xCAFEF00DC0FFEE11L;
uint64_t StaticMetadataInitCanary();
#endif
extern const StaticMetadataSlice* g_static_metadata_slice_table;
}
} // namespace grpc_core
inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() {
GPR_DEBUG_ASSERT(grpc_core::StaticMetadataInitCanary() ==
grpc_core::kGrpcStaticMetadataInitCanary);

@ -27,10 +27,9 @@
+ (void)setUserAgentPrefix:(nonnull NSString *)userAgentPrefix forHost:(nonnull NSString *)host;
+ (void)setResponseSizeLimit:(NSUInteger)limit forHost:(nonnull NSString *)host;
+ (void)closeOpenConnections DEPRECATED_MSG_ATTRIBUTE(
"The API for this feature is experimental, "
"and might be removed or modified at any "
"time.");
+ (void)closeOpenConnections DEPRECATED_MSG_ATTRIBUTE("The API for this feature is experimental, "
"and might be removed or modified at any "
"time.");
+ (void)setDefaultCompressMethod:(GRPCCompressAlgorithm)algorithm forhost:(nonnull NSString *)host;
+ (void)setKeepaliveWithInterval:(int)interval
timeout:(int)timeout

@ -24,6 +24,6 @@
/**
* Extend GIDSignIn class to comply GRPCAuthorizationProtocol
*/
@interface GIDSignIn (GRPC)<GRPCAuthorizationProtocol>
@interface GIDSignIn (GRPC) <GRPCAuthorizationProtocol>
- (void)getTokenWithHandler:(void (^)(NSString *token))hander;
@end

@ -35,10 +35,10 @@ static dispatch_once_t onceToken;
[globalInterceptorLock lock];
if (globalInterceptorFactory != nil) {
[globalInterceptorLock unlock];
[NSException raise:NSInternalInconsistencyException
format:
@"Global interceptor is already registered. Only one global interceptor can be "
@"registered in a process."];
[NSException
raise:NSInternalInconsistencyException
format:@"Global interceptor is already registered. Only one global interceptor can be "
@"registered in a process."];
return;
}

@ -37,8 +37,9 @@
[NSException raise:NSInvalidArgumentException format:@"testname must be provided."];
}
NSError *error = nil;
NSString *certs =
[NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error];
NSString *certs = [NSString stringWithContentsOfFile:certsPath
encoding:NSUTF8StringEncoding
error:&error];
if (error != nil) {
[NSException raise:[error localizedDescription] format:@"failed to load certs"];
}

@ -47,7 +47,7 @@
NS_ASSUME_NONNULL_BEGIN
/** An object can implement this protocol to receive responses from server from a call. */
@protocol GRPCResponseHandler<NSObject, GRPCDispatchable>
@protocol GRPCResponseHandler <NSObject, GRPCDispatchable>
@optional
@ -99,11 +99,11 @@ NS_ASSUME_NONNULL_BEGIN
* HTTP request parameters. If Protobuf is used, these parameters are automatically generated by
* Protobuf. If directly using the GRPCCall2 class, users should specify these parameters manually.
*/
@interface GRPCRequestOptions : NSObject<NSCopying>
@interface GRPCRequestOptions : NSObject <NSCopying>
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
/** Initialize with all properties. */
- (instancetype)initWithHost:(NSString *)host
@ -131,7 +131,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
/**
* Designated initializer for a call.

@ -35,7 +35,7 @@ NSString *const kGRPCErrorDomain = @"io.grpc";
* dispatch queue of a user provided response handler. It removes the requirement of having to use
* serial dispatch queue in the user provided response handler.
*/
@interface GRPCResponseDispatcher : NSObject<GRPCResponseHandler>
@interface GRPCResponseDispatcher : NSObject <GRPCResponseHandler>
- (nullable instancetype)initWithResponseHandler:(id<GRPCResponseHandler>)responseHandler;
@ -117,8 +117,9 @@ NSString *const kGRPCErrorDomain = @"io.grpc";
}
- (id)copyWithZone:(NSZone *)zone {
GRPCRequestOptions *request =
[[GRPCRequestOptions alloc] initWithHost:_host path:_path safety:_safety];
GRPCRequestOptions *request = [[GRPCRequestOptions alloc] initWithHost:_host
path:_path
safety:_safety];
return request;
}
@ -221,8 +222,9 @@ NSString *const kGRPCErrorDomain = @"io.grpc";
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
responseHandler:(id<GRPCResponseHandler>)responseHandler {
return
[self initWithRequestOptions:requestOptions responseHandler:responseHandler callOptions:nil];
return [self initWithRequestOptions:requestOptions
responseHandler:responseHandler
callOptions:nil];
}
- (void)start {

@ -112,7 +112,7 @@
/** This protocol is kept for backwards compatibility with existing code. */
DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.")
@protocol GRPCRequestHeaders<NSObject>
@protocol GRPCRequestHeaders <NSObject>
@property(nonatomic, readonly) NSUInteger count;
- (id)objectForKeyedSubscript:(id)key;
@ -125,7 +125,7 @@ DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.")
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
/** This is only needed for backwards-compatibility. */
@interface NSMutableDictionary (GRPCRequestHeaders)<GRPCRequestHeaders>
@interface NSMutableDictionary (GRPCRequestHeaders) <GRPCRequestHeaders>
@end
#pragma clang diagnostic pop
#pragma clang diagnostic pop

@ -46,7 +46,7 @@ NSInteger kMaxClientBatch = 6;
static NSString *const kAuthorizationHeader = @"authorization";
static NSString *const kBearerPrefix = @"Bearer ";
@interface GRPCCall ()<GRXWriteable>
@interface GRPCCall () <GRXWriteable>
// Make them read-write.
@property(atomic, strong) NSDictionary *responseHeaders;
@property(atomic, strong) NSDictionary *responseTrailers;
@ -429,8 +429,8 @@ static NSString *const kBearerPrefix = @"Bearer ";
}
}
};
GRPCOpSendMessage *op =
[[GRPCOpSendMessage alloc] initWithMessage:message handler:resumingHandler];
GRPCOpSendMessage *op = [[GRPCOpSendMessage alloc] initWithMessage:message
handler:resumingHandler];
if (!_unaryCall) {
[_wrappedCall startBatchWithOperations:@[ op ] errorHandler:errorHandler];
} else {
@ -501,22 +501,23 @@ static NSString *const kBearerPrefix = @"Bearer ";
- (void)invokeCall {
__weak GRPCCall *weakSelf = self;
[self invokeCallWithHeadersHandler:^(NSDictionary *headers) {
// Response headers received.
__strong GRPCCall *strongSelf = weakSelf;
if (strongSelf) {
@synchronized(strongSelf) {
// it is ok to set nil because headers are only received once
strongSelf.responseHeaders = nil;
// copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed
NSDictionary *copiedHeaders =
[[NSDictionary alloc] initWithDictionary:headers copyItems:YES];
strongSelf.responseHeaders = copiedHeaders;
strongSelf->_pendingCoreRead = NO;
[strongSelf maybeStartNextRead];
[self
invokeCallWithHeadersHandler:^(NSDictionary *headers) {
// Response headers received.
__strong GRPCCall *strongSelf = weakSelf;
if (strongSelf) {
@synchronized(strongSelf) {
// it is ok to set nil because headers are only received once
strongSelf.responseHeaders = nil;
// copy the header so that the GRPCOpRecvMetadata object may be dealloc'ed
NSDictionary *copiedHeaders = [[NSDictionary alloc] initWithDictionary:headers
copyItems:YES];
strongSelf.responseHeaders = copiedHeaders;
strongSelf->_pendingCoreRead = NO;
[strongSelf maybeStartNextRead];
}
}
}
}
}
completionHandler:^(NSError *error, NSDictionary *trailers) {
__strong GRPCCall *strongSelf = weakSelf;
if (strongSelf) {
@ -548,11 +549,11 @@ static NSString *const kBearerPrefix = @"Bearer ";
return;
}
_responseWriteable =
[[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue];
_responseWriteable = [[GRXConcurrentWriteable alloc] initWithWriteable:writeable
dispatchQueue:_responseQueue];
GRPCPooledChannel *channel =
[[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions];
GRPCPooledChannel *channel = [[GRPCChannelPool sharedInstance] channelWithHost:_host
callOptions:_callOptions];
_wrappedCall = [channel wrappedCallWithPath:_path
completionQueue:[GRPCCompletionQueue completionQueue]
callOptions:_callOptions];

@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Immutable user configurable options for a gRPC call.
*/
@interface GRPCCallOptions : NSObject<NSCopying, NSMutableCopying>
@interface GRPCCallOptions : NSObject <NSCopying, NSMutableCopying>
// Call parameters
/**
@ -200,7 +200,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Mutable user configurable options for a gRPC call.
*/
@interface GRPCMutableCallOptions : GRPCCallOptions<NSCopying, NSMutableCopying>
@interface GRPCMutableCallOptions : GRPCCallOptions <NSCopying, NSMutableCopying>
// Call parameters
/**

@ -178,10 +178,10 @@ static BOOL areObjectsEqual(id obj1, id obj2) {
_interceptorFactories = interceptorFactories;
_oauth2AccessToken = [oauth2AccessToken copy];
_authTokenProvider = authTokenProvider;
_initialMetadata =
initialMetadata == nil
? nil
: [[NSDictionary alloc] initWithDictionary:initialMetadata copyItems:YES];
_initialMetadata = initialMetadata == nil
? nil
: [[NSDictionary alloc] initWithDictionary:initialMetadata
copyItems:YES];
_userAgentPrefix = [userAgentPrefix copy];
_responseSizeLimit = responseSizeLimit;
_compressionAlgorithm = compressionAlgorithm;
@ -191,10 +191,10 @@ static BOOL areObjectsEqual(id obj1, id obj2) {
_connectMinTimeout = connectMinTimeout < 0 ? 0 : connectMinTimeout;
_connectInitialBackoff = connectInitialBackoff < 0 ? 0 : connectInitialBackoff;
_connectMaxBackoff = connectMaxBackoff < 0 ? 0 : connectMaxBackoff;
_additionalChannelArgs =
additionalChannelArgs == nil
? nil
: [[NSDictionary alloc] initWithDictionary:additionalChannelArgs copyItems:YES];
_additionalChannelArgs = additionalChannelArgs == nil
? nil
: [[NSDictionary alloc] initWithDictionary:additionalChannelArgs
copyItems:YES];
_PEMRootCertificates = [PEMRootCertificates copy];
_PEMPrivateKey = [PEMPrivateKey copy];
_PEMCertificateChain = [PEMCertificateChain copy];
@ -533,8 +533,8 @@ static BOOL areObjectsEqual(id obj1, id obj2) {
}
- (void)setAdditionalChannelArgs:(NSDictionary *)additionalChannelArgs {
_additionalChannelArgs =
[[NSDictionary alloc] initWithDictionary:additionalChannelArgs copyItems:YES];
_additionalChannelArgs = [[NSDictionary alloc] initWithDictionary:additionalChannelArgs
copyItems:YES];
}
- (void)setPEMRootCertificates:(NSString *)PEMRootCertificates {

@ -127,7 +127,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* The GRPCInterceptorInterface defines the request events that can occur to an interceptor.
*/
@protocol GRPCInterceptorInterface<NSObject, GRPCDispatchable>
@protocol GRPCInterceptorInterface <NSObject, GRPCDispatchable>
/**
* To start the call. This method will only be called once for each instance.
@ -184,11 +184,11 @@ NS_ASSUME_NONNULL_BEGIN
* When an interceptor is shutting down, it must invoke -shutDown method of its corresponding
* manager so that references to other interceptors can be released and proper clean-up is made.
*/
@interface GRPCInterceptorManager : NSObject<GRPCInterceptorInterface, GRPCResponseHandler>
@interface GRPCInterceptorManager : NSObject <GRPCInterceptorInterface, GRPCResponseHandler>
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (nullable instancetype)initWithFactories:(nullable NSArray<id<GRPCInterceptorFactory>> *)factories
previousInterceptor:(nullable id<GRPCResponseHandler>)previousInterceptor
@ -246,10 +246,10 @@ NS_ASSUME_NONNULL_BEGIN
* with [super initWithInterceptorManager:dispatchQueue:] for the default implementation to function
* properly.
*/
@interface GRPCInterceptor : NSObject<GRPCInterceptorInterface, GRPCResponseHandler>
@interface GRPCInterceptor : NSObject <GRPCInterceptorInterface, GRPCResponseHandler>
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
/**
* Initialize the interceptor with the next interceptor in the chain, and provide the dispatch queue

@ -21,7 +21,7 @@
#import "GRPCInterceptor.h"
#import "private/GRPCTransport+Private.h"
@interface GRPCInterceptorManager ()<GRPCInterceptorInterface, GRPCResponseHandler>
@interface GRPCInterceptorManager () <GRPCInterceptorInterface, GRPCResponseHandler>
@end
@ -86,8 +86,8 @@
arrayWithArray:[_factories subarrayWithRange:NSMakeRange(1, _factories.count - 1)]];
while (_nextInterceptor == nil) {
if (interceptorFactories.count == 0) {
_nextInterceptor =
[[GRPCTransportManager alloc] initWithTransportID:_transportID previousInterceptor:self];
_nextInterceptor = [[GRPCTransportManager alloc] initWithTransportID:_transportID
previousInterceptor:self];
break;
} else {
_nextInterceptor = [[GRPCInterceptorManager alloc] initWithFactories:interceptorFactories

@ -49,7 +49,7 @@ NSUInteger TransportIDHash(GRPCTransportID);
@class GRPCTransport;
/** The factory to create a transport. */
@protocol GRPCTransportFactory<NSObject>
@protocol GRPCTransportFactory <NSObject>
/** Create a transport implementation instance. */
- (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager;
@ -79,7 +79,7 @@ NSUInteger TransportIDHash(GRPCTransportID);
* Base class for transport implementations. All transport implementation should inherit from this
* class.
*/
@interface GRPCTransport : NSObject<GRPCInterceptorInterface>
@interface GRPCTransport : NSObject <GRPCInterceptorInterface>
@end

@ -33,11 +33,11 @@ NS_ASSUME_NONNULL_BEGIN
* Signature for the channel. If two channel's signatures are the same and connect to the same
* remote, they share the same underlying \a GRPCChannel object.
*/
@interface GRPCChannelConfiguration : NSObject<NSCopying>
@interface GRPCChannelConfiguration : NSObject <NSCopying>
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
/** The host that this channel is connected to. */
@property(copy, readonly) NSString *host;
@ -66,7 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable instancetype)init NS_UNAVAILABLE;
+ (nullable instancetype) new NS_UNAVAILABLE;
+ (nullable instancetype)new NS_UNAVAILABLE;
/**
* Create a channel with remote \a host and signature \a channelConfigurations.

@ -83,8 +83,9 @@
return factory;
}
case GRPCTransportTypeCronet: {
id<GRPCCoreTransportFactory> transportFactory = (id<GRPCCoreTransportFactory>)[
[GRPCTransportRegistry sharedInstance] getTransportFactoryWithID:gGRPCCoreCronetID];
id<GRPCCoreTransportFactory> transportFactory =
(id<GRPCCoreTransportFactory>)[[GRPCTransportRegistry sharedInstance]
getTransportFactoryWithID:gGRPCCoreCronetID];
return [transportFactory createCoreChannelFactoryWithCallOptions:_callOptions];
}
case GRPCTransportTypeInsecure:

@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable instancetype)init NS_UNAVAILABLE;
+ (nullable instancetype) new NS_UNAVAILABLE;
+ (nullable instancetype)new NS_UNAVAILABLE;
/**
* Initialize with an actual channel object \a channel and a reference to the channel pool.
@ -76,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable instancetype)init NS_UNAVAILABLE;
+ (nullable instancetype) new NS_UNAVAILABLE;
+ (nullable instancetype)new NS_UNAVAILABLE;
/**
* Get the global channel pool.

@ -27,6 +27,6 @@
* dependency of the project and use gGRPCCoreCronetID in call options to
* specify that this is the transport to be used for a call.
*/
@interface GRPCCoreCronetFactory : NSObject<GRPCCoreTransportFactory>
@interface GRPCCoreCronetFactory : NSObject <GRPCCoreTransportFactory>
@end

@ -22,7 +22,7 @@ typedef struct stream_engine stream_engine;
NS_ASSUME_NONNULL_BEGIN
@interface GRPCCronetChannelFactory : NSObject<GRPCChannelFactory>
@interface GRPCCronetChannelFactory : NSObject <GRPCChannelFactory>
+ (nullable instancetype)sharedInstance;

@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol GRPCCallOptions;
/** The interface for transport implementations that are based on Core. */
@protocol GRPCCoreTransportFactory<GRPCTransportFactory>
@protocol GRPCCoreTransportFactory <GRPCTransportFactory>
/** Get the channel factory for GRPCChannel from call options. */
- (nullable id<GRPCChannelFactory>)createCoreChannelFactoryWithCallOptions:
@ -33,12 +33,12 @@ NS_ASSUME_NONNULL_BEGIN
@end
/** The factory for gRPC Core + CFStream + TLS secure channel transport implementation. */
@interface GRPCCoreSecureFactory : NSObject<GRPCCoreTransportFactory>
@interface GRPCCoreSecureFactory : NSObject <GRPCCoreTransportFactory>
@end
/** The factory for gRPC Core + CFStream + insecure channel transport implementation. */
@interface GRPCCoreInsecureFactory : NSObject<GRPCCoreTransportFactory>
@interface GRPCCoreInsecureFactory : NSObject <GRPCCoreTransportFactory>
@end

@ -21,7 +21,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface GRPCInsecureChannelFactory : NSObject<GRPCChannelFactory>
@interface GRPCInsecureChannelFactory : NSObject <GRPCChannelFactory>
+ (nullable instancetype)sharedInstance;

@ -38,18 +38,16 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
if ([key hasSuffix:@"-bin"]) {
if (![value isKindOfClass:[NSData class]]) {
[NSException raise:NSInvalidArgumentException
format:
@"Expected NSData value for header %@ ending in \"-bin\", "
@"instead got %@",
key, value];
format:@"Expected NSData value for header %@ ending in \"-bin\", "
@"instead got %@",
key, value];
}
} else {
if (![value isKindOfClass:[NSString class]]) {
[NSException raise:NSInvalidArgumentException
format:
@"Expected NSString value for header %@ not ending in \"-bin\", "
@"instead got %@",
key, value];
format:@"Expected NSString value for header %@ not ending in \"-bin\", "
@"instead got %@",
key, value];
}
CheckIsNonNilASCII(@"Text header value", (NSString *)value);
}

@ -21,7 +21,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface GRPCSecureChannelFactory : NSObject<GRPCChannelFactory>
@interface GRPCSecureChannelFactory : NSObject <GRPCChannelFactory>
/**
* Creates a secure channel factory which uses provided root certificates and client authentication

@ -77,7 +77,7 @@
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)initWithUnmanagedCall:(grpc_call *)unmanagedCall
pooledChannel:(GRPCPooledChannel *)pooledChannel NS_DESIGNATED_INITIALIZER;

@ -30,12 +30,12 @@
}
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
if (details) {
userInfo[NSLocalizedDescriptionKey] =
[NSString stringWithCString:details encoding:NSUTF8StringEncoding];
userInfo[NSLocalizedDescriptionKey] = [NSString stringWithCString:details
encoding:NSUTF8StringEncoding];
}
if (errorString) {
userInfo[NSDebugDescriptionErrorKey] =
[NSString stringWithCString:errorString encoding:NSUTF8StringEncoding];
userInfo[NSDebugDescriptionErrorKey] = [NSString stringWithCString:errorString
encoding:NSUTF8StringEncoding];
}
return [NSError errorWithDomain:kGRPCErrorDomain code:statusCode userInfo:userInfo];
}

@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
* When a transport instance is shutting down, it must call -shutDown method of its associated
* transport manager for proper clean-up.
*/
@interface GRPCTransportManager : NSObject<GRPCInterceptorInterface>
@interface GRPCTransportManager : NSObject <GRPCInterceptorInterface>
- (instancetype)initWithTransportID:(GRPCTransportID)transportID
previousInterceptor:(id<GRPCResponseHandler>)previousInterceptor;

@ -22,8 +22,8 @@
* A fully-qualified proto service method name. Full qualification is needed because a gRPC endpoint
* can implement multiple services.
*/
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod
: NSObject @property(nonatomic, readonly) NSString *package;
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod : NSObject
@property(nonatomic, readonly) NSString *package;
@property(nonatomic, readonly) NSString *service;
@property(nonatomic, readonly) NSString *method;
@ -40,7 +40,7 @@ __attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMetho
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface GRPCProtoMethod : ProtoMethod
@interface GRPCProtoMethod : ProtoMethod
#pragma clang diagnostic pop
@end
@end

@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
@class GPBMessage;
/** An object can implement this protocol to receive responses from server from a call. */
@protocol GRPCProtoResponseHandler<NSObject>
@protocol GRPCProtoResponseHandler <NSObject>
@required
@ -77,7 +77,7 @@ NS_ASSUME_NONNULL_BEGIN
* The object is stateful and should not be reused for multiple calls. If multiple calls share the
* same response handling logic, create separate GRPCUnaryResponseHandler objects for each call.
*/
@interface GRPCUnaryResponseHandler<ResponseType> : NSObject<GRPCProtoResponseHandler>
@interface GRPCUnaryResponseHandler<ResponseType> : NSObject <GRPCProtoResponseHandler>
/**
* Creates a responsehandler object with a unary call handler.
@ -102,7 +102,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
/**
* Users should not use this initializer directly. Call objects will be created, initialized, and
@ -133,7 +133,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
/**
* Users should not use this initializer directly. Call objects will be created, initialized, and

@ -111,7 +111,7 @@
@end
@interface GRPCStreamingProtoCall ()<GRPCResponseHandler>
@interface GRPCStreamingProtoCall () <GRPCResponseHandler>
@end
@ -266,8 +266,8 @@
}
[copiedHandler didReceiveProtoMessage:parsed];
});
} else if (!parsed &&
[_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) {
} else if (!parsed && [_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:
error:)]) {
dispatch_async(_dispatchQueue, ^{
id<GRPCProtoResponseHandler> copiedHandler = nil;
@synchronized(self) {

@ -30,18 +30,17 @@
@class GRXWriter;
@protocol GRXWriteable;
__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC
: GRPCCall
__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC : GRPCCall
/**
* host parameter should not contain the scheme (http:// or https://), only the name or IP
* addr and the port number, for example @"localhost:5050".
*/
-
(instancetype)initWithHost : (NSString *)host method
: (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass
: (Class)responseClass responsesWriteable
: (id<GRXWriteable>)responsesWriteable NS_DESIGNATED_INITIALIZER;
/**
* host parameter should not contain the scheme (http:// or https://), only the name or IP
* addr and the port number, for example @"localhost:5050".
*/
- (instancetype)initWithHost:(NSString *)host
method:(GRPCProtoMethod *)method
requestsWriter:(GRXWriter *)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable NS_DESIGNATED_INITIALIZER;
- (void)start;
@ -53,15 +52,13 @@ __attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface GRPCProtoCall
: ProtoRPC
@interface GRPCProtoCall : ProtoRPC
#pragma clang diagnostic pop
@end
@end
/**
* Generate an NSError object that represents a failure in parsing a proto class. For gRPC
* internal use only.
*/
NSError *
ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError);
/**
* Generate an NSError object that represents a failure in parsing a proto class. For gRPC
* internal use only.
*/
NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError);

@ -70,16 +70,18 @@
__weak ProtoRPC *weakSelf = self;
// A writeable that parses the proto messages received.
_responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
// TODO(jcanizales): This is done in the main thread, and needs to happen in another thread.
NSError *error = nil;
id parsed = [responseClass parseFromData:value error:&error];
if (parsed) {
[responsesWriteable writeValue:parsed];
} else {
[weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)];
}
}
_responseWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
// TODO(jcanizales): This is done in the main thread, and needs to happen in another
// thread.
NSError *error = nil;
id parsed = [responseClass parseFromData:value error:&error];
if (parsed) {
[responsesWriteable writeValue:parsed];
} else {
[weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)];
}
}
completionHandler:^(NSError *errorOrNil) {
[responsesWriteable writesFinishedWithError:errorOrNil];
}];

@ -28,13 +28,13 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability-completeness"
__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService
: NSObject
__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService : NSObject
-
(nullable instancetype)initWithHost : (nonnull NSString *)host packageName
: (nonnull NSString *)packageName serviceName : (nonnull NSString *)serviceName callOptions
: (nullable GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithHost:(nonnull NSString *)host
packageName:(nonnull NSString *)packageName
serviceName:(nonnull NSString *)serviceName
callOptions:(nullable GRPCCallOptions *)callOptions
NS_DESIGNATED_INITIALIZER;
- (nullable GRPCUnaryProtoCall *)RPCToMethod:(nonnull NSString *)method
message:(nonnull id)message
@ -49,10 +49,11 @@ __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoServ
@end
@interface ProtoService(Legacy)
@interface ProtoService (Legacy)
- (instancetype)initWithHost : (NSString *)host packageName
: (NSString *)packageName serviceName : (NSString *)serviceName;
- (instancetype)initWithHost:(NSString *)host
packageName:(NSString *)packageName
serviceName:(NSString *)serviceName;
- (GRPCProtoCall *)RPCToMethod:(NSString *)method
requestsWriter:(GRXWriter *)requestsWriter
@ -69,7 +70,7 @@ __attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoServ
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface GRPCProtoService : ProtoService
@interface GRPCProtoService : ProtoService
#pragma clang diagnostic pop
@end
@end

@ -69,8 +69,9 @@
responseHandler:(id<GRPCProtoResponseHandler>)handler
callOptions:(GRPCCallOptions *)callOptions
responseClass:(Class)responseClass {
GRPCProtoMethod *methodName =
[[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method];
GRPCProtoMethod *methodName = [[GRPCProtoMethod alloc] initWithPackage:_packageName
service:_serviceName
method:method];
GRPCRequestOptions *requestOptions =
[[GRPCRequestOptions alloc] initWithHost:_host
path:methodName.HTTPPath
@ -86,8 +87,9 @@
responseHandler:(id<GRPCProtoResponseHandler>)handler
callOptions:(GRPCCallOptions *)callOptions
responseClass:(Class)responseClass {
GRPCProtoMethod *methodName =
[[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method];
GRPCProtoMethod *methodName = [[GRPCProtoMethod alloc] initWithPackage:_packageName
service:_serviceName
method:method];
GRPCRequestOptions *requestOptions =
[[GRPCRequestOptions alloc] initWithHost:_host
path:methodName.HTTPPath

@ -59,8 +59,9 @@
NSString *packageName = object_getIvar(self, packageNameIvar);
NSString *serviceName = object_getIvar(self, serviceNameIvar);
GRPCProtoMethod *methodName =
[[GRPCProtoMethod alloc] initWithPackage:packageName service:serviceName method:method];
GRPCProtoMethod *methodName = [[GRPCProtoMethod alloc] initWithPackage:packageName
service:serviceName
method:method];
return [[GRPCProtoCall alloc] initWithHost:host
method:methodName
requestsWriter:requestsWriter

@ -38,7 +38,7 @@
*
* Thread-safety: the methods of this class are thread-safe.
*/
@interface GRXBufferedPipe : GRXWriter<GRXWriteable>
@interface GRXBufferedPipe : GRXWriter <GRXWriteable>
/** Convenience constructor. */
+ (instancetype)pipe;

@ -18,7 +18,7 @@
#import "GRXForwardingWriter.h"
@interface GRXForwardingWriter ()<GRXWriteable>
@interface GRXForwardingWriter () <GRXWriteable>
@end
@implementation GRXForwardingWriter {

@ -18,7 +18,7 @@
#import "GRXMappingWriter.h"
@interface GRXForwardingWriter ()<GRXWriteable>
@interface GRXForwardingWriter () <GRXWriteable>
@end
@implementation GRXMappingWriter {

@ -22,7 +22,7 @@
* A GRXWriteable is an object to which a sequence of values can be sent. The
* sequence finishes with an optional error.
*/
@protocol GRXWriteable<NSObject>
@protocol GRXWriteable <NSObject>
/** Push the next value of the sequence to the receiving object. */
- (void)writeValue:(id)value;
@ -44,7 +44,7 @@ typedef void (^GRXEventHandler)(BOOL done, id value, NSError *error);
* Utility to create objects that conform to the GRXWriteable protocol, from
* blocks that handle each of the two methods of the protocol.
*/
@interface GRXWriteable : NSObject<GRXWriteable>
@interface GRXWriteable : NSObject <GRXWriteable>
+ (instancetype)writeableWithSingleHandler:(GRXSingleHandler)handler;
+ (instancetype)writeableWithEventHandler:(GRXEventHandler)handler;

@ -54,9 +54,9 @@
// the two domains.
static NSString *kGRPCErrorDomain = @"io.grpc";
static NSUInteger kGRPCErrorCodeInternal = 13;
singleHandler(
nil,
[NSError errorWithDomain:kGRPCErrorDomain code:kGRPCErrorCodeInternal userInfo:userInfo]);
singleHandler(nil, [NSError errorWithDomain:kGRPCErrorDomain
code:kGRPCErrorCodeInternal
userInfo:userInfo]);
}
};
return [self writeableWithEventHandler:^(BOOL done, id value, NSError *error) {
@ -70,9 +70,10 @@
if (!handler) {
return [[self alloc] init];
}
return [[self alloc] initWithValueHandler:^(id value) {
handler(NO, value, nil);
}
return [[self alloc]
initWithValueHandler:^(id value) {
handler(NO, value, nil);
}
completionHandler:^(NSError *errorOrNil) {
handler(YES, nil, errorOrNil);
}];

@ -18,7 +18,7 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property(strong, nonatomic) UIWindow* window;

@ -20,7 +20,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface RequestCacheEntry : NSObject<NSCopying>
@interface RequestCacheEntry : NSObject <NSCopying>
@property(readonly, copy, nullable) NSString *path;
@property(readonly, copy, nullable) id message;
@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
@end
@interface ResponseCacheEntry : NSObject<NSCopying>
@interface ResponseCacheEntry : NSObject <NSCopying>
@property(readonly, copy, nullable) NSDate *deadline;
@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN
@end
@interface CacheContext : NSObject<GRPCInterceptorFactory>
@interface CacheContext : NSObject <GRPCInterceptorFactory>
- (nullable instancetype)init;
@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (nullable instancetype)initWithInterceptorManager:
(GRPCInterceptorManager *_Nonnull)intercepterManager

@ -32,7 +32,7 @@
static NSString *const kPackage = @"grpc.testing";
static NSString *const kService = @"TestService";
@interface ViewController ()<GRPCResponseHandler>
@interface ViewController () <GRPCResponseHandler>
@end
@ -51,8 +51,9 @@ static NSString *const kService = @"TestService";
}
- (IBAction)tapCall:(id)sender {
GRPCProtoMethod *kUnaryCallMethod =
[[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"UnaryCall"];
GRPCProtoMethod *kUnaryCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"UnaryCall"];
GRPCRequestOptions *requestOptions =
[[GRPCRequestOptions alloc] initWithHost:@"grpc-test.sandbox.googleapis.com"

@ -18,6 +18,6 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property(strong, nonatomic) UIWindow* window;
@end

@ -66,18 +66,18 @@
path:method.HTTPPath
requestsWriter:requestsWriter];
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
RMTSimpleResponse *response = [RMTSimpleResponse parseFromData:value error:NULL];
NSLog(@"Received response:\n%@", response);
}
completionHandler:^(NSError *errorOrNil) {
if (errorOrNil) {
NSLog(@"Finished with error: %@", errorOrNil);
} else {
NSLog(@"Finished successfully.");
}
}];
completionHandler:^(NSError *errorOrNil) {
if (errorOrNil) {
NSLog(@"Finished with error: %@", errorOrNil);
} else {
NSLog(@"Finished successfully.");
}
}];
[call startWithWriteable:responsesWriteable];
}

@ -18,7 +18,7 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property(strong, nonatomic) UIWindow* window;

@ -28,7 +28,7 @@
#import <GRPCClient/GRPCCallOptions.h>
#import <ProtoRPC/ProtoRPC.h>
@interface ViewController ()<GRPCProtoResponseHandler>
@interface ViewController () <GRPCProtoResponseHandler>
@end
@ -50,8 +50,9 @@
- (IBAction)makeCall:(id)sender {
RMTSimpleRequest *request = [RMTSimpleRequest message];
request.responseSize = 100;
GRPCUnaryProtoCall *call =
[_service unaryCallWithMessage:request responseHandler:self callOptions:nil];
GRPCUnaryProtoCall *call = [_service unaryCallWithMessage:request
responseHandler:self
callOptions:nil];
[call start];
}

@ -18,6 +18,6 @@
#import <WatchKit/WatchKit.h>
@interface ExtensionDelegate : NSObject<WKExtensionDelegate>
@interface ExtensionDelegate : NSObject <WKExtensionDelegate>
@end

@ -27,7 +27,7 @@
#import <GRPCClient/GRPCCallOptions.h>
#import <ProtoRPC/ProtoRPC.h>
@interface InterfaceController ()<GRPCProtoResponseHandler>
@interface InterfaceController () <GRPCProtoResponseHandler>
@end
@ -51,8 +51,9 @@
- (IBAction)makeCall {
RMTSimpleRequest *request = [RMTSimpleRequest message];
request.responseSize = 100;
GRPCUnaryProtoCall *call =
[_service unaryCallWithMessage:request responseHandler:self callOptions:nil];
GRPCUnaryProtoCall *call = [_service unaryCallWithMessage:request
responseHandler:self
callOptions:nil];
[call start];
}

@ -18,7 +18,7 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property(strong, nonatomic) UIWindow* window;

@ -18,7 +18,7 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property(strong, nonatomic) UIWindow* window;

@ -26,7 +26,7 @@
NSString *const kRemoteHost = @"grpc-test.sandbox.googleapis.com";
const int32_t kMessageSize = 100;
@interface ViewController : UIViewController<GRPCProtoResponseHandler>
@interface ViewController : UIViewController <GRPCProtoResponseHandler>
@property(strong, nonatomic) UILabel *callStatusLabel;
@property(strong, nonatomic) UILabel *callCountLabel;
@end
@ -64,8 +64,9 @@ const int32_t kMessageSize = 100;
request.responseSize = kMessageSize;
request.payload.body = [NSMutableData dataWithLength:kMessageSize];
GRPCUnaryProtoCall *call =
[_service unaryCallWithMessage:request responseHandler:self callOptions:nil];
GRPCUnaryProtoCall *call = [_service unaryCallWithMessage:request
responseHandler:self
callOptions:nil];
[call start];
}

@ -47,13 +47,15 @@ NSString *host = @"grpc-test.sandbox.googleapis.com";
GRPCProtoMethod *method = [[GRPCProtoMethod alloc] initWithPackage:@"grpc.testing"
service:@"TestService"
method:@"UnaryCall"];
GRXWriter *loggingRequestWriter = [[GRXWriter
writerWithValue:[NSData dataWithBytes:bytes length:sizeof(bytes)]] map:^id(id value) {
NSLog(@"Sending request.");
return value;
}];
GRPCCall *call =
[[GRPCCall alloc] initWithHost:host path:method.HTTPPath requestsWriter:loggingRequestWriter];
GRXWriter *loggingRequestWriter =
[[GRXWriter writerWithValue:[NSData dataWithBytes:bytes
length:sizeof(bytes)]] map:^id(id value) {
NSLog(@"Sending request.");
return value;
}];
GRPCCall *call = [[GRPCCall alloc] initWithHost:host
path:method.HTTPPath
requestsWriter:loggingRequestWriter];
[call startWithWriteable:[GRXWriteable
writeableWithEventHandler:^(BOOL done, id value, NSError *error) {
@ -78,8 +80,9 @@ NSString *host = @"grpc-test.sandbox.googleapis.com";
[requestsBuffer writeValue:[NSData dataWithBytes:bytes length:sizeof(bytes)]];
GRPCCall *call =
[[GRPCCall alloc] initWithHost:host path:method.HTTPPath requestsWriter:requestsBuffer];
GRPCCall *call = [[GRPCCall alloc] initWithHost:host
path:method.HTTPPath
requestsWriter:requestsBuffer];
[call startWithWriteable:[GRXWriteable
writeableWithEventHandler:^(BOOL done, id value, NSError *error) {

@ -18,7 +18,7 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property(strong, nonatomic) UIWindow *window;
@end
@implementation AppDelegate

@ -18,7 +18,7 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property(strong, nonatomic) UIWindow* window;

@ -77,7 +77,7 @@ BOOL isRemoteInteropTest(NSString *host) {
return [host isEqualToString:@"grpc-test.sandbox.googleapis.com"];
}
@interface DefaultInterceptorFactory : NSObject<GRPCInterceptorFactory>
@interface DefaultInterceptorFactory : NSObject <GRPCInterceptorFactory>
- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager;
@ -87,28 +87,29 @@ BOOL isRemoteInteropTest(NSString *host) {
- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager {
dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
return
[[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager dispatchQueue:queue];
return [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager
dispatchQueue:queue];
}
@end
@interface HookInterceptorFactory : NSObject<GRPCInterceptorFactory>
@interface HookInterceptorFactory : NSObject <GRPCInterceptorFactory>
- (instancetype)
initWithDispatchQueue:(dispatch_queue_t)dispatchQueue
startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager))startHook
writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook
finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook
receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
GRPCInterceptorManager *manager))receiveNextMessagesHook
responseHeaderHook:(void (^)(NSDictionary *initialMetadata,
GRPCInterceptorManager *manager))responseHeaderHook
responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook
responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error,
GRPCInterceptorManager *manager))responseCloseHook
didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook;
initWithDispatchQueue:(dispatch_queue_t)dispatchQueue
startHook:(void (^)(GRPCRequestOptions *requestOptions,
GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager))startHook
writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook
finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook
receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
GRPCInterceptorManager *manager))receiveNextMessagesHook
responseHeaderHook:(void (^)(NSDictionary *initialMetadata,
GRPCInterceptorManager *manager))responseHeaderHook
responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook
responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error,
GRPCInterceptorManager *manager))responseCloseHook
didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook;
- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager;
@ -117,21 +118,21 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
@interface HookInterceptor : GRPCInterceptor
- (instancetype)
initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager
dispatchQueue:(dispatch_queue_t)dispatchQueue
startHook:(void (^)(GRPCRequestOptions *requestOptions,
GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager))startHook
writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook
finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook
receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
GRPCInterceptorManager *manager))receiveNextMessagesHook
responseHeaderHook:(void (^)(NSDictionary *initialMetadata,
GRPCInterceptorManager *manager))responseHeaderHook
responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook
responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error,
GRPCInterceptorManager *manager))responseCloseHook
didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook;
initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager
dispatchQueue:(dispatch_queue_t)dispatchQueue
startHook:(void (^)(GRPCRequestOptions *requestOptions,
GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager))startHook
writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook
finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook
receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
GRPCInterceptorManager *manager))receiveNextMessagesHook
responseHeaderHook:(void (^)(NSDictionary *initialMetadata,
GRPCInterceptorManager *manager))responseHeaderHook
responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook
responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error,
GRPCInterceptorManager *manager))responseCloseHook
didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook;
@end
@ -151,19 +152,20 @@ initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager
}
- (instancetype)
initWithDispatchQueue:(dispatch_queue_t)dispatchQueue
startHook:(void (^)(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager))startHook
writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook
finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook
receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
GRPCInterceptorManager *manager))receiveNextMessagesHook
responseHeaderHook:(void (^)(NSDictionary *initialMetadata,
GRPCInterceptorManager *manager))responseHeaderHook
responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook
responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error,
GRPCInterceptorManager *manager))responseCloseHook
didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook {
initWithDispatchQueue:(dispatch_queue_t)dispatchQueue
startHook:(void (^)(GRPCRequestOptions *requestOptions,
GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager))startHook
writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook
finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook
receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
GRPCInterceptorManager *manager))receiveNextMessagesHook
responseHeaderHook:(void (^)(NSDictionary *initialMetadata,
GRPCInterceptorManager *manager))responseHeaderHook
responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook
responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error,
GRPCInterceptorManager *manager))responseCloseHook
didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook {
if ((self = [super init])) {
_dispatchQueue = dispatchQueue;
_startHook = startHook;
@ -213,21 +215,21 @@ receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
}
- (instancetype)
initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager
dispatchQueue:(dispatch_queue_t)dispatchQueue
startHook:(void (^)(GRPCRequestOptions *requestOptions,
GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager))startHook
writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook
finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook
receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
GRPCInterceptorManager *manager))receiveNextMessagesHook
responseHeaderHook:(void (^)(NSDictionary *initialMetadata,
GRPCInterceptorManager *manager))responseHeaderHook
responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook
responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error,
GRPCInterceptorManager *manager))responseCloseHook
didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook {
initWithInterceptorManager:(GRPCInterceptorManager *)interceptorManager
dispatchQueue:(dispatch_queue_t)dispatchQueue
startHook:(void (^)(GRPCRequestOptions *requestOptions,
GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager))startHook
writeDataHook:(void (^)(id data, GRPCInterceptorManager *manager))writeDataHook
finishHook:(void (^)(GRPCInterceptorManager *manager))finishHook
receiveNextMessagesHook:(void (^)(NSUInteger numberOfMessages,
GRPCInterceptorManager *manager))receiveNextMessagesHook
responseHeaderHook:(void (^)(NSDictionary *initialMetadata,
GRPCInterceptorManager *manager))responseHeaderHook
responseDataHook:(void (^)(id data, GRPCInterceptorManager *manager))responseDataHook
responseCloseHook:(void (^)(NSDictionary *trailingMetadata, NSError *error,
GRPCInterceptorManager *manager))responseCloseHook
didWriteDataHook:(void (^)(GRPCInterceptorManager *manager))didWriteDataHook {
if ((self = [super initWithInterceptorManager:interceptorManager dispatchQueue:dispatchQueue])) {
_startHook = startHook;
_writeDataHook = writeDataHook;
@ -618,8 +620,8 @@ static dispatch_once_t initGlobalInterceptorFactory;
responseDispatchQueue:nil];
[[_service unaryCallWithMessage:request responseHandler:handler callOptions:options] start];
[[_service unaryCallWithMessage:request responseHandler:handlerMainQueue callOptions:options]
start];
[[_service unaryCallWithMessage:request responseHandler:handlerMainQueue
callOptions:options] start];
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
@ -1167,8 +1169,8 @@ static dispatch_once_t initGlobalInterceptorFactory;
__block BOOL receivedResponse = NO;
id request =
[RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415];
id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782
requestedResponseSize:@31415];
[requestsBuffer writeValue:request];
@ -1209,8 +1211,8 @@ static dispatch_once_t initGlobalInterceptorFactory;
options.PEMRootCertificates = self.class.PEMRootCertificates;
options.hostNameOverride = [[self class] hostNameOverride];
id request =
[RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415];
id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782
requestedResponseSize:@31415];
__block GRPCStreamingProtoCall *call = [_service
fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc]
@ -1244,8 +1246,8 @@ static dispatch_once_t initGlobalInterceptorFactory;
options.PEMRootCertificates = self.class.PEMRootCertificates;
options.hostNameOverride = [[self class] hostNameOverride];
id request =
[RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415];
id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782
requestedResponseSize:@31415];
__block GRPCStreamingProtoCall *call = [_service
fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc]
@ -1684,15 +1686,16 @@ static dispatch_once_t initGlobalInterceptorFactory;
__block NSUInteger responseDataCount = 0;
__block NSUInteger responseCloseCount = 0;
__block NSUInteger didWriteDataCount = 0;
[globalInterceptorFactory setStartHook:^(GRPCRequestOptions *requestOptions,
GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager) {
startCount++;
XCTAssertEqualObjects(requestOptions.host, [[self class] host]);
XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall");
XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault);
[manager startNextInterceptorWithRequest:[requestOptions copy] callOptions:[callOptions copy]];
}
[globalInterceptorFactory
setStartHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager) {
startCount++;
XCTAssertEqualObjects(requestOptions.host, [[self class] host]);
XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall");
XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault);
[manager startNextInterceptorWithRequest:[requestOptions copy]
callOptions:[callOptions copy]];
}
writeDataHook:^(id data, GRPCInterceptorManager *manager) {
writeDataCount++;
[manager writeNextInterceptorWithData:data];
@ -1869,15 +1872,16 @@ static dispatch_once_t initGlobalInterceptorFactory;
__block NSUInteger globalResponseCloseCount = 0;
__block NSUInteger globalDidWriteDataCount = 0;
[globalInterceptorFactory setStartHook:^(GRPCRequestOptions *requestOptions,
GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager) {
globalStartCount++;
XCTAssertEqualObjects(requestOptions.host, [[self class] host]);
XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall");
XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault);
[manager startNextInterceptorWithRequest:[requestOptions copy] callOptions:[callOptions copy]];
}
[globalInterceptorFactory
setStartHook:^(GRPCRequestOptions *requestOptions, GRPCCallOptions *callOptions,
GRPCInterceptorManager *manager) {
globalStartCount++;
XCTAssertEqualObjects(requestOptions.host, [[self class] host]);
XCTAssertEqualObjects(requestOptions.path, @"/grpc.testing.TestService/FullDuplexCall");
XCTAssertEqual(requestOptions.safety, GRPCCallSafetyDefault);
[manager startNextInterceptorWithRequest:[requestOptions copy]
callOptions:[callOptions copy]];
}
writeDataHook:^(id data, GRPCInterceptorManager *manager) {
globalWriteDataCount++;
[manager writeNextInterceptorWithData:data];

@ -19,7 +19,7 @@
#import <ProtoRPC/ProtoRPC.h>
// Convenience class to use blocks as callbacks
@interface InteropTestsBlockCallbacks : NSObject<GRPCProtoResponseHandler>
@interface InteropTestsBlockCallbacks : NSObject <GRPCProtoResponseHandler>
- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback
messageCallback:(void (^)(id))messageCallback

@ -43,8 +43,8 @@ static int32_t kLocalInteropServerOverhead = 10;
+ (NSString *)PEMRootCertificates {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"];
NSError *error;
return [NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error];
}
@ -66,8 +66,8 @@ static int32_t kLocalInteropServerOverhead = 10;
// Register test server certificates and name.
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"];
[GRPCCall useTestCertsPath:certsPath testName:@"foo.test.google.fr" forHost:kLocalSSLHost];
}

@ -100,11 +100,12 @@ dispatch_once_t initCronet;
// Local stack with SSL
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"];
NSError *error = nil;
NSString *certs =
[NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error];
NSString *certs = [NSString stringWithContentsOfFile:certsPath
encoding:NSUTF8StringEncoding
error:&error];
XCTAssertNil(error);
options = [[GRPCMutableCallOptions alloc] init];

@ -34,7 +34,7 @@
extern const char *kCFStreamVarName;
// Convenience class to use blocks as callbacks
@interface MacTestsBlockCallbacks : NSObject<GRPCProtoResponseHandler>
@interface MacTestsBlockCallbacks : NSObject <GRPCProtoResponseHandler>
- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback
messageCallback:(void (^)(id))messageCallback
@ -179,7 +179,6 @@ extern const char *kCFStreamVarName;
}
}
closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
@synchronized(self) {
if (error == nil && !address_removed) {
system([[NSString
@ -188,9 +187,9 @@ extern const char *kCFStreamVarName;
UTF8String]);
address_removed = YES;
} else if (error != nil && !address_readded) {
system([
[NSString stringWithFormat:@"sudo ifconfig lo0 alias %@",
[[self class] hostAddress]]
system([[NSString
stringWithFormat:@"sudo ifconfig lo0 alias %@",
[[self class] hostAddress]]
UTF8String]);
address_readded = YES;
}

@ -41,8 +41,8 @@ static int32_t kLocalInteropServerOverhead = 10;
+ (NSString *)PEMRootCertificates {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"];
NSError *error;
return [NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error];
}
@ -64,8 +64,8 @@ static int32_t kLocalInteropServerOverhead = 10;
// Register test server certificates and name.
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"];
[GRPCCall useTestCertsPath:certsPath testName:@"foo.test.google.fr" forHost:[[self class] host]];
}
@end

@ -60,7 +60,7 @@ extern const char *kCFStreamVarName;
}
@end
@interface DefaultInterceptorFactory : NSObject<GRPCInterceptorFactory>
@interface DefaultInterceptorFactory : NSObject <GRPCInterceptorFactory>
- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager;
@ -70,8 +70,8 @@ extern const char *kCFStreamVarName;
- (GRPCInterceptor *)createInterceptorWithManager:(GRPCInterceptorManager *)interceptorManager {
dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
return
[[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager dispatchQueue:queue];
return [[GRPCInterceptor alloc] initWithInterceptorManager:interceptorManager
dispatchQueue:queue];
}
@end
@ -158,7 +158,6 @@ extern const char *kCFStreamVarName;
closeCallback:^(NSDictionary *trailingMetadata,
NSError *error) {
[expectation fulfill];
}]
callOptions:options];
[call start];
@ -285,7 +284,6 @@ extern const char *kCFStreamVarName;
[expectation fulfill];
}
}
}]
callOptions:options];
dispatch_time_t timeout =

@ -19,7 +19,7 @@
#import <ProtoRPC/ProtoRPC.h>
// Convenience class to use blocks as callbacks
@interface PerfTestsBlockCallbacks : NSObject<GRPCProtoResponseHandler>
@interface PerfTestsBlockCallbacks : NSObject <GRPCProtoResponseHandler>
- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback
messageCallback:(void (^)(id))messageCallback

@ -45,8 +45,8 @@ static int32_t kLocalInteropServerOverhead = 10;
+ (NSString *)PEMRootCertificates {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"];
NSError *error;
return [NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error];
}
@ -72,8 +72,8 @@ static int32_t kLocalInteropServerOverhead = 10;
// Register test server certificates and name.
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"];
[GRPCCall useTestCertsPath:certsPath testName:@"foo.test.google.fr" forHost:kLocalSSLHost];
}

@ -45,8 +45,8 @@ static int32_t kLocalInteropServerOverhead = 10;
+ (NSString *)PEMRootCertificates {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"];
NSError *error;
return [NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error];
}
@ -72,8 +72,8 @@ static int32_t kLocalInteropServerOverhead = 10;
// Register test server certificates and name.
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"];
[GRPCCall useTestCertsPath:certsPath testName:@"foo.test.google.fr" forHost:kLocalSSLHost];
}

@ -57,7 +57,7 @@ static const NSTimeInterval kInvertedTimeout = 2;
@end
// Convenience class to use blocks as callbacks
@interface ClientTestsBlockCallbacks : NSObject<GRPCResponseHandler>
@interface ClientTestsBlockCallbacks : NSObject <GRPCResponseHandler>
- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback
messageCallback:(void (^)(id))messageCallback
@ -131,7 +131,7 @@ static const NSTimeInterval kInvertedTimeout = 2;
@end
@interface CallAPIv2Tests : XCTestCase<GRPCAuthorizationProtocol>
@interface CallAPIv2Tests : XCTestCase <GRPCAuthorizationProtocol>
@end
@ -139,17 +139,21 @@ static const NSTimeInterval kInvertedTimeout = 2;
- (void)setUp {
// This method isn't implemented by the remote server.
kInexistentMethod =
[[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"Inexistent"];
kEmptyCallMethod =
[[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"EmptyCall"];
kUnaryCallMethod =
[[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"UnaryCall"];
kInexistentMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"Inexistent"];
kEmptyCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"EmptyCall"];
kUnaryCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"UnaryCall"];
kOutputStreamingCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"StreamingOutputCall"];
kFullDuplexCallMethod =
[[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"FullDuplexCall"];
kFullDuplexCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"FullDuplexCall"];
}
- (void)testMetadata {
@ -217,54 +221,58 @@ static const NSTimeInterval kInvertedTimeout = 2;
options.initialMetadata = headers;
GRPCCall2 *call = [[GRPCCall2 alloc]
initWithRequestOptions:request
responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:^(
NSDictionary *initialMetadata) {
NSString *userAgent = initialMetadata[@"x-grpc-test-echo-useragent"];
// Test the regex is correct
NSString *expectedUserAgent = @"Foo grpc-objc/";
expectedUserAgent =
[expectedUserAgent stringByAppendingString:GRPC_OBJC_VERSION_STRING];
expectedUserAgent = [expectedUserAgent stringByAppendingString:@" grpc-c/"];
expectedUserAgent =
[expectedUserAgent stringByAppendingString:GRPC_C_VERSION_STRING];
expectedUserAgent = [expectedUserAgent stringByAppendingString:@" ("];
expectedUserAgent = [expectedUserAgent stringByAppendingString:@GPR_PLATFORM_STRING];
expectedUserAgent = [expectedUserAgent stringByAppendingString:@"; chttp2; "];
expectedUserAgent = [expectedUserAgent
stringByAppendingString:[NSString stringWithUTF8String:grpc_g_stands_for()]];
expectedUserAgent = [expectedUserAgent stringByAppendingString:@")"];
XCTAssertEqualObjects(userAgent, expectedUserAgent);
NSError *error = nil;
// Change in format of user-agent field in a direction that does not match
// the regex will likely cause problem for certain gRPC users. For details,
// refer to internal doc https://goo.gl/c2diBc
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:
@" grpc-[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?/[^ ,]+( \\([^)]*\\))?"
options:0
error:&error];
NSString *customUserAgent =
[regex stringByReplacingMatchesInString:userAgent
options:0
range:NSMakeRange(0, [userAgent length])
withTemplate:@""];
XCTAssertEqualObjects(customUserAgent, @"Foo");
[recvInitialMd fulfill];
}
messageCallback:^(id message) {
XCTAssertNotNil(message);
XCTAssertEqual([message length], 0,
@"Non-empty response received: %@", message);
}
closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
if (error) {
XCTFail(@"Finished with unexpected error: %@", error);
} else {
[completion fulfill];
}
}]
responseHandler:
[[ClientTestsBlockCallbacks alloc]
initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) {
NSString *userAgent = initialMetadata[@"x-grpc-test-echo-useragent"];
// Test the regex is correct
NSString *expectedUserAgent = @"Foo grpc-objc/";
expectedUserAgent =
[expectedUserAgent stringByAppendingString:GRPC_OBJC_VERSION_STRING];
expectedUserAgent = [expectedUserAgent stringByAppendingString:@" grpc-c/"];
expectedUserAgent =
[expectedUserAgent stringByAppendingString:GRPC_C_VERSION_STRING];
expectedUserAgent = [expectedUserAgent stringByAppendingString:@" ("];
expectedUserAgent =
[expectedUserAgent stringByAppendingString:@GPR_PLATFORM_STRING];
expectedUserAgent =
[expectedUserAgent stringByAppendingString:@"; chttp2; "];
expectedUserAgent = [expectedUserAgent
stringByAppendingString:[NSString
stringWithUTF8String:grpc_g_stands_for()]];
expectedUserAgent = [expectedUserAgent stringByAppendingString:@")"];
XCTAssertEqualObjects(userAgent, expectedUserAgent);
NSError *error = nil;
// Change in format of user-agent field in a direction that does not match
// the regex will likely cause problem for certain gRPC users. For details,
// refer to internal doc https://goo.gl/c2diBc
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:
@" grpc-[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?/[^ ,]+( \\([^)]*\\))?"
options:0
error:&error];
NSString *customUserAgent = [regex
stringByReplacingMatchesInString:userAgent
options:0
range:NSMakeRange(0, [userAgent length])
withTemplate:@""];
XCTAssertEqualObjects(customUserAgent, @"Foo");
[recvInitialMd fulfill];
}
messageCallback:^(id message) {
XCTAssertNotNil(message);
XCTAssertEqual([message length], 0, @"Non-empty response received: %@",
message);
}
closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
if (error) {
XCTFail(@"Finished with unexpected error: %@", error);
} else {
[completion fulfill];
}
}]
callOptions:options];
[call writeData:[NSData data]];
[call start];
@ -406,9 +414,8 @@ static const NSTimeInterval kInvertedTimeout = 2;
XCTFail(@"Failure: response received; Expect: no response received.");
}
closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
XCTAssertNotNil(error,
@"Failure: no error received; Expect: receive "
@"deadline exceeded.");
XCTAssertNotNil(error, @"Failure: no error received; Expect: receive "
@"deadline exceeded.");
if (error.code != GRPCErrorCodeDeadlineExceeded) {
NSLog(@"Unexpected error: %@", error);
}

@ -40,12 +40,13 @@ static NSString *kDummyPath = @"/dummy/path";
- (void)testPooledChannelCreatingChannel {
GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
GRPCChannelConfiguration *config =
[[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options];
GRPCChannelConfiguration *config = [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost
callOptions:options];
GRPCPooledChannel *channel = [[GRPCPooledChannel alloc] initWithChannelConfiguration:config];
GRPCCompletionQueue *cq = [GRPCCompletionQueue completionQueue];
GRPCWrappedCall *wrappedCall =
[channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
GRPCWrappedCall *wrappedCall = [channel wrappedCallWithPath:kDummyPath
completionQueue:cq
callOptions:options];
XCTAssertNotNil(channel.wrappedChannel);
(void)wrappedCall;
}
@ -53,8 +54,8 @@ static NSString *kDummyPath = @"/dummy/path";
- (void)testTimedDestroyChannel {
const NSTimeInterval kDestroyDelay = 1.0;
GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
GRPCChannelConfiguration *config =
[[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options];
GRPCChannelConfiguration *config = [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost
callOptions:options];
GRPCPooledChannel *channel =
[[GRPCPooledChannel alloc] initWithChannelConfiguration:config destroyDelay:kDestroyDelay];
GRPCCompletionQueue *cq = [GRPCCompletionQueue completionQueue];
@ -83,13 +84,14 @@ static NSString *kDummyPath = @"/dummy/path";
- (void)testDisconnect {
const NSTimeInterval kDestroyDelay = 1.0;
GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
GRPCChannelConfiguration *config =
[[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options];
GRPCChannelConfiguration *config = [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost
callOptions:options];
GRPCPooledChannel *channel =
[[GRPCPooledChannel alloc] initWithChannelConfiguration:config destroyDelay:kDestroyDelay];
GRPCCompletionQueue *cq = [GRPCCompletionQueue completionQueue];
GRPCWrappedCall *wrappedCall =
[channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
GRPCWrappedCall *wrappedCall = [channel wrappedCallWithPath:kDummyPath
completionQueue:cq
callOptions:options];
XCTAssertNotNil(channel.wrappedChannel);
// Disconnect; expect wrapped channel to be dropped
@ -98,8 +100,9 @@ static NSString *kDummyPath = @"/dummy/path";
// Create a new call and unref the old call; confirm that destroy of the old call does not make
// the channel disconnect, even after the destroy delay.
GRPCWrappedCall *wrappedCall2 =
[channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
GRPCWrappedCall *wrappedCall2 = [channel wrappedCallWithPath:kDummyPath
completionQueue:cq
callOptions:options];
XCTAssertNotNil(channel.wrappedChannel);
GRPCChannel *wrappedChannel = channel.wrappedChannel;
wrappedCall = nil;

@ -114,14 +114,18 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
[GRPCCall useInsecureConnectionsForHost:kHostAddress];
// This method isn't implemented by the remote server.
kInexistentMethod =
[[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"Inexistent"];
kEmptyCallMethod =
[[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"EmptyCall"];
kUnaryCallMethod =
[[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"UnaryCall"];
kFullDuplexCallMethod =
[[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"FullDuplexCall"];
kInexistentMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"Inexistent"];
kEmptyCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"EmptyCall"];
kUnaryCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"UnaryCall"];
kFullDuplexCallMethod = [[GRPCProtoMethod alloc] initWithPackage:kPackage
service:kService
method:@"FullDuplexCall"];
}
- (void)testConnectionToRemoteServer {
@ -131,15 +135,15 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
path:kInexistentMethod.HTTPPath
requestsWriter:[GRXWriter writerWithValue:[NSData data]]];
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTFail(@"Received unexpected response: %@", value);
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished without error!");
XCTAssertEqual(errorOrNil.code, 12, @"Finished with unexpected error: %@", errorOrNil);
[expectation fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished without error!");
XCTAssertEqual(errorOrNil.code, 12, @"Finished with unexpected error: %@", errorOrNil);
[expectation fulfill];
}];
[call startWithWriteable:responsesWriteable];
@ -155,16 +159,16 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
path:kEmptyCallMethod.HTTPPath
requestsWriter:[GRXWriter writerWithValue:[NSData data]]];
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTAssertNotNil(value, @"nil value received as response.");
XCTAssertEqual([value length], 0, @"Non-empty response received: %@", value);
[response fulfill];
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
@ -185,8 +189,8 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
path:kUnaryCallMethod.HTTPPath
requestsWriter:requestsWriter];
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTAssertNotNil(value, @"nil value received as response.");
XCTAssertGreaterThan(value.length, 0, @"Empty response received.");
RMTSimpleResponse *responseProto = [RMTSimpleResponse parseFromData:value error:NULL];
@ -195,10 +199,10 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
XCTAssertNotNil(responseProto.oauthScope, @"Response's OAuth scope is nil.");
[response fulfill];
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
@ -219,22 +223,22 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
call.oauth2AccessToken = @"bogusToken";
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTFail(@"Received unexpected response: %@", value);
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished without error!");
XCTAssertEqual(errorOrNil.code, 16, @"Finished with unexpected error: %@", errorOrNil);
XCTAssertEqualObjects(call.responseHeaders, errorOrNil.userInfo[kGRPCHeadersKey],
@"Headers in the NSError object and call object differ.");
XCTAssertEqualObjects(call.responseTrailers, errorOrNil.userInfo[kGRPCTrailersKey],
@"Trailers in the NSError object and call object differ.");
NSString *challengeHeader = call.oauth2ChallengeHeader;
XCTAssertGreaterThan(challengeHeader.length, 0, @"No challenge in response headers %@",
call.responseHeaders);
[expectation fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished without error!");
XCTAssertEqual(errorOrNil.code, 16, @"Finished with unexpected error: %@", errorOrNil);
XCTAssertEqualObjects(call.responseHeaders, errorOrNil.userInfo[kGRPCHeadersKey],
@"Headers in the NSError object and call object differ.");
XCTAssertEqualObjects(call.responseTrailers, errorOrNil.userInfo[kGRPCTrailersKey],
@"Trailers in the NSError object and call object differ.");
NSString *challengeHeader = call.oauth2ChallengeHeader;
XCTAssertGreaterThan(challengeHeader.length, 0, @"No challenge in response headers %@",
call.responseHeaders);
[expectation fulfill];
}];
[call startWithWriteable:responsesWriteable];
@ -260,16 +264,16 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
[call addObserver:observer forKeyPath:@"responseHeaders" options:0 context:NULL];
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTAssertNotNil(value, @"nil value received as response.");
XCTAssertEqual([value length], 0, @"Non-empty response received: %@", value);
[response fulfill];
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
@ -288,8 +292,8 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
// user-agent value, which we confirm.
call.requestHeaders[@"x-grpc-test-echo-useragent"] = @"";
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTAssertNotNil(value, @"nil value received as response.");
XCTAssertEqual([value length], 0, @"Non-empty response received: %@", value);
@ -325,10 +329,10 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
[response fulfill];
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
@ -349,18 +353,18 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
NSData *trailer_data = [NSData dataWithBytes:raw_bytes length:sizeof(raw_bytes)];
call.requestHeaders[@"x-grpc-test-echo-trailing-bin"] = trailer_data;
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTAssertNotNil(value, @"nil value received as response.");
XCTAssertEqual([value length], 0, @"Non-empty response received: %@", value);
[response fulfill];
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
XCTAssertEqualObjects((NSData *)call.responseTrailers[@"x-grpc-test-echo-trailing-bin"],
trailer_data, @"Did not receive expected trailer");
[completion fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
XCTAssertEqualObjects((NSData *)call.responseTrailers[@"x-grpc-test-echo-trailing-bin"],
trailer_data, @"Did not receive expected trailer");
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
@ -407,8 +411,8 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
host:kHostAddress
path:kUnaryCallMethod.HTTPPath];
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTAssertNotNil(value, @"nil value received as response.");
XCTAssertGreaterThan(value.length, 0, @"Empty response received.");
RMTSimpleResponse *responseProto = [RMTSimpleResponse parseFromData:value error:NULL];
@ -417,10 +421,10 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
XCTAssertNotNil(responseProto.oauthScope, @"Response's OAuth scope is nil.");
[response fulfill];
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNil(errorOrNil, @"Finished with unexpected error: %@", errorOrNil);
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
@ -445,16 +449,16 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
path:kUnaryCallMethod.HTTPPath
requestsWriter:requestsWriter1];
id<GRXWriteable> responsesWriteable1 =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable1 = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
NSString *label =
[NSString stringWithUTF8String:dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)];
XCTAssert([label isEqualToString:main_queue_label]);
[expectation1 fulfill];
}
completionHandler:^(NSError *errorOrNil){
}];
completionHandler:^(NSError *errorOrNil){
}];
[call1 startWithWriteable:responsesWriteable1];
@ -475,16 +479,16 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
[call2 setResponseDispatchQueue:queue];
id<GRXWriteable> responsesWriteable2 =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable2 = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
NSString *label =
[NSString stringWithUTF8String:dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)];
XCTAssert([label isEqualToString:queue_label]);
[expectation2 fulfill];
}
completionHandler:^(NSError *errorOrNil){
}];
completionHandler:^(NSError *errorOrNil){
}];
[call2 startWithWriteable:responsesWriteable2];
@ -499,16 +503,16 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
path:kFullDuplexCallMethod.HTTPPath
requestsWriter:pipe];
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTAssert(0, @"Failure: response received; Expect: no response received.");
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil,
@"Failure: no error received; Expect: receive deadline exceeded.");
XCTAssertEqual(errorOrNil.code, GRPCErrorCodeDeadlineExceeded);
[completion fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil,
@"Failure: no error received; Expect: receive deadline exceeded.");
XCTAssertEqual(errorOrNil.code, GRPCErrorCodeDeadlineExceeded);
[completion fulfill];
}];
call.timeout = 0.001;
[call startWithWriteable:responsesWriteable];
@ -539,16 +543,16 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
path:kEmptyCallMethod.HTTPPath
requestsWriter:[GRXWriter writerWithValue:[NSData data]]];
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
// Should not reach here
XCTAssert(NO);
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished with no error");
XCTAssertEqual(errorOrNil.code, GRPC_STATUS_UNAVAILABLE);
[completion fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished with no error");
XCTAssertEqual(errorOrNil.code, GRPC_STATUS_UNAVAILABLE);
[completion fulfill];
}];
[call startWithWriteable:responsesWriteable];
@ -570,9 +574,10 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
path:@"/dummyPath"
requestsWriter:[GRXWriter writerWithValue:[NSData data]]];
NSDate *startTime = [NSDate date];
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(id value) {
XCTAssert(NO, @"Received message. Should not reach here");
}
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(id value) {
XCTAssert(NO, @"Received message. Should not reach here");
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished with no error");
// The call must fail before maxConnectTime. However there is no lower bound on the time
@ -613,21 +618,21 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
call.oauth2AccessToken = @"bogusToken";
id<GRXWriteable> responsesWriteable =
[[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc]
initWithValueHandler:^(NSData *value) {
XCTFail(@"Received unexpected response: %@", value);
}
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished without error!");
NSDictionary *userInfo = errorOrNil.userInfo;
NSString *debugInformation = userInfo[NSDebugDescriptionErrorKey];
XCTAssertNotNil(debugInformation);
XCTAssertNotEqual([debugInformation length], 0);
NSString *challengeHeader = call.oauth2ChallengeHeader;
XCTAssertGreaterThan(challengeHeader.length, 0, @"No challenge in response headers %@",
call.responseHeaders);
[expectation fulfill];
}];
completionHandler:^(NSError *errorOrNil) {
XCTAssertNotNil(errorOrNil, @"Finished without error!");
NSDictionary *userInfo = errorOrNil.userInfo;
NSString *debugInformation = userInfo[NSDebugDescriptionErrorKey];
XCTAssertNotNil(debugInformation);
XCTAssertNotEqual([debugInformation length], 0);
NSString *challengeHeader = call.oauth2ChallengeHeader;
XCTAssertGreaterThan(challengeHeader.length, 0, @"No challenge in response headers %@",
call.responseHeaders);
[expectation fulfill];
}];
[call startWithWriteable:responsesWriteable];

@ -38,8 +38,9 @@
NSError *error3 = [NSError grpc_errorFromStatusCode:GRPC_STATUS_UNAUTHENTICATED
details:kDetails
errorString:nil];
NSError *error4 =
[NSError grpc_errorFromStatusCode:GRPC_STATUS_UNAVAILABLE details:nil errorString:nil];
NSError *error4 = [NSError grpc_errorFromStatusCode:GRPC_STATUS_UNAVAILABLE
details:nil
errorString:nil];
XCTAssertNil(error1);
XCTAssertEqual(error2.code, 1);

@ -31,7 +31,7 @@ static const GRPCTransportID kFakeTransportID = "io.grpc.transport.unittest.fake
dispatch_once_t initFakeTransportFactory;
static GRPCFakeTransportFactory *fakeTransportFactory;
@interface GRPCFakeTransportFactory : NSObject<GRPCTransportFactory>
@interface GRPCFakeTransportFactory : NSObject <GRPCTransportFactory>
@property(atomic) GRPCTransport *nextTransportInstance;
- (void)setTransportInterceptorFactories:(NSArray<id<GRPCInterceptorFactory>> *)factories;
@ -114,7 +114,7 @@ static GRPCFakeTransportFactory *fakeTransportFactory;
@end
@interface DummyInterceptorFactory : NSObject<GRPCInterceptorFactory>
@interface DummyInterceptorFactory : NSObject <GRPCInterceptorFactory>
- (instancetype)initWithPassthrough:(BOOL)passthrough;
@ -143,7 +143,7 @@ static GRPCFakeTransportFactory *fakeTransportFactory;
@end
@interface TestsBlockCallbacks : NSObject<GRPCResponseHandler>
@interface TestsBlockCallbacks : NSObject <GRPCResponseHandler>
- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback
dataCallback:(void (^)(id))dataCallback

@ -309,7 +309,7 @@ static bool client_ssl_test(char* server_alpn_preferred) {
return success;
}
int main(int /*argc*/, char* /*argv*/ []) {
int main(int /*argc*/, char* /*argv*/[]) {
// Handshake succeeeds when the server has grpc-exp as the ALPN preference.
GPR_ASSERT(client_ssl_test(const_cast<char*>("grpc-exp")));
// Handshake succeeeds when the server has h2 as the ALPN preference. This

@ -76,7 +76,7 @@ class ReadAheadHandshakerFactory : public HandshakerFactory {
} // namespace grpc_core
int main(int /*argc*/, char* /*argv*/ []) {
int main(int /*argc*/, char* /*argv*/[]) {
using namespace grpc_core;
grpc_init();
HandshakerRegistry::RegisterHandshakerFactory(

@ -36,7 +36,7 @@
#include "test/core/handshake/server_ssl_common.h"
int main(int /*argc*/, char* /*argv*/ []) {
int main(int /*argc*/, char* /*argv*/[]) {
// Handshake succeeeds when the client supplies the standard ALPN list.
const char* full_alpn_list[] = {"grpc-exp", "h2"};
GPR_ASSERT(server_ssl_test(full_alpn_list, 2, "grpc-exp"));

@ -105,8 +105,8 @@ class FakeHandshakeServer {
int port = grpc_pick_unused_port_or_die();
grpc_core::JoinHostPort(&address_, "localhost", port);
if (check_num_concurrent_rpcs) {
service_ = grpc::gcp::CreateFakeHandshakerService(
kFakeHandshakeServerMaxConcurrentStreams /* expected max concurrent rpcs */);
service_ = grpc::gcp::
CreateFakeHandshakerService(kFakeHandshakeServerMaxConcurrentStreams /* expected max concurrent rpcs */);
} else {
service_ = grpc::gcp::CreateFakeHandshakerService(
0 /* expected max concurrent rpcs unset */);

@ -49,9 +49,9 @@
#include "src/proto/grpc/lb/v1/load_balancer.grpc.pb.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
using grpc::lb::v1::LoadBalancer;
using grpc::lb::v1::LoadBalanceRequest;
using grpc::lb::v1::LoadBalanceResponse;
using grpc::lb::v1::LoadBalancer;
namespace grpc {
namespace testing {

@ -75,9 +75,9 @@
using std::chrono::system_clock;
using grpc::lb::v1::LoadBalancer;
using grpc::lb::v1::LoadBalanceRequest;
using grpc::lb::v1::LoadBalanceResponse;
using grpc::lb::v1::LoadBalancer;
namespace grpc {
namespace testing {

@ -42,6 +42,14 @@
#include <iostream>
using grpc::testing::DefaultReactorTestPeer;
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using grpc::testing::EchoTestService;
using grpc::testing::MockClientReaderWriter;
using std::vector;
using std::chrono::system_clock;
using ::testing::_;
using ::testing::AtLeast;
using ::testing::DoAll;
using ::testing::Invoke;
@ -49,14 +57,6 @@ using ::testing::Return;
using ::testing::SaveArg;
using ::testing::SetArgPointee;
using ::testing::WithArg;
using ::testing::_;
using grpc::testing::DefaultReactorTestPeer;
using grpc::testing::EchoRequest;
using grpc::testing::EchoResponse;
using grpc::testing::EchoTestService;
using grpc::testing::MockClientReaderWriter;
using std::chrono::system_clock;
using std::vector;
namespace grpc {
namespace testing {

@ -108,15 +108,15 @@ DEFINE_string(server_host_override, "",
using grpc::testing::ALTS;
using grpc::testing::INSECURE;
using grpc::testing::kTestCaseList;
using grpc::testing::MetricsService;
using grpc::testing::MetricsServiceImpl;
using grpc::testing::StressTestInteropClient;
using grpc::testing::TLS;
using grpc::testing::TestCaseType;
using grpc::testing::TLS;
using grpc::testing::transport_security;
using grpc::testing::UNKNOWN_TEST;
using grpc::testing::WeightedRandomTestSelector;
using grpc::testing::kTestCaseList;
using grpc::testing::transport_security;
static int log_level = GPR_LOG_SEVERITY_DEBUG;

@ -151,9 +151,9 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
// Specify which protected members we are using since there is no
// member name resolution until the template types are fully resolved
public:
using Client::closed_loop_;
using Client::NextIssuer;
using Client::SetupLoadTest;
using Client::closed_loop_;
using ClientImpl<StubType, RequestType>::cores_;
using ClientImpl<StubType, RequestType>::channels_;
using ClientImpl<StubType, RequestType>::request_;

@ -33,11 +33,11 @@ namespace testing {
namespace {
using ::grpc::load_reporter::CallMetricValue;
using ::grpc::load_reporter::kInvalidLbId;
using ::grpc::load_reporter::LoadDataStore;
using ::grpc::load_reporter::LoadRecordKey;
using ::grpc::load_reporter::LoadRecordValue;
using ::grpc::load_reporter::PerBalancerStore;
using ::grpc::load_reporter::kInvalidLbId;
class LoadDataStoreTest : public ::testing::Test {
public:

Loading…
Cancel
Save