protocol-grpc 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 121472581aa9d3d84bc5b1542bbe6d49274180ae0129d151a2b8f6aca9377026
4
- data.tar.gz: 820130b179cf141d525cc483900a14edbc68705c6f318e469c258c1e6cb0735d
3
+ metadata.gz: 5ead258154cb8fe775c509d2b4aa05aadee904b18f052ff72163559c45ffdae0
4
+ data.tar.gz: 5af2daafbecc85fcd2fa722f9c8e02a262997e0a7fe1fdc0196fab7af80cf2aa
5
5
  SHA512:
6
- metadata.gz: 8576fe2b1c9f6f0b88e2472c34bd5720e48e33c43da18845360e52c10017410ea1b730d206a71c47ad8e8b5e7b9e132e9e795524e8baea89f67156bb660e0bfc
7
- data.tar.gz: cc61e8bc843aa2e27ad8a6c9d9e63788be37729a53060b19a486b572e6761aa35fb066edf1493b63ff4b71bb1f5058af6014a7c8deb3c9f92d6c76a272925e9a
6
+ metadata.gz: 1e417c6adce8b055da14fd619381f3de243022ed2e9a27841cb2fab0c0c5232c57bbd559728cfcbf72e1ab61e49981f93d100cde21d3a4d194c0f17a89bc1087
7
+ data.tar.gz: 88290f4fb1f059056e0a545eaae4d90efcb4c7b01e69937ecfa17370392092edd66ce178ed1ebab68da3fbb90bfe879ff02ac6ea20f9768e377faa01c7445aa4
checksums.yaml.gz.sig CHANGED
Binary file
@@ -15,8 +15,8 @@ $ bundle add protocol-grpc
15
15
  `protocol-grpc` has several core concepts:
16
16
 
17
17
  - A {ruby Protocol::GRPC::Interface} class which defines gRPC service contracts with RPC methods, request/response types, and streaming patterns.
18
- - A {ruby Protocol::GRPC::Body::ReadableBody} class which handles reading gRPC messages from HTTP request/response bodies with automatic framing and decoding.
19
- - A {ruby Protocol::GRPC::Body::WritableBody} class which handles writing gRPC messages to HTTP request/response bodies with automatic framing and encoding.
18
+ - A {ruby Protocol::GRPC::Body::Readable} class which handles reading gRPC messages from HTTP request/response bodies with automatic framing and decoding.
19
+ - A {ruby Protocol::GRPC::Body::Writable} class which handles writing gRPC messages to HTTP request/response bodies with automatic framing and encoding.
20
20
  - A {ruby Protocol::GRPC::Middleware} abstract base class for building gRPC server applications.
21
21
  - A {ruby Protocol::GRPC::Call} class which represents the context of a single gRPC RPC call, including deadline tracking.
22
22
  - A {ruby Protocol::GRPC::Status} module with gRPC status code constants.
@@ -39,23 +39,38 @@ This gem provides protocol-level abstractions only. To actually send requests ov
39
39
  require "protocol/grpc/interface"
40
40
 
41
41
  class GreeterInterface < Protocol::GRPC::Interface
42
- rpc :SayHello, request_class: Hello::HelloRequest, response_class: Hello::HelloReply
43
- rpc :SayHelloAgain, request_class: Hello::HelloRequest, response_class: Hello::HelloReply,
44
- streaming: :server_streaming
42
+ # Unary RPC (single request, single response)
43
+ rpc :SayHello, Hello::HelloRequest, Hello::HelloReply
44
+
45
+ # Server streaming RPC using stream() decorator
46
+ rpc :SayHelloMany, Hello::HelloRequest, stream(Hello::HelloReply)
47
+
48
+ # Client streaming RPC
49
+ rpc :SayHelloRepeatedly, stream(Hello::HelloRequest), Hello::HelloReply
50
+
51
+ # Bidirectional streaming RPC
52
+ rpc :ChatHello, stream(Hello::HelloRequest), stream(Hello::HelloReply)
45
53
  end
