Merge pull request #22210 from veblush/docker-for-sanity

Docker for sanity
pull/22228/head
Esun Kim 5 years ago committed by GitHub
commit 30f88e8b76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .clang-format
  2. 1
      .clang_complete
  3. 39
      CMakeLists.txt
  4. 48
      Makefile
  5. 13
      build_autogenerated.yaml
  6. 12
      include/grpcpp/impl/codegen/server_context_impl.h
  7. 2
      include/grpcpp/server_posix_impl.h
  8. 2
      src/compiler/csharp_generator.cc
  9. 1
      src/compiler/objective_c_generator.cc
  10. 3
      src/compiler/objective_c_generator.h
  11. 2
      src/compiler/objective_c_generator_helpers.h
  12. 4
      src/core/ext/filters/client_channel/lb_policy.cc
  13. 4
      src/core/ext/filters/client_channel/lb_policy.h
  14. 2
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc
  15. 4
      src/core/ext/filters/client_channel/resolver.cc
  16. 4
      src/core/ext/filters/client_channel/resolver.h
  17. 13
      src/core/ext/filters/client_channel/xds/xds_client_stats.cc
  18. 15
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  19. 2
      src/core/lib/gpr/time_posix.cc
  20. 2
      src/core/lib/gprpp/fork.cc
  21. 5
      src/core/lib/iomgr/ev_epoll1_linux.cc
  22. 6
      src/core/lib/iomgr/ev_poll_posix.cc
  23. 2
      src/core/lib/json/json_reader.cc
  24. 2
      src/core/lib/security/credentials/jwt/json_token.cc
  25. 2
      src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
  26. 2
      src/core/lib/surface/channel.cc
  27. 2
      src/core/lib/surface/channel.h
  28. 6
      src/core/lib/transport/metadata.cc
  29. 2
      src/core/lib/transport/static_metadata.h
  30. 7
      src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
  31. 2
      src/objective-c/GRPCClient/GRPCCall+GID.h
  32. 8
      src/objective-c/GRPCClient/GRPCCall+Interceptor.m
  33. 5
      src/objective-c/GRPCClient/GRPCCall+Tests.m
  34. 8
      src/objective-c/GRPCClient/GRPCCall.h
  35. 12
      src/objective-c/GRPCClient/GRPCCall.m
  36. 4
      src/objective-c/GRPCClient/GRPCCallLegacy.h
  37. 45
      src/objective-c/GRPCClient/GRPCCallLegacy.m
  38. 4
      src/objective-c/GRPCClient/GRPCCallOptions.h
  39. 20
      src/objective-c/GRPCClient/GRPCCallOptions.m
  40. 10
      src/objective-c/GRPCClient/GRPCInterceptor.h
  41. 6
      src/objective-c/GRPCClient/GRPCInterceptor.m
  42. 4
      src/objective-c/GRPCClient/GRPCTransport.h
  43. 6
      src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.h
  44. 5
      src/objective-c/GRPCClient/private/GRPCCore/GRPCChannel.m
  45. 4
      src/objective-c/GRPCClient/private/GRPCCore/GRPCChannelPool.h
  46. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCoreCronetFactory.h
  47. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreCronet/GRPCCronetChannelFactory.h
  48. 6
      src/objective-c/GRPCClient/private/GRPCCore/GRPCCoreFactory.h
  49. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCInsecureChannelFactory.h
  50. 14
      src/objective-c/GRPCClient/private/GRPCCore/GRPCRequestHeaders.m
  51. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCSecureChannelFactory.h
  52. 2
      src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.h
  53. 8
      src/objective-c/GRPCClient/private/GRPCCore/NSError+GRPC.m
  54. 2
      src/objective-c/GRPCClient/private/GRPCTransport+Private.h
  55. 8
      src/objective-c/ProtoRPC/ProtoMethod.h
  56. 8
      src/objective-c/ProtoRPC/ProtoRPC.h
  57. 6
      src/objective-c/ProtoRPC/ProtoRPC.m
  58. 37
      src/objective-c/ProtoRPC/ProtoRPCLegacy.h
  59. 22
      src/objective-c/ProtoRPC/ProtoRPCLegacy.m
  60. 23
      src/objective-c/ProtoRPC/ProtoService.h
  61. 10
      src/objective-c/ProtoRPC/ProtoService.m
  62. 5
      src/objective-c/ProtoRPC/ProtoServiceLegacy.m
  63. 2
      src/objective-c/RxLibrary/GRXBufferedPipe.h
  64. 2
      src/objective-c/RxLibrary/GRXForwardingWriter.m
  65. 2
      src/objective-c/RxLibrary/GRXMappingWriter.m
  66. 4
      src/objective-c/RxLibrary/GRXWriteable.h
  67. 13
      src/objective-c/RxLibrary/GRXWriteable.m
  68. 2
      src/objective-c/examples/InterceptorSample/InterceptorSample/AppDelegate.h
  69. 8
      src/objective-c/examples/InterceptorSample/InterceptorSample/CacheInterceptor.h
  70. 7
      src/objective-c/examples/InterceptorSample/InterceptorSample/ViewController.m
  71. 2
      src/objective-c/examples/Sample/Sample/AppDelegate.h
  72. 18
      src/objective-c/examples/Sample/Sample/ViewController.m
  73. 2
      src/objective-c/examples/tvOS-sample/tvOS-sample/AppDelegate.h
  74. 7
      src/objective-c/examples/tvOS-sample/tvOS-sample/ViewController.m
  75. 2
      src/objective-c/examples/watchOS-sample/WatchKit-Extension/ExtensionDelegate.h
  76. 7
      src/objective-c/examples/watchOS-sample/WatchKit-Extension/InterfaceController.m
  77. 2
      src/objective-c/examples/watchOS-sample/watchOS-sample/AppDelegate.h
  78. 2
      src/objective-c/manual_tests/AppDelegate.h
  79. 7
      src/objective-c/manual_tests/ViewController.m
  80. 21
      src/objective-c/tests/Connectivity/ConnectivityTestingApp/ViewController.m
  81. 2
      src/objective-c/tests/Connectivity/ConnectivityTestingApp/main.m
  82. 2
      src/objective-c/tests/Hosts/ios-host/AppDelegate.h
  83. 176
      src/objective-c/tests/InteropTests/InteropTests.m
  84. 2
      src/objective-c/tests/InteropTests/InteropTestsBlockCallbacks.h
  85. 8
      src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m
  86. 9
      src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m
  87. 9
      src/objective-c/tests/MacTests/StressTests.m
  88. 8
      src/objective-c/tests/MacTests/StressTestsSSL.m
  89. 8
      src/objective-c/tests/PerfTests/PerfTests.m
  90. 2
      src/objective-c/tests/PerfTests/PerfTestsBlockCallbacks.h
  91. 8
      src/objective-c/tests/PerfTests/PerfTestsCFStreamSSL.m
  92. 8
      src/objective-c/tests/PerfTests/PerfTestsNoCFStreamSSL.m
  93. 129
      src/objective-c/tests/UnitTests/APIv2Tests.m
  94. 27
      src/objective-c/tests/UnitTests/ChannelTests.m
  95. 217
      src/objective-c/tests/UnitTests/GRPCClientTests.m
  96. 5
      src/objective-c/tests/UnitTests/NSErrorUnitTests.m
  97. 6
      src/objective-c/tests/UnitTests/TransportTests.m
  98. 7
      templates/tools/dockerfile/clang5.include
  99. 8
      templates/tools/dockerfile/grpc_clang_format/Dockerfile.template
  100. 10
      templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,6 +1,6 @@
