ProtoRPC.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. *
  3. * Copyright 2015 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #import <Foundation/Foundation.h>
  19. #import <GRPCClient/GRPCCall.h>
  20. #import "ProtoMethod.h"
  21. @class GPBMessage;
  22. /** A unary-request RPC call with Protobuf. */
  23. @interface GRPCUnaryProtoCall : NSObject
  24. - (instancetype)init NS_UNAVAILABLE;
  25. + (instancetype)new NS_UNAVAILABLE;
  26. /**
  27. * Users should not use this initializer directly. Call objects will be created, initialized, and
  28. * returned to users by methods of the generated service.
  29. */
  30. - (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
  31. message:(GPBMessage *)message
  32. responseHandler:(id<GRPCResponseHandler>)handler
  33. callOptions:(GRPCCallOptions *)callOptions
  34. responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
  35. /** Cancel the call at best effort. */
  36. - (void)cancel;
  37. @end
  38. /** A client-streaming RPC call with Protobuf. */
  39. @interface GRPCStreamingProtoCall : NSObject
  40. - (instancetype)init NS_UNAVAILABLE;
  41. + (instancetype)new NS_UNAVAILABLE;
  42. /**
  43. * Users should not use this initializer directly. Call objects will be created, initialized, and
  44. * returned to users by methods of the generated service.
  45. */
  46. - (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
  47. responseHandler:(id<GRPCResponseHandler>)handler
  48. callOptions:(GRPCCallOptions *)callOptions
  49. responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
  50. /** Cancel the call at best effort. */
  51. - (void)cancel;
  52. /**
  53. * Send a message to the server. The message should be a Protobuf message which will be serialized
  54. * internally.
  55. */
  56. - (void)writeWithMessage:(GPBMessage *)message;
  57. /**
  58. * Finish the RPC request and half-close the call. The server may still send messages and/or
  59. * trailers to the client.
  60. */
  61. - (void)finish;
  62. @end
  63. __attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC
  64. : GRPCCall
  65. /**
  66. * host parameter should not contain the scheme (http:// or https://), only the name or IP
  67. * addr and the port number, for example @"localhost:5050".
  68. */
  69. -
  70. (instancetype)initWithHost : (NSString *)host method
  71. : (GRPCProtoMethod *)method requestsWriter : (GRXWriter *)requestsWriter responseClass
  72. : (Class)responseClass responsesWriteable
  73. : (id<GRXWriteable>)responsesWriteable NS_DESIGNATED_INITIALIZER;
  74. - (void)start;
  75. @end
  76. /**
  77. * This subclass is empty now. Eventually we'll remove ProtoRPC class
  78. * to avoid potential naming conflict
  79. */
  80. #pragma clang diagnostic push
  81. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  82. @interface GRPCProtoCall : ProtoRPC
  83. #pragma clang diagnostic pop
  84. @end