46
54
  ```
47
55
 
56
+ The `stream()` decorator marks message types as streamed. You can also use the keyword syntax:
57
+
58
+ ``` ruby
59
+ rpc :SayHelloAgain, request_class: Hello::HelloRequest, response_class: Hello::HelloReply,
60
+ streaming: :server_streaming
61
+ ```
62
+
48
63
  ### Building a Request
49
64
 
50
- Build gRPC requests using `Protocol::GRPC::Methods` and `Protocol::GRPC::Body::WritableBody`:
65
+ Build gRPC requests using `Protocol::GRPC::Methods` and `Protocol::GRPC::Body::Writable`:
51
66
 
52
67
  ``` ruby
53
68
  require "protocol/grpc"
54
69
  require "protocol/grpc/methods"
55
- require "protocol/grpc/body/writable_body"
70
+ require "protocol/grpc/body/writable"
56
71
 
57
72
  # Build request body
58
- body = Protocol::GRPC::Body::WritableBody.new(message_class: Hello::HelloRequest)
73
+ body = Protocol::GRPC::Body::Writable.new(message_class: Hello::HelloRequest)
59
74
  body.write(Hello::HelloRequest.new(name: "World"))
60
75
  body.close_write
61
76
 
@@ -69,13 +84,13 @@ request = Protocol::HTTP::Request["POST", path, headers, body]
69
84
 
70
85
  ### Reading a Response
71
86
 
72
- Read gRPC responses using `Protocol::GRPC::Body::ReadableBody`:
87
+ Read gRPC responses using `Protocol::GRPC::Body::Readable`:
73
88
 
74
89
  ``` ruby
75
- require "protocol/grpc/body/readable_body"
90
+ require "protocol/grpc/body/readable"
76
91
 
77
92
  # Read response body
78
- readable_body = Protocol::GRPC::Body::ReadableBody.new(
93
+ readable_body = Protocol::GRPC::Body::Readable.new(
79
94
  response.body,
80
95
  message_class: Hello::HelloReply
81
96
  )
data/design.md CHANGED
@@ -140,7 +140,7 @@ module Protocol
140
140
 
141
141
  # Parse service and method from gRPC path
142
142
  # @parameter path [String] e.g., "/my_service.Greeter/SayHello"
143
- # @returns [Array(String, String)] [service, method]
143
+ # @returns [Tuple(String, String)] of service and method.
144
144
  def self.parse_path(path)
145
145
  parts = path.split("/")
146
146
  [parts[1], parts[2]]
@@ -287,28 +287,28 @@ module Protocol
287
287
 
288
288
  # Extract gRPC status message from headers
289
289
  # @parameter headers [Protocol::HTTP::Headers]
290
- # @returns [String, nil] Status message
290
+ # @returns [String | Nil] Status message
291
291
  def self.extract_message(headers)
292
292
  message = headers["grpc-message"]
293
293
  message ? URI.decode_www_form_component(message) : nil
294
294
  end
295
295
 
296
- # Add gRPC status, message, and optional backtrace to headers.
297
- # Whether these become headers or trailers is controlled by the protocol layer.
298
- # @parameter headers [Protocol::HTTP::Headers]
299
- # @parameter status [Integer] gRPC status code
300
- # @parameter message [String | Nil] Optional status message
301
- # @parameter error [Exception | Nil] Optional error object (used to extract backtrace)
302
- def self.add_status!(headers, status: Status::OK, message: nil, error: nil)
303
- headers["grpc-status"] = Header::Status.new(status)
304
- headers["grpc-message"] = Header::Message.new(Header::Message.encode(message)) if message
305
-
296
+ # Add gRPC status, message, and optional backtrace to headers.
297
+ # Whether these become headers or trailers is controlled by the protocol layer.
298
+ # @parameter headers [Protocol::HTTP::Headers]
299
+ # @parameter status [Integer] gRPC status code
300
+ # @parameter message [String | Nil] Optional status message
301
+ # @parameter error [Exception | Nil] Optional error object (used to extract backtrace)
302
+ def self.add_status!(headers, status: Status::OK, message: nil, error: nil)
303
+ headers["grpc-status"] = Header::Status.new(status)
304
+ headers["grpc-message"] = Header::Message.new(Header::Message.encode(message)) if message
305
+
306
306
  # Add backtrace from error if available
307
- if error && error.backtrace && !error.backtrace.empty?
308
- headers["backtrace"] = error.backtrace
307
+ if error && error.backtrace && !error.backtrace.empty?
308
+ headers["backtrace"] = error.backtrace
309
+ end
309
310
  end
310
311
  end
311
- end
312
312
  end
313
313
  end
314
314
  ```