---
Language: Cpp
BasedOnStyle: Google
Language: Cpp
BasedOnStyle: Google
DerivePointerAlignment: false
PointerAlignment: Left
---
@ -9,4 +9,3 @@ BasedOnStyle: Google
ColumnLimit: 100
ObjCBlockIndentWidth: 2
...

@ -5,6 +5,7 @@
-Iinclude
-Isrc/core/ext/upb-generated
-Ithird_party/abseil-cpp
-Ithird_party/address_sorting/include
-Ithird_party/benchmark/include
-Ithird_party/boringssl-with-bazel/src/include
-Ithird_party/cares

@ -740,7 +740,6 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_cxx http2_client)
add_dependencies(buildtests_cxx hybrid_end2end_test)
add_dependencies(buildtests_cxx initial_settings_frame_bad_client_test)
add_dependencies(buildtests_cxx inlined_vector_test)
add_dependencies(buildtests_cxx interop_client)
add_dependencies(buildtests_cxx interop_server)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
@ -11625,44 +11624,6 @@ target_link_libraries(initial_settings_frame_bad_client_test
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(inlined_vector_test
test/core/gprpp/inlined_vector_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(inlined_vector_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(inlined_vector_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
grpc
gpr
address_sorting
upb
${_gRPC_GFLAGS_LIBRARIES}
)
endif()
if(gRPC_BUILD_TESTS)

@ -1237,7 +1237,6 @@ http_request_fuzzer_test: $(BINDIR)/$(CONFIG)/http_request_fuzzer_test
http_response_fuzzer_test: $(BINDIR)/$(CONFIG)/http_response_fuzzer_test
hybrid_end2end_test: $(BINDIR)/$(CONFIG)/hybrid_end2end_test
initial_settings_frame_bad_client_test: $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test
inlined_vector_test: $(BINDIR)/$(CONFIG)/inlined_vector_test
interop_client: $(BINDIR)/$(CONFIG)/interop_client
interop_server: $(BINDIR)/$(CONFIG)/interop_server
interop_test: $(BINDIR)/$(CONFIG)/interop_test
@ -1605,7 +1604,6 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/http2_client \
$(BINDIR)/$(CONFIG)/hybrid_end2end_test \
$(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test \
$(BINDIR)/$(CONFIG)/inlined_vector_test \
$(BINDIR)/$(CONFIG)/interop_client \
$(BINDIR)/$(CONFIG)/interop_server \
$(BINDIR)/$(CONFIG)/interop_test \
@ -1762,7 +1760,6 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/http2_client \
$(BINDIR)/$(CONFIG)/hybrid_end2end_test \
$(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test \
$(BINDIR)/$(CONFIG)/inlined_vector_test \
$(BINDIR)/$(CONFIG)/interop_client \
$(BINDIR)/$(CONFIG)/interop_server \
$(BINDIR)/$(CONFIG)/interop_test \
@ -2271,8 +2268,6 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/hybrid_end2end_test || ( echo test hybrid_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing initial_settings_frame_bad_client_test"
$(Q) $(BINDIR)/$(CONFIG)/initial_settings_frame_bad_client_test || ( echo test initial_settings_frame_bad_client_test failed ; exit 1 )
$(E) "[RUN] Testing inlined_vector_test"
$(Q) $(BINDIR)/$(CONFIG)/inlined_vector_test || ( echo test inlined_vector_test failed ; exit 1 )
$(E) "[RUN] Testing interop_test"
$(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 )
$(E) "[RUN] Testing json_test"
@ -15520,49 +15515,6 @@ endif
endif
INLINED_VECTOR_TEST_SRC = \
test/core/gprpp/inlined_vector_test.cc \
INLINED_VECTOR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(INLINED_VECTOR_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/inlined_vector_test: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+.
$(BINDIR)/$(CONFIG)/inlined_vector_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/inlined_vector_test: $(PROTOBUF_DEP) $(INLINED_VECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(INLINED_VECTOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/inlined_vector_test
endif
endif
$(OBJDIR)/$(CONFIG)/test/core/gprpp/inlined_vector_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libaddress_sorting.a $(LIBDIR)/$(CONFIG)/libupb.a
deps_inlined_vector_test: $(INLINED_VECTOR_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(INLINED_VECTOR_TEST_OBJS:.o=.dep)
endif
endif
INTEROP_CLIENT_SRC = \
$(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc \
$(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc \

@ -6256,19 +6256,6 @@ targets:
- gpr
- address_sorting
- upb
- name: inlined_vector_test
gtest: true
build: test
language: c++
headers: []
src:
- test/core/gprpp/inlined_vector_test.cc
deps:
- grpc_test_util
- grpc
- gpr
- address_sorting
- upb
- name: interop_client
build: test
run: false

@ -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";

@ -57,7 +57,7 @@ LoadBalancingPolicy::UpdateArgs::UpdateArgs(const UpdateArgs& other) {
args = grpc_channel_args_copy(other.args);
}
LoadBalancingPolicy::UpdateArgs::UpdateArgs(UpdateArgs&& other) {
LoadBalancingPolicy::UpdateArgs::UpdateArgs(UpdateArgs&& other) noexcept {
addresses = std::move(other.addresses);
config = std::move(other.config);
// TODO(roth): Use std::move() once channel args is converted to C++.
@ -75,7 +75,7 @@ LoadBalancingPolicy::UpdateArgs& LoadBalancingPolicy::UpdateArgs::operator=(
}
LoadBalancingPolicy::UpdateArgs& LoadBalancingPolicy::UpdateArgs::operator=(
UpdateArgs&& other) {
UpdateArgs&& other) noexcept {
addresses = std::move(other.addresses);
config = std::move(other.config);
// TODO(roth): Use std::move() once channel args is converted to C++.

@ -302,9 +302,9 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
UpdateArgs() = default;
~UpdateArgs() { grpc_channel_args_destroy(args); }
UpdateArgs(const UpdateArgs& other);
UpdateArgs(UpdateArgs&& other);
UpdateArgs(UpdateArgs&& other) noexcept;
UpdateArgs& operator=(const UpdateArgs& other);
UpdateArgs& operator=(UpdateArgs&& other);
UpdateArgs& operator=(UpdateArgs&& other) noexcept;
};
/// Args used to instantiate an LB policy.

@ -131,7 +131,7 @@ class XdsLb : public LoadBalancingPolicy {
public:
explicit RefCountedEndpointPicker(std::unique_ptr<SubchannelPicker> picker)
: picker_(std::move(picker)) {}
PickResult Pick(PickArgs args) { return picker_->Pick(std::move(args)); }
PickResult Pick(PickArgs args) { return picker_->Pick(args); }
private:
std::unique_ptr<SubchannelPicker> picker_;

@ -54,7 +54,7 @@ Resolver::Result::Result(const Result& other) {
args = grpc_channel_args_copy(other.args);
}
Resolver::Result::Result(Result&& other) {
Resolver::Result::Result(Result&& other) noexcept {
addresses = std::move(other.addresses);
service_config = std::move(other.service_config);
service_config_error = other.service_config_error;
@ -73,7 +73,7 @@ Resolver::Result& Resolver::Result::operator=(const Result& other) {
return *this;
}
Resolver::Result& Resolver::Result::operator=(Result&& other) {
Resolver::Result& Resolver::Result::operator=(Result&& other) noexcept {
addresses = std::move(other.addresses);
service_config = std::move(other.service_config);
GRPC_ERROR_UNREF(service_config_error);

@ -60,9 +60,9 @@ class Resolver : public InternallyRefCounted<Resolver> {
Result() = default;
~Result();
Result(const Result& other);
Result(Result&& other);
Result(Result&& other) noexcept;
Result& operator=(const Result& other);
Result& operator=(Result&& other);
Result& operator=(Result&& other) noexcept;
};
/// A proxy object used by the resolver to return results to the

@ -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;

@ -20,19 +20,18 @@
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "absl/strings/str_format.h"
#include "src/core/ext/transport/chttp2/transport/context_list.h"
#include "src/core/ext/transport/chttp2/transport/frame_data.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
@ -1097,8 +1096,10 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
"Received a GOAWAY with error code ENHANCE_YOUR_CALM and debug "
"data equal to \"too_many_pings\"");
double current_keepalive_time_ms = static_cast<double>(t->keepalive_time);
constexpr int max_keepalive_time_ms =
INT_MAX / KEEPALIVE_TIME_BACKOFF_MULTIPLIER;
t->keepalive_time =
current_keepalive_time_ms > INT_MAX / KEEPALIVE_TIME_BACKOFF_MULTIPLIER
current_keepalive_time_ms > static_cast<double>(max_keepalive_time_ms)
? GRPC_MILLIS_INF_FUTURE
: static_cast<grpc_millis>(current_keepalive_time_ms *
KEEPALIVE_TIME_BACKOFF_MULTIPLIER);

@ -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__)

@ -235,7 +235,7 @@ void JsonReader::SetString() {
bool JsonReader::SetNumber() {
Json* value = CreateAndLinkValue();
*value = Json(std::move(string_), /*is_number=*/true);
*value = Json(string_, /*is_number=*/true);
string_.clear();
return true;
}

@ -127,7 +127,7 @@ grpc_auth_json_key grpc_auth_json_key_create_from_string(
grpc_error* error = GRPC_ERROR_NONE;
Json json = Json::Parse(json_string, &error);
GRPC_LOG_IF_ERROR("JSON key parsing", error);
return grpc_auth_json_key_create_from_json(std::move(json));
return grpc_auth_json_key_create_from_json(json);
}
void grpc_auth_json_key_destruct(grpc_auth_json_key* json_key) {

@ -97,7 +97,7 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string(
gpr_log(GPR_ERROR, "JSON parsing failed: %s", grpc_error_string(error));
GRPC_ERROR_UNREF(error);
}
return grpc_auth_refresh_token_create_from_json(std::move(json));
return grpc_auth_refresh_token_create_from_json(json);
}
void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token) {

@ -429,7 +429,7 @@ RegisteredCall::RegisteredCall(const RegisteredCall& other) {
GRPC_MDELEM_REF(authority);
}
RegisteredCall::RegisteredCall(RegisteredCall&& other) {
RegisteredCall::RegisteredCall(RegisteredCall&& other) noexcept {
path = other.path;
authority = other.authority;
other.path = GRPC_MDNULL;

@ -76,7 +76,7 @@ struct RegisteredCall {
// TODO(vjpai): delete copy constructor once all supported compilers allow
// std::map value_type to be MoveConstructible.
RegisteredCall(const RegisteredCall& other);
RegisteredCall(RegisteredCall&& other);
RegisteredCall(RegisteredCall&& other) noexcept;
~RegisteredCall();
};

@ -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

@ -1,7 +0,0 @@
RUN apt-get update && apt-get -y install wget xz-utils
RUN wget http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
RUN tar xf clang+llvm-5.0.0-linux-x86_64-ubuntu14.04.tar.xz
RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-format /usr/local/bin/clang-format
ENV CLANG_FORMAT=clang-format
RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-tidy /usr/local/bin/clang-tidy
ENV CLANG_TIDY=clang-tidy

@ -13,10 +13,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
<%include file="../debian_jessie_header.include"/>
<%include file="../clang5.include"/>
FROM debian:10
RUN apt-get update && apt-get install -y clang-format
ADD clang_format_all_the_things.sh /
# When running locally, we'll be impersonating the current user, so we need

@ -14,9 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
<%include file="../debian_jessie_header.include"/>
FROM debian:10
<%include file="../clang5.include"/>
# Install clang-tidy 6.0
# This is because clang-tidy 7.0 started treating compiler errors as tidy errors
# and there are a couple of files which are not properly compiled via tidy so it
# should be using 6.0 version until all compilation errors are addressed.
RUN apt-get update && apt-get install -y clang-tidy-6.0
ENV CLANG_TIDY=clang-tidy-6.0
<%include file="../python_deps.include"/>
ADD clang_tidy_all_the_things.sh /

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save