@@ -329,7 +329,7 @@ module Protocol
329
329
  # @parameter body [Protocol::HTTP::Body::Readable] The underlying HTTP body
330
330
  # @parameter message_class [Class, nil] Protobuf message class with .decode method
331
331
  # If nil, returns raw binary data (useful for channel adapters)
332
- # @parameter encoding [String, nil] Compression encoding (from grpc-encoding header)
332
+ # @parameter encoding [String | Nil] Compression encoding (from grpc-encoding header)
333
333
  def initialize(body, message_class: nil, encoding: nil)
334
334
  super(body)
335
335
  @message_class = message_class
@@ -408,7 +408,7 @@ module Protocol
408
408
  # Writes length-prefixed gRPC messages
409
409
  # This is the standard writable body for gRPC - all gRPC requests use message framing
410
410
  class Writable < Protocol::HTTP::Body::Writable
411
- # @parameter encoding [String, nil] Compression encoding (gzip, deflate, identity)
411
+ # @parameter encoding [String | Nil] Compression encoding (gzip, deflate, identity)
412
412
  # @parameter level [Integer] Compression level if encoding is used
413
413
  def initialize(encoding: nil, level: Zlib::DEFAULT_COMPRESSION, **options)
414
414
  super(**options)
@@ -446,7 +446,7 @@ module Protocol
446
446
  super(prefix + data) # Call Protocol::HTTP::Body::Writable#write
447
447
  end
448
448
 
449
- protected
449
+ protected
450
450
 
451
451
  def compress(data)
452
452
  case @encoding
@@ -574,7 +574,7 @@ module Protocol
574
574
  end
575
575
 
576
576
  # Get peer information (client address)
577
- # @returns [String, nil]
577
+ # @returns [String | Nil]
578
578
  def peer
579
579
  @request.peer&.to_s
580
580
  end
@@ -741,13 +741,13 @@ module Protocol
741
741
  end
742
742
 
743
743
  # Handle the RPC
744
- begin
745
- handle_rpc(request, handler, handler_method, request_class, response_class)
746
- rescue Error => error
747
- make_response(error.status_code, error.message, error: error)
748
- rescue => error
749
- make_response(Status::INTERNAL, error.message, error: error)
750
- end
744
+ begin
745
+ handle_rpc(request, handler, handler_method, request_class, response_class)
746
+ rescue Error => error
747
+ make_response(error.status_code, error.message, error: error)
748
+ rescue => error
749
+ make_response(Status::INTERNAL, error.message, error: error)
750
+ end
751
751
  end
752
752
 
753
753
  protected
@@ -764,33 +764,33 @@ module Protocol
764
764
  input = Body::Readable.new(request.body, message_class: request_class, encoding: encoding)
765
765
  output = Body::Writable.new(encoding: encoding)
766
766
 
767
- # Create call context
767
+ # Create call context
768
768
  response_headers = Protocol::HTTP::Headers.new([], nil, policy: HEADER_POLICY)
769
769
  response_headers["content-type"] = "application/grpc+proto"
770
770
  response_headers["grpc-encoding"] = encoding if encoding
771
771
 
772
772
  call = Call.new(request)
773
773
 
774
- # Invoke handler
774
+ # Invoke handler
775
775
  handler.send(method, input, output, call)
776
776
  output.close_write unless output.closed?
777
777
 
778
- # Mark trailers and add status
779
- response_headers.trailer!
780
- Metadata.add_status!(response_headers, status: Status::OK)
778
+ # Mark trailers and add status
779
+ response_headers.trailer!
780
+ Metadata.add_status!(response_headers, status: Status::OK)
781
+
782
+ Protocol::HTTP::Response[200, response_headers, output]
783
+ end
781
784
 
782
- Protocol::HTTP::Response[200, response_headers, output]
783
- end
784
-
785
785
  protected
786
-
787
- def make_response(status_code, message, error: nil)
788
- headers = Protocol::HTTP::Headers.new([], nil, policy: HEADER_POLICY)
789
- headers["content-type"] = "application/grpc+proto"
790
- Metadata.add_status!(headers, status: status_code, message: message, error: error)
791
786
 
792
- Protocol::HTTP::Response[200, headers, nil]
793
- end
787
+ def make_response(status_code, message, error: nil)
788
+ headers = Protocol::HTTP::Headers.new([], nil, policy: HEADER_POLICY)
789
+ headers["content-type"] = "application/grpc+proto"
790
+ Metadata.add_status!(headers, status: status_code, message: message, error: error)
791
+
792
+ Protocol::HTTP::Response[200, headers, nil]
793
+ end
794
794
  end
795
795
  end
796
796
  end
@@ -804,7 +804,7 @@ Standard health checking protocol:
804
804
  module Protocol
805
805
  module GRPC
806
806
  module HealthCheck
807
- # Health check status constants
807
+ # Health check status constants
808
808
  module ServingStatus
809
809
  UNKNOWN = 0
810
810
  SERVING = 1
@@ -888,10 +888,10 @@ require "protocol/grpc"
888
888
 
889
889
  # This would be inside a Rack/HTTP middleware/handler
890
890
  def handle_grpc_request(http_request)
891
- # Parse gRPC path
891
+ # Parse gRPC path
892
892
  service, method = Protocol::GRPC::Methods.parse_path(http_request.path)
893
893
 
894
- # Read input messages
894
+ # Read input messages
895
895
  input = Protocol::GRPC::Body::Readable.new(
896
896
  http_request.body,
897
897
  message_class: MyService::HelloRequest
@@ -899,26 +899,26 @@ def handle_grpc_request(http_request)
899
899
 
900
900
  request_message = input.read
901
901
 
902
- # Process the request
902
+ # Process the request
903
903
  reply = MyService::HelloReply.new(
904
904
  message: "Hello, #{request_message.name}!"
905
905
  )
906
906
 
907
- # Create response body
907
+ # Create response body
908
908
  output = Protocol::GRPC::Body::Writable.new
909
909
  output.write(reply)
910
910
  output.close_write
911
911
 
912
- # Build response headers with gRPC policy
912
+ # Build response headers with gRPC policy
913
913
  headers = Protocol::HTTP::Headers.new([], nil, policy: Protocol::GRPC::HEADER_POLICY)
914
914
  headers["content-type"] = "application/grpc+proto"
915
915
 
916
- # Mark that trailers will follow (after body)
916
+ # Mark that trailers will follow (after body)
917
917
  headers.trailer!
918
918
 
919
- # Add status as trailer - these will be sent after the response body
920
- # Note: The user just adds them to headers; the @tail marker ensures
921
- # they're recognized as trailers internally
919
+ # Add status as trailer - these will be sent after the response body
920
+ # Note: The user just adds them to headers; the @tail marker ensures
921
+ # they're recognized as trailers internally
922
922
  Protocol::GRPC::Metadata.add_status!(headers, status: Protocol::GRPC::Status::OK)
923
923
 
924
924
  Protocol::HTTP::Response[200, headers, output]
@@ -1091,20 +1091,20 @@ require "protocol/grpc"
1091
1091
  require_relative "my_service_pb" # Generated by protoc --ruby_out
1092
1092
 
1093
1093
  module MyService
1094
- # Client stub for Greeter service
1094
+ # Client stub for Greeter service
1095
1095
  class GreeterClient
1096
- # @parameter client [Async::GRPC::Client] The gRPC client
1096
+ # @parameter client [Async::GRPC::Client] The gRPC client
1097
1097
  def initialize(client)
1098
1098
  @client = client
1099
1099
  end
1100
1100
 
1101
1101
  SERVICE_PATH = "my_service.Greeter"
1102
1102
 
1103
- # Unary RPC: SayHello
1104
- # @parameter request [MyService::HelloRequest]
1105
- # @parameter metadata [Hash] Custom metadata
1106
- # @parameter timeout [Numeric] Deadline
1107
- # @returns [MyService::HelloReply]
1103
+ # Unary RPC: SayHello
1104
+ # @parameter request [MyService::HelloRequest]
1105
+ # @parameter metadata [Hash] Custom metadata
1106
+ # @parameter timeout [Numeric] Deadline
1107
+ # @returns [MyService::HelloReply]
1108
1108
  def say_hello(request, metadata: {}, timeout: nil)
1109
1109
  @client.unary(
1110
1110
  SERVICE_PATH,
@@ -1116,45 +1116,45 @@ module MyService
1116
1116
  )
1117
1117
  end
1118
1118
 
1119
- # Server streaming RPC: StreamNumbers
1120
- # @parameter request [MyService::HelloRequest]
1121
- # @yields {|response| ...} Each HelloReply message
1122
- # @returns [Enumerator<MyService::HelloReply>] if no block given
1119
+ # Server streaming RPC: StreamNumbers
1120
+ # @parameter request [MyService::HelloRequest]
1121
+ # @yields {|response| ...} Each HelloReply message
1122
+ # @returns [Enumerator<MyService::HelloReply>] if no block given
1123
1123
  def stream_numbers(request, metadata: {}, timeout: nil, &block)
1124
1124
  @client.server_streaming(
1125
1125
  SERVICE_PATH,
1126
1126
  "StreamNumbers",
1127
1127
  request,
1128
1128
  response_class: MyService::HelloReply,
1129
- metadata: metadata,
1130
- timeout: timeout,
1129
+ metadata: metadata,
1130
+ timeout: timeout,
1131
1131
  &block
1132
1132
  )
1133
1133
  end
1134
1134
 
1135
- # Client streaming RPC: RecordRoute
1136
- # @yields {|stream| ...} Block that writes Point messages
1137
- # @returns [MyService::RouteSummary]
1135
+ # Client streaming RPC: RecordRoute
1136
+ # @yields {|stream| ...} Block that writes Point messages
1137
+ # @returns [MyService::RouteSummary]
1138
1138
  def record_route(metadata: {}, timeout: nil, &block)
1139
1139
  @client.client_streaming(
1140
1140
  SERVICE_PATH,
1141
1141
  "RecordRoute",
1142
1142
  response_class: MyService::RouteSummary,
1143
- metadata: metadata,
1144
- timeout: timeout,
1143
+ metadata: metadata,
1144
+ timeout: timeout,
1145
1145
  &block
1146
1146
  )
1147
1147
  end
1148
1148
 
1149
- # Bidirectional streaming RPC: RouteChat
1150
- # @yields {|input, output| ...} input for writing, output for reading
1149
+ # Bidirectional streaming RPC: RouteChat
1150
+ # @yields {|input, output| ...} input for writing, output for reading
1151
1151
  def route_chat(metadata: {}, timeout: nil, &block)
1152
1152
  @client.bidirectional_streaming(
1153
1153
  SERVICE_PATH,
1154
1154
  "RouteChat",
1155
1155
  response_class: MyService::Point,
1156
- metadata: metadata,
1157
- timeout: timeout,
1156
+ metadata: metadata,
1157
+ timeout: timeout,
1158
1158
  &block
1159
1159
  )
1160
1160
  end
@@ -1172,76 +1172,76 @@ require "protocol/grpc"
1172
1172
  require_relative "my_service_pb" # Generated by protoc --ruby_out
1173
1173
 
1174
1174
  module MyService
1175
- # Base class for Greeter service implementation
1176
- # Inherit from this class and implement the RPC methods
1175
+ # Base class for Greeter service implementation
1176
+ # Inherit from this class and implement the RPC methods
1177
1177
  class GreeterService
1178
- # Unary RPC: SayHello
1179
- # Override this method in your implementation
1180
- # @parameter request [MyService::HelloRequest]
1181
- # @parameter call [Protocol::GRPC::ServerCall] Call context with metadata
1182
- # @returns [MyService::HelloReply]
1178
+ # Unary RPC: SayHello
1179
+ # Override this method in your implementation
1180
+ # @parameter request [MyService::HelloRequest]
1181
+ # @parameter call [Protocol::GRPC::ServerCall] Call context with metadata
1182
+ # @returns [MyService::HelloReply]
1183
1183
  def say_hello(request, call)
1184
1184
  raise NotImplementedError, "#{self.class}#say_hello not implemented"
1185
1185
  end
1186
1186
 
1187
- # Server streaming RPC: StreamNumbers
1188
- # Override this method in your implementation
1189
- # @parameter request [MyService::HelloRequest]
1190
- # @parameter call [Protocol::GRPC::ServerCall] Call context with metadata
1191
- # @yields [MyService::HelloReply] Yield each response message
1187
+ # Server streaming RPC: StreamNumbers
1188
+ # Override this method in your implementation
1189
+ # @parameter request [MyService::HelloRequest]
1190
+ # @parameter call [Protocol::GRPC::ServerCall] Call context with metadata
1191
+ # @yields [MyService::HelloReply] Yield each response message
1192
1192
  def stream_numbers(request, call)
1193
1193
  raise NotImplementedError, "#{self.class}#stream_numbers not implemented"
1194
1194
  end
1195
1195
 
1196
- # Client streaming RPC: RecordRoute
1197
- # Override this method in your implementation
1198
- # @parameter call [Protocol::GRPC::ServerCall] Call context with metadata
1199
- # @yields [MyService::Point] Each request message from client
1200
- # @returns [MyService::RouteSummary]
1196
+ # Client streaming RPC: RecordRoute
1197
+ # Override this method in your implementation
1198
+ # @parameter call [Protocol::GRPC::ServerCall] Call context with metadata
1199
+ # @yields [MyService::Point] Each request message from client
1200
+ # @returns [MyService::RouteSummary]
1201
1201
  def record_route(call)
1202
1202
  raise NotImplementedError, "#{self.class}#record_route not implemented"
1203
1203
  end
1204
1204
 
1205
- # Bidirectional streaming RPC: RouteChat
1206
- # Override this method in your implementation
1207
- # @parameter call [Protocol::GRPC::ServerCall] Call context with metadata
1208
- # @returns [Enumerator, Enumerator] (input, output) - input for reading, output for writing
1205
+ # Bidirectional streaming RPC: RouteChat
1206
+ # Override this method in your implementation
1207
+ # @parameter call [Protocol::GRPC::ServerCall] Call context with metadata
1208
+ # @returns [Enumerator, Enumerator] (input, output) - input for reading, output for writing
1209
1209
  def route_chat(call)
1210
1210
  raise NotImplementedError, "#{self.class}#route_chat not implemented"
1211
1211
  end
1212
1212
 
1213
- # Internal: Dispatch method for Async::GRPC::Server
1214
- # Maps RPC calls to handler methods
1213
+ # Internal: Dispatch method for Async::GRPC::Server
1214
+ # Maps RPC calls to handler methods
1215
1215
  def self.rpc_descriptions
1216
1216
  {
1217
1217
  "SayHello" => {
1218
1218
  method: :say_hello,
1219
- request_class: MyService::HelloRequest,
1220
- response_class: MyService::HelloReply,
1221
- request_streaming: false,
1222
- response_streaming: false
1219
+ request_class: MyService::HelloRequest,
1220
+ response_class: MyService::HelloReply,
1221
+ request_streaming: false,
1222
+ response_streaming: false
1223
+ },
1224
+ "StreamNumbers" => {
1225
+ method: :stream_numbers,
1226
+ request_class: MyService::HelloRequest,
1227
+ response_class: MyService::HelloReply,
1228
+ request_streaming: false,
1229
+ response_streaming: true
1230
+ },
1231
+ "RecordRoute" => {
1232
+ method: :record_route,
1233
+ request_class: MyService::Point,
1234
+ response_class: MyService::RouteSummary,
1235
+ request_streaming: true,
1236
+ response_streaming: false
1223
1237
  },
1224
- "StreamNumbers" => {
1225
- method: :stream_numbers,
1226
- request_class: MyService::HelloRequest,
1227
- response_class: MyService::HelloReply,
1228
- request_streaming: false,
1229
- response_streaming: true
1230
- },
1231
- "RecordRoute" => {
1232
- method: :record_route,
1233
- request_class: MyService::Point,
1234
- response_class: MyService::RouteSummary,
1235
- request_streaming: true,
1236
- response_streaming: false
1237
- },
1238
- "RouteChat" => {
1239
- method: :route_chat,
1240
- request_class: MyService::Point,
1241
- response_class: MyService::Point,
1242
- request_streaming: true,
1243
- response_streaming: true
1244
- }
1238
+ "RouteChat" => {
1239
+ method: :route_chat,
1240
+ request_class: MyService::Point,
1241
+ response_class: MyService::Point,
1242
+ request_streaming: true,
1243
+ response_streaming: true
1244
+ }
1245
1245
  }
1246
1246
  end
1247
1247
  end
@@ -1261,12 +1261,12 @@ Async do
1261
1261
  client = Async::GRPC::Client.new(endpoint)
1262
1262
  stub = MyService::GreeterClient.new(client)
1263
1263
 
1264
- # Clean, typed interface!
1264
+ # Clean, typed interface!
1265
1265
  request = MyService::HelloRequest.new(name: "World")
1266
1266
  response = stub.say_hello(request)
1267
1267
  puts response.message
1268
1268
 
1269
- # Server streaming
1269
+ # Server streaming
1270
1270
  stub.stream_numbers(request) do |reply|
1271
1271
  puts reply.message
1272
1272
  end
@@ -1315,7 +1315,7 @@ Async do
1315
1315
  server = Async::GRPC::Server.new
1316
1316
  server.register("my_service.Greeter", MyGreeter.new)
1317
1317
 
1318
- # ... start server
1318
+ # ... start server
1319
1319
  end
1320
1320
  ```
1321
1321
 
@@ -1332,27 +1332,27 @@ Key classes:
1332
1332
  module Protocol
1333
1333
  module GRPC
1334
1334
  class Generator
1335
- # @parameter proto_file [String] Path to .proto file
1335
+ # @parameter proto_file [String] Path to .proto file
1336
1336
  def initialize(proto_file)
1337
1337
  @proto = parse_proto(proto_file)
1338
1338
  end
1339
1339
 
1340
1340
  def generate_client(output_path)
1341
- # Generate client stub
1341
+ # Generate client stub
1342
1342
  end
1343
1343
 
1344
1344
  def generate_server(output_path)
1345
- # Generate server base class
1345
+ # Generate server base class
1346
1346
  end
1347
1347
 
1348
- private
1348
+ private
1349
1349
 
1350
1350
  def parse_proto(file)
1351
- # Simple parsing - extract:
1352
- # - package name
1353
- # - message names (just reference them, protoc generates these)
1354
- # - service definitions
1355
- # - RPC methods with request/response types and streaming flags
1351
+ # Simple parsing - extract:
1352
+ # - package name
1353
+ # - message names (just reference them, protoc generates these)
1354
+ # - service definitions
1355
+ # - RPC methods with request/response types and streaming flags
1356
1356
  end
1357
1357
  end
1358
1358
  end
@@ -1392,8 +1392,8 @@ module Bake
1392
1392
  Console.logger.info(self){"Generated #{output_path}"}
1393
1393
  end
1394
1394
 
1395
- # Generate gRPC stubs for all .proto files in directory
1396
- # @parameter directory [String] Directory containing .proto files
1395
+ # Generate gRPC stubs for all .proto files in directory
1396
+ # @parameter directory [String] Directory containing .proto files
1397
1397
  def generate_all(directory: ".")
1398
1398
  Dir.glob(File.join(directory, "**/*.proto")).each do |proto_file|
1399
1399
  generate(proto_file)