grpc 0.14.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1398 -817
  3. data/include/grpc/compression.h +2 -1
  4. data/include/grpc/grpc.h +10 -1
  5. data/include/grpc/grpc_cronet.h +51 -0
  6. data/include/grpc/grpc_posix.h +70 -0
  7. data/include/grpc/impl/codegen/atm.h +2 -2
  8. data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
  9. data/include/grpc/impl/codegen/compression_types.h +39 -5
  10. data/include/grpc/impl/codegen/connectivity_state.h +1 -1
  11. data/include/grpc/impl/codegen/grpc_types.h +10 -0
  12. data/include/grpc/impl/codegen/log.h +2 -1
  13. data/include/grpc/impl/codegen/port_platform.h +30 -12
  14. data/include/grpc/impl/codegen/slice_buffer.h +2 -3
  15. data/include/grpc/impl/codegen/sync.h +2 -2
  16. data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
  17. data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
  18. data/include/grpc/support/avl.h +5 -0
  19. data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
  20. data/include/grpc/support/string_util.h +2 -1
  21. data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
  22. data/src/core/ext/census/gen/census.pb.c +179 -0
  23. data/src/core/ext/census/gen/census.pb.h +294 -0
  24. data/src/core/ext/census/grpc_filter.c +11 -7
  25. data/src/core/ext/client_config/channel_connectivity.c +28 -14
  26. data/src/core/ext/client_config/client_channel.c +77 -53
  27. data/src/core/ext/client_config/connector.h +1 -1
  28. data/src/core/ext/client_config/lb_policy.c +9 -6
  29. data/src/core/ext/client_config/lb_policy.h +9 -5
  30. data/src/core/ext/client_config/subchannel.c +58 -39
  31. data/src/core/ext/client_config/subchannel.h +3 -2
  32. data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
  33. data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
  34. data/src/core/ext/client_config/subchannel_index.c +20 -9
  35. data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
  36. data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
  37. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
  38. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
  39. data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
  40. data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
  41. data/src/core/ext/load_reporting/load_reporting.c +133 -0
  42. data/src/core/ext/load_reporting/load_reporting.h +75 -0
  43. data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
  44. data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
  45. data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
  46. data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
  47. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
  48. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
  49. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
  50. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
  51. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
  52. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
  53. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
  54. data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
  55. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
  56. data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
  57. data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
  58. data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
  59. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
  60. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
  61. data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
  62. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
  63. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
  64. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
  65. data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
  66. data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
  67. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
  68. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
  69. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
  70. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
  71. data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
  72. data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
  73. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
  74. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
  75. data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
  76. data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
  77. data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
  78. data/src/core/lib/channel/channel_args.c +26 -12
  79. data/src/core/lib/channel/channel_args.h +1 -1
  80. data/src/core/lib/channel/channel_stack.c +12 -8
  81. data/src/core/lib/channel/channel_stack.h +27 -11
  82. data/src/core/lib/channel/channel_stack_builder.c +2 -2
  83. data/src/core/lib/channel/compress_filter.c +26 -31
  84. data/src/core/lib/channel/compress_filter.h +4 -4
  85. data/src/core/lib/channel/connected_channel.c +7 -5
  86. data/src/core/lib/channel/http_client_filter.c +34 -8
  87. data/src/core/lib/channel/http_client_filter.h +1 -1
  88. data/src/core/lib/channel/http_server_filter.c +21 -12
  89. data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
  90. data/src/core/lib/http/httpcli.c +81 -59
  91. data/src/core/lib/http/httpcli.h +11 -15
  92. data/src/core/lib/http/httpcli_security_connector.c +5 -3
  93. data/src/core/lib/http/parser.c +127 -118
  94. data/src/core/lib/http/parser.h +11 -6
  95. data/src/core/lib/iomgr/closure.c +20 -16
  96. data/src/core/lib/iomgr/closure.h +19 -15
  97. data/src/core/lib/iomgr/endpoint.h +1 -1
  98. data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
  99. data/src/core/lib/iomgr/error.c +535 -0
  100. data/src/core/lib/iomgr/error.h +192 -0
  101. data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
  102. data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
  103. data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
  104. data/src/core/lib/iomgr/ev_posix.c +104 -14
  105. data/src/core/lib/iomgr/ev_posix.h +17 -7
  106. data/src/core/lib/iomgr/exec_ctx.c +25 -7
  107. data/src/core/lib/iomgr/exec_ctx.h +27 -8
  108. data/src/core/lib/iomgr/executor.c +2 -2
  109. data/src/core/lib/iomgr/executor.h +1 -1
  110. data/src/core/lib/iomgr/iocp_windows.c +2 -41
  111. data/src/core/lib/iomgr/iocp_windows.h +0 -8
  112. data/src/core/lib/iomgr/iomgr.c +5 -4
  113. data/src/core/lib/iomgr/iomgr_posix.c +5 -1
  114. data/src/core/lib/iomgr/iomgr_windows.c +1 -1
  115. data/src/core/lib/{support → iomgr}/load_file.c +15 -17
  116. data/src/core/lib/{support → iomgr}/load_file.h +8 -7
  117. data/src/core/lib/iomgr/polling_entity.c +104 -0
  118. data/src/core/lib/iomgr/polling_entity.h +81 -0
  119. data/src/core/lib/iomgr/pollset.h +6 -5
  120. data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
  121. data/src/core/lib/iomgr/pollset_windows.c +10 -6
  122. data/src/core/lib/iomgr/resolve_address.h +5 -9
  123. data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
  124. data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
  125. data/src/core/lib/iomgr/sockaddr.h +2 -2
  126. data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
  127. data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
  128. data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
  129. data/src/core/lib/iomgr/socket_windows.c +61 -2
  130. data/src/core/lib/iomgr/socket_windows.h +13 -0
  131. data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
  132. data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
  133. data/src/core/lib/iomgr/tcp_posix.c +43 -39
  134. data/src/core/lib/iomgr/tcp_server.h +5 -3
  135. data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
  136. data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
  137. data/src/core/lib/iomgr/tcp_windows.c +45 -50
  138. data/src/core/lib/iomgr/tcp_windows.h +1 -1
  139. data/src/core/lib/iomgr/timer.c +26 -13
  140. data/src/core/lib/iomgr/udp_server.c +28 -4
  141. data/src/core/lib/iomgr/udp_server.h +5 -1
  142. data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
  143. data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
  144. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
  145. data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
  146. data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
  147. data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
  148. data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
  149. data/src/core/lib/iomgr/workqueue.h +5 -4
  150. data/src/core/lib/iomgr/workqueue_posix.c +40 -26
  151. data/src/core/lib/iomgr/workqueue_windows.c +2 -2
  152. data/src/core/lib/profiling/basic_timers.c +2 -2
  153. data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
  154. data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
  155. data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
  156. data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
  157. data/src/core/lib/security/credentials/credentials.c +233 -0
  158. data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
  159. data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
  160. data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
  161. data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
  162. data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
  163. data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
  164. data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
  165. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
  166. data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
  167. data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
  168. data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
  169. data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
  170. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
  171. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
  172. data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
  173. data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
  174. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
  175. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
  176. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
  177. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
  178. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
  179. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
  180. data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
  181. data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
  182. data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
  183. data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
  184. data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
  185. data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
  186. data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
  187. data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
  188. data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
  189. data/src/core/lib/security/transport/tsi_error.c +40 -0
  190. data/src/core/lib/security/transport/tsi_error.h +42 -0
  191. data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
  192. data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
  193. data/src/core/lib/security/util/json_util.c +61 -0
  194. data/src/core/lib/security/util/json_util.h +55 -0
  195. data/src/core/lib/support/avl.c +11 -0
  196. data/src/core/lib/support/cpu_windows.c +2 -2
  197. data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
  198. data/src/core/lib/support/log.c +3 -1
  199. data/src/core/lib/support/log_linux.c +2 -2
  200. data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
  201. data/src/core/lib/support/murmur_hash.c +3 -5
  202. data/src/core/lib/support/string.c +10 -0
  203. data/src/core/lib/support/string.h +4 -0
  204. data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
  205. data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
  206. data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
  207. data/src/core/lib/support/subprocess_windows.c +1 -1
  208. data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
  209. data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
  210. data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
  211. data/src/core/lib/support/tmpfile_msys.c +1 -1
  212. data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
  213. data/src/core/lib/surface/alarm.c +2 -2
  214. data/src/core/lib/surface/byte_buffer_reader.c +13 -6
  215. data/src/core/lib/surface/call.c +323 -123
  216. data/src/core/lib/surface/call.h +2 -0
  217. data/src/core/lib/surface/call_log_batch.c +1 -1
  218. data/src/core/lib/surface/channel.c +64 -15
  219. data/src/core/lib/surface/channel.h +9 -0
  220. data/src/core/lib/surface/channel_ping.c +3 -3
  221. data/src/core/lib/surface/completion_queue.c +75 -19
  222. data/src/core/lib/surface/completion_queue.h +7 -2
  223. data/src/core/lib/surface/init.c +2 -1
  224. data/src/core/lib/surface/init_secure.c +4 -4
  225. data/src/core/lib/surface/lame_client.c +12 -8
  226. data/src/core/lib/surface/server.c +213 -120
  227. data/src/core/lib/surface/server.h +1 -0
  228. data/src/core/lib/surface/version.c +1 -1
  229. data/src/core/lib/transport/connectivity_state.c +40 -18
  230. data/src/core/lib/transport/connectivity_state.h +4 -1
  231. data/src/core/lib/transport/metadata.c +23 -23
  232. data/src/core/lib/transport/metadata.h +4 -0
  233. data/src/core/lib/transport/metadata_batch.c +9 -0
  234. data/src/core/lib/transport/metadata_batch.h +3 -0
  235. data/src/core/lib/transport/static_metadata.c +6 -5
  236. data/src/core/lib/transport/static_metadata.h +64 -60
  237. data/src/core/lib/transport/transport.c +24 -12
  238. data/src/core/lib/transport/transport.h +6 -5
  239. data/src/core/lib/transport/transport_impl.h +4 -0
  240. data/src/core/lib/transport/transport_op_string.c +2 -2
  241. data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
  242. data/src/ruby/bin/math_services.rb +41 -2
  243. data/src/ruby/ext/grpc/rb_call.c +42 -40
  244. data/src/ruby/ext/grpc/rb_channel.c +1 -1
  245. data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
  246. data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
  247. data/src/ruby/ext/grpc/rb_grpc.c +1 -3
  248. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
  249. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
  250. data/src/ruby/ext/grpc/rb_loader.c +1 -1
  251. data/src/ruby/ext/grpc/rb_server.c +5 -3
  252. data/src/ruby/lib/grpc.rb +0 -3
  253. data/src/ruby/lib/grpc/errors.rb +3 -2
  254. data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
  255. data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
  256. data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
  257. data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
  258. data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
  259. data/src/ruby/lib/grpc/generic/service.rb +8 -8
  260. data/src/ruby/lib/grpc/version.rb +1 -1
  261. data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
  262. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
  263. data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
  264. data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
  265. data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
  266. data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
  267. data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
  268. data/src/ruby/pb/test/client.rb +5 -2
  269. data/src/ruby/spec/generic/active_call_spec.rb +3 -2
  270. data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
  271. data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
  272. data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
  273. data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
  274. metadata +86 -48
  275. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
  276. data/src/core/lib/security/credentials.c +0 -1296
  277. data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -35,6 +35,7 @@
35
35
  #define GRPC_CORE_EXT_CLIENT_CONFIG_SUBCHANNEL_CALL_HOLDER_H
36
36
 
37
37
  #include "src/core/ext/client_config/subchannel.h"
38
+ #include "src/core/lib/iomgr/polling_entity.h"
38
39
 
39
40
  /** Pick a subchannel for grpc_subchannel_call_holder;
40
41
  Return 1 if subchannel is available immediately (in which case on_ready
@@ -71,7 +72,7 @@ typedef struct grpc_subchannel_call_holder {
71
72
 
72
73
  grpc_subchannel_call_holder_creation_phase creation_phase;
73
74
  grpc_connected_subchannel *connected_subchannel;
74
- grpc_pollset *pollset;
75
+ grpc_polling_entity *pollent;
75
76
 
76
77
  grpc_transport_stream_op *waiting_ops;
77
78
  size_t waiting_ops_count;
@@ -77,12 +77,19 @@ static grpc_subchannel_key *create_key(
77
77
  grpc_subchannel_key *k = gpr_malloc(sizeof(*k));
78
78
  k->connector = grpc_connector_ref(connector);
79
79
  k->args.filter_count = args->filter_count;
80
- k->args.filters = gpr_malloc(sizeof(*k->args.filters) * k->args.filter_count);
81
- memcpy((grpc_channel_filter *)k->args.filters, args->filters,
82
- sizeof(*k->args.filters) * k->args.filter_count);
80
+ if (k->args.filter_count > 0) {
81
+ k->args.filters =
82
+ gpr_malloc(sizeof(*k->args.filters) * k->args.filter_count);
83
+ memcpy((grpc_channel_filter *)k->args.filters, args->filters,
84
+ sizeof(*k->args.filters) * k->args.filter_count);
85
+ } else {
86
+ k->args.filters = NULL;
87
+ }
83
88
  k->args.addr_len = args->addr_len;
84
89
  k->args.addr = gpr_malloc(args->addr_len);
85
- memcpy(k->args.addr, args->addr, k->args.addr_len);
90
+ if (k->args.addr_len > 0) {
91
+ memcpy(k->args.addr, args->addr, k->args.addr_len);
92
+ }
86
93
  k->args.args = copy_channel_args(args->args);
87
94
  return k;
88
95
  }
@@ -104,11 +111,15 @@ static int subchannel_key_compare(grpc_subchannel_key *a,
104
111
  if (c != 0) return c;
105
112
  c = GPR_ICMP(a->args.filter_count, b->args.filter_count);
106
113
  if (c != 0) return c;
107
- c = memcmp(a->args.addr, b->args.addr, a->args.addr_len);
108
- if (c != 0) return c;
109
- c = memcmp(a->args.filters, b->args.filters,
110
- a->args.filter_count * sizeof(*a->args.filters));
111
- if (c != 0) return c;
114
+ if (a->args.addr_len) {
115
+ c = memcmp(a->args.addr, b->args.addr, a->args.addr_len);
116
+ if (c != 0) return c;
117
+ }
118
+ if (a->args.filter_count > 0) {
119
+ c = memcmp(a->args.filters, b->args.filters,
120
+ a->args.filter_count * sizeof(*a->args.filters));
121
+ if (c != 0) return c;
122
+ }
112
123
  return grpc_channel_args_compare(a->args.args, b->args.args);
113
124
  }
114
125
 
@@ -50,7 +50,7 @@ static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field,
50
50
  decode_serverlist_arg *dec_arg = *arg;
51
51
  if (dec_arg->first_pass != 0) { /* first pass */
52
52
  grpc_grpclb_server server;
53
- if (!pb_decode(stream, grpc_lb_v0_Server_fields, &server)) {
53
+ if (!pb_decode(stream, grpc_lb_v1_Server_fields, &server)) {
54
54
  return false;
55
55
  }
56
56
  dec_arg->num_servers++;
@@ -61,7 +61,7 @@ static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field,
61
61
  dec_arg->servers =
62
62
  gpr_malloc(sizeof(grpc_grpclb_server *) * dec_arg->num_servers);
63
63
  }
64
- if (!pb_decode(stream, grpc_lb_v0_Server_fields, server)) {
64
+ if (!pb_decode(stream, grpc_lb_v1_Server_fields, server)) {
65
65
  return false;
66
66
  }
67
67
  dec_arg->servers[dec_arg->i++] = server;
@@ -87,13 +87,13 @@ gpr_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) {
87
87
  pb_ostream_t outputstream;
88
88
  gpr_slice slice;
89
89
  memset(&sizestream, 0, sizeof(pb_ostream_t));
90
- pb_encode(&sizestream, grpc_lb_v0_LoadBalanceRequest_fields, request);
90
+ pb_encode(&sizestream, grpc_lb_v1_LoadBalanceRequest_fields, request);
91
91
  encoded_length = sizestream.bytes_written;
92
92
 
93
93
  slice = gpr_slice_malloc(encoded_length);
94
94
  outputstream =
95
95
  pb_ostream_from_buffer(GPR_SLICE_START_PTR(slice), encoded_length);
96
- GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v0_LoadBalanceRequest_fields,
96
+ GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v1_LoadBalanceRequest_fields,
97
97
  request) != 0);
98
98
  return slice;
99
99
  }
@@ -109,7 +109,7 @@ grpc_grpclb_response *grpc_grpclb_response_parse(gpr_slice encoded_response) {
109
109
  GPR_SLICE_LENGTH(encoded_response));
110
110
  grpc_grpclb_response *res = gpr_malloc(sizeof(grpc_grpclb_response));
111
111
  memset(res, 0, sizeof(*res));
112
- status = pb_decode(&stream, grpc_lb_v0_LoadBalanceResponse_fields, res);
112
+ status = pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, res);
113
113
  if (!status) {
114
114
  grpc_grpclb_response_destroy(res);
115
115
  return NULL;
@@ -132,7 +132,7 @@ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
132
132
  res->server_list.servers.funcs.decode = decode_serverlist;
133
133
  res->server_list.servers.arg = &arg;
134
134
  arg.first_pass = 1;
135
- status = pb_decode(&stream, grpc_lb_v0_LoadBalanceResponse_fields, res);
135
+ status = pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, res);
136
136
  if (!status) {
137
137
  grpc_grpclb_response_destroy(res);
138
138
  return NULL;
@@ -140,7 +140,7 @@ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
140
140
 
141
141
  arg.first_pass = 0;
142
142
  status =
143
- pb_decode(&stream_at_start, grpc_lb_v0_LoadBalanceResponse_fields, res);
143
+ pb_decode(&stream_at_start, grpc_lb_v1_LoadBalanceResponse_fields, res);
144
144
  if (!status) {
145
145
  grpc_grpclb_response_destroy(res);
146
146
  return NULL;
@@ -37,7 +37,7 @@
37
37
  #include <grpc/support/slice_buffer.h>
38
38
 
39
39
  #include "src/core/ext/client_config/lb_policy_factory.h"
40
- #include "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h"
40
+ #include "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h"
41
41
 
42
42
  #ifdef __cplusplus
43
43
  extern "C" {
@@ -45,10 +45,10 @@ extern "C" {
45
45
 
46
46
  #define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128
47
47
 
48
- typedef grpc_lb_v0_LoadBalanceRequest grpc_grpclb_request;
49
- typedef grpc_lb_v0_LoadBalanceResponse grpc_grpclb_response;
50
- typedef grpc_lb_v0_Server grpc_grpclb_server;
51
- typedef grpc_lb_v0_Duration grpc_grpclb_duration;
48
+ typedef grpc_lb_v1_LoadBalanceRequest grpc_grpclb_request;
49
+ typedef grpc_lb_v1_LoadBalanceResponse grpc_grpclb_response;
50
+ typedef grpc_lb_v1_Server grpc_grpclb_server;
51
+ typedef grpc_lb_v1_Duration grpc_grpclb_duration;
52
52
  typedef struct grpc_grpclb_serverlist {
53
53
  grpc_grpclb_server **servers;
54
54
  size_t num_servers;
@@ -33,7 +33,7 @@
33
33
  /* Automatically generated nanopb constant definitions */
34
34
  /* Generated by nanopb-0.3.5-dev */
35
35
 
36
- #include "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h"
36
+ #include "src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h"
37
37
 
38
38
  #if PB_PROTO_HEADER_VERSION != 30
39
39
  #error Regenerate this file with the current version of nanopb generator.
@@ -41,54 +41,53 @@
41
41
 
42
42
 
43
43
 
44
- const pb_field_t grpc_lb_v0_Duration_fields[3] = {
45
- PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, grpc_lb_v0_Duration, seconds, seconds, 0),
46
- PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, grpc_lb_v0_Duration, nanos, seconds, 0),
44
+ const pb_field_t grpc_lb_v1_Duration_fields[3] = {
45
+ PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, grpc_lb_v1_Duration, seconds, seconds, 0),
46
+ PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_Duration, nanos, seconds, 0),
47
47
  PB_LAST_FIELD
48
48
  };
49
49
 
50
- const pb_field_t grpc_lb_v0_LoadBalanceRequest_fields[3] = {
51
- PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_lb_v0_LoadBalanceRequest, initial_request, initial_request, &grpc_lb_v0_InitialLoadBalanceRequest_fields),
52
- PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v0_LoadBalanceRequest, client_stats, initial_request, &grpc_lb_v0_ClientStats_fields),
50
+ const pb_field_t grpc_lb_v1_LoadBalanceRequest_fields[3] = {
51
+ PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_lb_v1_LoadBalanceRequest, initial_request, initial_request, &grpc_lb_v1_InitialLoadBalanceRequest_fields),
52
+ PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v1_LoadBalanceRequest, client_stats, initial_request, &grpc_lb_v1_ClientStats_fields),
53
53
  PB_LAST_FIELD
54
54
  };
55
55
 
56
- const pb_field_t grpc_lb_v0_InitialLoadBalanceRequest_fields[2] = {
57
- PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v0_InitialLoadBalanceRequest, name, name, 0),
56
+ const pb_field_t grpc_lb_v1_InitialLoadBalanceRequest_fields[2] = {
57
+ PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v1_InitialLoadBalanceRequest, name, name, 0),
58
58
  PB_LAST_FIELD
59
59
  };
60
60
 
61
- const pb_field_t grpc_lb_v0_ClientStats_fields[4] = {
62
- PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, grpc_lb_v0_ClientStats, total_requests, total_requests, 0),
63
- PB_FIELD( 2, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v0_ClientStats, client_rpc_errors, total_requests, 0),
64
- PB_FIELD( 3, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v0_ClientStats, dropped_requests, client_rpc_errors, 0),
61
+ const pb_field_t grpc_lb_v1_ClientStats_fields[4] = {
62
+ PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, grpc_lb_v1_ClientStats, total_requests, total_requests, 0),
63
+ PB_FIELD( 2, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ClientStats, client_rpc_errors, total_requests, 0),
64
+ PB_FIELD( 3, INT64 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ClientStats, dropped_requests, client_rpc_errors, 0),
65
65
  PB_LAST_FIELD
66
66
  };
67
67
 
68
- const pb_field_t grpc_lb_v0_LoadBalanceResponse_fields[3] = {
69
- PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_lb_v0_LoadBalanceResponse, initial_response, initial_response, &grpc_lb_v0_InitialLoadBalanceResponse_fields),
70
- PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v0_LoadBalanceResponse, server_list, initial_response, &grpc_lb_v0_ServerList_fields),
68
+ const pb_field_t grpc_lb_v1_LoadBalanceResponse_fields[3] = {
69
+ PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, grpc_lb_v1_LoadBalanceResponse, initial_response, initial_response, &grpc_lb_v1_InitialLoadBalanceResponse_fields),
70
+ PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v1_LoadBalanceResponse, server_list, initial_response, &grpc_lb_v1_ServerList_fields),
71
71
  PB_LAST_FIELD
72
72
  };
73
73
 
74
- const pb_field_t grpc_lb_v0_InitialLoadBalanceResponse_fields[4] = {
75
- PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v0_InitialLoadBalanceResponse, client_config, client_config, 0),
76
- PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, grpc_lb_v0_InitialLoadBalanceResponse, load_balancer_delegate, client_config, 0),
77
- PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v0_InitialLoadBalanceResponse, client_stats_report_interval, load_balancer_delegate, &grpc_lb_v0_Duration_fields),
74
+ const pb_field_t grpc_lb_v1_InitialLoadBalanceResponse_fields[3] = {
75
+ PB_FIELD( 2, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v1_InitialLoadBalanceResponse, load_balancer_delegate, load_balancer_delegate, 0),
76
+ PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval, load_balancer_delegate, &grpc_lb_v1_Duration_fields),
78
77
  PB_LAST_FIELD
79
78
  };
80
79
 
81
- const pb_field_t grpc_lb_v0_ServerList_fields[3] = {
82
- PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, grpc_lb_v0_ServerList, servers, servers, &grpc_lb_v0_Server_fields),
83
- PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v0_ServerList, expiration_interval, servers, &grpc_lb_v0_Duration_fields),
80
+ const pb_field_t grpc_lb_v1_ServerList_fields[3] = {
81
+ PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, grpc_lb_v1_ServerList, servers, servers, &grpc_lb_v1_Server_fields),
82
+ PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, grpc_lb_v1_ServerList, expiration_interval, servers, &grpc_lb_v1_Duration_fields),
84
83
  PB_LAST_FIELD
85
84
  };
86
85
 
87
- const pb_field_t grpc_lb_v0_Server_fields[5] = {
88
- PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v0_Server, ip_address, ip_address, 0),
89
- PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, grpc_lb_v0_Server, port, ip_address, 0),
90
- PB_FIELD( 3, BYTES , OPTIONAL, STATIC , OTHER, grpc_lb_v0_Server, load_balance_token, port, 0),
91
- PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, grpc_lb_v0_Server, drop_request, load_balance_token, 0),
86
+ const pb_field_t grpc_lb_v1_Server_fields[5] = {
87
+ PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_lb_v1_Server, ip_address, ip_address, 0),
88
+ PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, grpc_lb_v1_Server, port, ip_address, 0),
89
+ PB_FIELD( 3, STRING , OPTIONAL, STATIC , OTHER, grpc_lb_v1_Server, load_balance_token, port, 0),
90
+ PB_FIELD( 4, BOOL , OPTIONAL, STATIC , OTHER, grpc_lb_v1_Server, drop_request, load_balance_token, 0),
92
91
  PB_LAST_FIELD
93
92
  };
94
93
 
@@ -102,7 +101,7 @@ const pb_field_t grpc_lb_v0_Server_fields[5] = {
102
101
  * numbers or field sizes that are larger than what can fit in 8 or 16 bit
103
102
  * field descriptors.
104
103
  */
105
- PB_STATIC_ASSERT((pb_membersize(grpc_lb_v0_LoadBalanceRequest, initial_request) < 65536 && pb_membersize(grpc_lb_v0_LoadBalanceRequest, client_stats) < 65536 && pb_membersize(grpc_lb_v0_LoadBalanceResponse, initial_response) < 65536 && pb_membersize(grpc_lb_v0_LoadBalanceResponse, server_list) < 65536 && pb_membersize(grpc_lb_v0_InitialLoadBalanceResponse, client_stats_report_interval) < 65536 && pb_membersize(grpc_lb_v0_ServerList, servers) < 65536 && pb_membersize(grpc_lb_v0_ServerList, expiration_interval) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v0_Duration_grpc_lb_v0_LoadBalanceRequest_grpc_lb_v0_InitialLoadBalanceRequest_grpc_lb_v0_ClientStats_grpc_lb_v0_LoadBalanceResponse_grpc_lb_v0_InitialLoadBalanceResponse_grpc_lb_v0_ServerList_grpc_lb_v0_Server)
104
+ PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 65536 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 65536 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 65536 && pb_membersize(grpc_lb_v1_ServerList, servers) < 65536 && pb_membersize(grpc_lb_v1_ServerList, expiration_interval) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server)
106
105
  #endif
107
106
 
108
107
  #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
@@ -113,7 +112,7 @@ PB_STATIC_ASSERT((pb_membersize(grpc_lb_v0_LoadBalanceRequest, initial_request)
113
112
  * numbers or field sizes that are larger than what can fit in the default
114
113
  * 8 bit descriptors.
115
114
  */
116
- PB_STATIC_ASSERT((pb_membersize(grpc_lb_v0_LoadBalanceRequest, initial_request) < 256 && pb_membersize(grpc_lb_v0_LoadBalanceRequest, client_stats) < 256 && pb_membersize(grpc_lb_v0_LoadBalanceResponse, initial_response) < 256 && pb_membersize(grpc_lb_v0_LoadBalanceResponse, server_list) < 256 && pb_membersize(grpc_lb_v0_InitialLoadBalanceResponse, client_stats_report_interval) < 256 && pb_membersize(grpc_lb_v0_ServerList, servers) < 256 && pb_membersize(grpc_lb_v0_ServerList, expiration_interval) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v0_Duration_grpc_lb_v0_LoadBalanceRequest_grpc_lb_v0_InitialLoadBalanceRequest_grpc_lb_v0_ClientStats_grpc_lb_v0_LoadBalanceResponse_grpc_lb_v0_InitialLoadBalanceResponse_grpc_lb_v0_ServerList_grpc_lb_v0_Server)
115
+ PB_STATIC_ASSERT((pb_membersize(grpc_lb_v1_LoadBalanceRequest, initial_request) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceRequest, client_stats) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, initial_response) < 256 && pb_membersize(grpc_lb_v1_LoadBalanceResponse, server_list) < 256 && pb_membersize(grpc_lb_v1_InitialLoadBalanceResponse, client_stats_report_interval) < 256 && pb_membersize(grpc_lb_v1_ServerList, servers) < 256 && pb_membersize(grpc_lb_v1_ServerList, expiration_interval) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_grpc_lb_v1_Duration_grpc_lb_v1_LoadBalanceRequest_grpc_lb_v1_InitialLoadBalanceRequest_grpc_lb_v1_ClientStats_grpc_lb_v1_LoadBalanceResponse_grpc_lb_v1_InitialLoadBalanceResponse_grpc_lb_v1_ServerList_grpc_lb_v1_Server)
117
116
  #endif
118
117
 
119
118
 
@@ -0,0 +1,178 @@
1
+ /*
2
+ *
3
+ * Copyright 2016, Google Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are
8
+ * met:
9
+ *
10
+ * * Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * * Redistributions in binary form must reproduce the above
13
+ * copyright notice, this list of conditions and the following disclaimer
14
+ * in the documentation and/or other materials provided with the
15
+ * distribution.
16
+ * * Neither the name of Google Inc. nor the names of its
17
+ * contributors may be used to endorse or promote products derived from
18
+ * this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ *
32
+ */
33
+ /* Automatically generated nanopb header */
34
+ /* Generated by nanopb-0.3.5-dev */
35
+
36
+ #ifndef GRPC_CORE_EXT_LB_POLICY_GRPCLB_PROTO_GRPC_LB_V1_LOAD_BALANCER_PB_H
37
+ #define GRPC_CORE_EXT_LB_POLICY_GRPCLB_PROTO_GRPC_LB_V1_LOAD_BALANCER_PB_H
38
+ #include "third_party/nanopb/pb.h"
39
+ #if PB_PROTO_HEADER_VERSION != 30
40
+ #error Regenerate this file with the current version of nanopb generator.
41
+ #endif
42
+
43
+ #ifdef __cplusplus
44
+ extern "C" {
45
+ #endif
46
+
47
+ /* Struct definitions */
48
+ typedef struct _grpc_lb_v1_ClientStats {
49
+ bool has_total_requests;
50
+ int64_t total_requests;
51
+ bool has_client_rpc_errors;
52
+ int64_t client_rpc_errors;
53
+ bool has_dropped_requests;
54
+ int64_t dropped_requests;
55
+ } grpc_lb_v1_ClientStats;
56
+
57
+ typedef struct _grpc_lb_v1_Duration {
58
+ bool has_seconds;
59
+ int64_t seconds;
60
+ bool has_nanos;
61
+ int32_t nanos;
62
+ } grpc_lb_v1_Duration;
63
+
64
+ typedef struct _grpc_lb_v1_InitialLoadBalanceRequest {
65
+ bool has_name;
66
+ char name[128];
67
+ } grpc_lb_v1_InitialLoadBalanceRequest;
68
+
69
+ typedef struct _grpc_lb_v1_Server {
70
+ bool has_ip_address;
71
+ char ip_address[46];
72
+ bool has_port;
73
+ int32_t port;
74
+ bool has_load_balance_token;
75
+ char load_balance_token[64];
76
+ bool has_drop_request;
77
+ bool drop_request;
78
+ } grpc_lb_v1_Server;
79
+
80
+ typedef struct _grpc_lb_v1_InitialLoadBalanceResponse {
81
+ bool has_load_balancer_delegate;
82
+ char load_balancer_delegate[64];
83
+ bool has_client_stats_report_interval;
84
+ grpc_lb_v1_Duration client_stats_report_interval;
85
+ } grpc_lb_v1_InitialLoadBalanceResponse;
86
+
87
+ typedef struct _grpc_lb_v1_LoadBalanceRequest {
88
+ bool has_initial_request;
89
+ grpc_lb_v1_InitialLoadBalanceRequest initial_request;
90
+ bool has_client_stats;
91
+ grpc_lb_v1_ClientStats client_stats;
92
+ } grpc_lb_v1_LoadBalanceRequest;
93
+
94
+ typedef struct _grpc_lb_v1_ServerList {
95
+ pb_callback_t servers;
96
+ bool has_expiration_interval;
97
+ grpc_lb_v1_Duration expiration_interval;
98
+ } grpc_lb_v1_ServerList;
99
+
100
+ typedef struct _grpc_lb_v1_LoadBalanceResponse {
101
+ bool has_initial_response;
102
+ grpc_lb_v1_InitialLoadBalanceResponse initial_response;
103
+ bool has_server_list;
104
+ grpc_lb_v1_ServerList server_list;
105
+ } grpc_lb_v1_LoadBalanceResponse;
106
+
107
+ /* Default values for struct fields */
108
+
109
+ /* Initializer values for message structs */
110
+ #define grpc_lb_v1_Duration_init_default {false, 0, false, 0}
111
+ #define grpc_lb_v1_LoadBalanceRequest_init_default {false, grpc_lb_v1_InitialLoadBalanceRequest_init_default, false, grpc_lb_v1_ClientStats_init_default}
112
+ #define grpc_lb_v1_InitialLoadBalanceRequest_init_default {false, ""}
113
+ #define grpc_lb_v1_ClientStats_init_default {false, 0, false, 0, false, 0}
114
+ #define grpc_lb_v1_LoadBalanceResponse_init_default {false, grpc_lb_v1_InitialLoadBalanceResponse_init_default, false, grpc_lb_v1_ServerList_init_default}
115
+ #define grpc_lb_v1_InitialLoadBalanceResponse_init_default {false, "", false, grpc_lb_v1_Duration_init_default}
116
+ #define grpc_lb_v1_ServerList_init_default {{{NULL}, NULL}, false, grpc_lb_v1_Duration_init_default}
117
+ #define grpc_lb_v1_Server_init_default {false, "", false, 0, false, "", false, 0}
118
+ #define grpc_lb_v1_Duration_init_zero {false, 0, false, 0}
119
+ #define grpc_lb_v1_LoadBalanceRequest_init_zero {false, grpc_lb_v1_InitialLoadBalanceRequest_init_zero, false, grpc_lb_v1_ClientStats_init_zero}
120
+ #define grpc_lb_v1_InitialLoadBalanceRequest_init_zero {false, ""}
121
+ #define grpc_lb_v1_ClientStats_init_zero {false, 0, false, 0, false, 0}
122
+ #define grpc_lb_v1_LoadBalanceResponse_init_zero {false, grpc_lb_v1_InitialLoadBalanceResponse_init_zero, false, grpc_lb_v1_ServerList_init_zero}
123
+ #define grpc_lb_v1_InitialLoadBalanceResponse_init_zero {false, "", false, grpc_lb_v1_Duration_init_zero}
124
+ #define grpc_lb_v1_ServerList_init_zero {{{NULL}, NULL}, false, grpc_lb_v1_Duration_init_zero}
125
+ #define grpc_lb_v1_Server_init_zero {false, "", false, 0, false, "", false, 0}
126
+
127
+ /* Field tags (for use in manual encoding/decoding) */
128
+ #define grpc_lb_v1_ClientStats_total_requests_tag 1
129
+ #define grpc_lb_v1_ClientStats_client_rpc_errors_tag 2
130
+ #define grpc_lb_v1_ClientStats_dropped_requests_tag 3
131
+ #define grpc_lb_v1_Duration_seconds_tag 1
132
+ #define grpc_lb_v1_Duration_nanos_tag 2
133
+ #define grpc_lb_v1_InitialLoadBalanceRequest_name_tag 1
134
+ #define grpc_lb_v1_Server_ip_address_tag 1
135
+ #define grpc_lb_v1_Server_port_tag 2
136
+ #define grpc_lb_v1_Server_load_balance_token_tag 3
137
+ #define grpc_lb_v1_Server_drop_request_tag 4
138
+ #define grpc_lb_v1_InitialLoadBalanceResponse_load_balancer_delegate_tag 2
139
+ #define grpc_lb_v1_InitialLoadBalanceResponse_client_stats_report_interval_tag 3
140
+ #define grpc_lb_v1_LoadBalanceRequest_initial_request_tag 1
141
+ #define grpc_lb_v1_LoadBalanceRequest_client_stats_tag 2
142
+ #define grpc_lb_v1_ServerList_servers_tag 1
143
+ #define grpc_lb_v1_ServerList_expiration_interval_tag 3
144
+ #define grpc_lb_v1_LoadBalanceResponse_initial_response_tag 1
145
+ #define grpc_lb_v1_LoadBalanceResponse_server_list_tag 2
146
+
147
+ /* Struct field encoding specification for nanopb */
148
+ extern const pb_field_t grpc_lb_v1_Duration_fields[3];
149
+ extern const pb_field_t grpc_lb_v1_LoadBalanceRequest_fields[3];
150
+ extern const pb_field_t grpc_lb_v1_InitialLoadBalanceRequest_fields[2];
151
+ extern const pb_field_t grpc_lb_v1_ClientStats_fields[4];
152
+ extern const pb_field_t grpc_lb_v1_LoadBalanceResponse_fields[3];
153
+ extern const pb_field_t grpc_lb_v1_InitialLoadBalanceResponse_fields[3];
154
+ extern const pb_field_t grpc_lb_v1_ServerList_fields[3];
155
+ extern const pb_field_t grpc_lb_v1_Server_fields[5];
156
+
157
+ /* Maximum encoded size of messages (where known) */
158
+ #define grpc_lb_v1_Duration_size 22
159
+ #define grpc_lb_v1_LoadBalanceRequest_size 169
160
+ #define grpc_lb_v1_InitialLoadBalanceRequest_size 131
161
+ #define grpc_lb_v1_ClientStats_size 33
162
+ #define grpc_lb_v1_LoadBalanceResponse_size (98 + grpc_lb_v1_ServerList_size)
163
+ #define grpc_lb_v1_InitialLoadBalanceResponse_size 90
164
+ #define grpc_lb_v1_Server_size 127
165
+
166
+ /* Message IDs (where set with "msgid" option) */
167
+ #ifdef PB_MSGID
168
+
169
+ #define LOAD_BALANCER_MESSAGES \
170
+
171
+
172
+ #endif
173
+
174
+ #ifdef __cplusplus
175
+ } /* extern "C" */
176
+ #endif
177
+
178
+ #endif
@@ -39,7 +39,7 @@
39
39
 
40
40
  typedef struct pending_pick {
41
41
  struct pending_pick *next;
42
- grpc_pollset *pollset;
42
+ grpc_polling_entity *pollent;
43
43
  uint32_t initial_metadata_flags;
44
44
  grpc_connected_subchannel **target;
45
45
  grpc_closure *on_complete;
@@ -103,8 +103,9 @@ static void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
103
103
  p->shutdown = 1;
104
104
  pp = p->pending_picks;
105
105
  p->pending_picks = NULL;
106
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
107
- GRPC_CHANNEL_FATAL_FAILURE, "shutdown");
106
+ grpc_connectivity_state_set(
107
+ exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
108
+ GRPC_ERROR_CREATE("Channel shutdown"), "shutdown");
108
109
  /* cancel subscription */
109
110
  if (selected != NULL) {
110
111
  grpc_connected_subchannel_notify_on_state_change(
@@ -118,9 +119,9 @@ static void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
118
119
  while (pp != NULL) {
119
120
  pending_pick *next = pp->next;
120
121
  *pp->target = NULL;
121
- grpc_pollset_set_del_pollset(exec_ctx, p->base.interested_parties,
122
- pp->pollset);
123
- grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, true, NULL);
122
+ grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent,
123
+ p->base.interested_parties);
124
+ grpc_exec_ctx_sched(exec_ctx, pp->on_complete, GRPC_ERROR_NONE, NULL);
124
125
  gpr_free(pp);
125
126
  pp = next;
126
127
  }
@@ -136,10 +137,11 @@ static void pf_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
136
137
  while (pp != NULL) {
137
138
  pending_pick *next = pp->next;
138
139
  if (pp->target == target) {
139
- grpc_pollset_set_del_pollset(exec_ctx, p->base.interested_parties,
140
- pp->pollset);
140
+ grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent,
141
+ p->base.interested_parties);
141
142
  *target = NULL;
142
- grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, false, NULL);
143
+ grpc_exec_ctx_sched(exec_ctx, pp->on_complete,
144
+ GRPC_ERROR_CREATE("Pick Cancelled"), NULL);
143
145
  gpr_free(pp);
144
146
  } else {
145
147
  pp->next = p->pending_picks;
@@ -162,9 +164,10 @@ static void pf_cancel_picks(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
162
164
  pending_pick *next = pp->next;
163
165
  if ((pp->initial_metadata_flags & initial_metadata_flags_mask) ==
164
166
  initial_metadata_flags_eq) {
165
- grpc_pollset_set_del_pollset(exec_ctx, p->base.interested_parties,
166
- pp->pollset);
167
- grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, false, NULL);
167
+ grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent,
168
+ p->base.interested_parties);
169
+ grpc_exec_ctx_sched(exec_ctx, pp->on_complete,
170
+ GRPC_ERROR_CREATE("Pick Cancelled"), NULL);
168
171
  gpr_free(pp);
169
172
  } else {
170
173
  pp->next = p->pending_picks;
@@ -196,7 +199,8 @@ static void pf_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
196
199
  }
197
200
 
198
201
  static int pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
199
- grpc_pollset *pollset, grpc_metadata_batch *initial_metadata,
202
+ grpc_polling_entity *pollent,
203
+ grpc_metadata_batch *initial_metadata,
200
204
  uint32_t initial_metadata_flags,
201
205
  grpc_connected_subchannel **target,
202
206
  grpc_closure *on_complete) {
@@ -221,10 +225,11 @@ static int pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
221
225
  if (!p->started_picking) {
222
226
  start_picking(exec_ctx, p);
223
227
  }
224
- grpc_pollset_set_add_pollset(exec_ctx, p->base.interested_parties, pollset);
228
+ grpc_polling_entity_add_to_pollset_set(exec_ctx, pollent,
229
+ p->base.interested_parties);
225
230
  pp = gpr_malloc(sizeof(*pp));
226
231
  pp->next = p->pending_picks;
227
- pp->pollset = pollset;
232
+ pp->pollent = pollent;
228
233
  pp->target = target;
229
234
  pp->initial_metadata_flags = initial_metadata_flags;
230
235
  pp->on_complete = on_complete;
@@ -235,7 +240,7 @@ static int pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
235
240
  }
236
241
 
237
242
  static void destroy_subchannels(grpc_exec_ctx *exec_ctx, void *arg,
238
- bool iomgr_success) {
243
+ grpc_error *error) {
239
244
  pick_first_lb_policy *p = arg;
240
245
  size_t i;
241
246
  size_t num_subchannels = p->num_subchannels;
@@ -256,12 +261,14 @@ static void destroy_subchannels(grpc_exec_ctx *exec_ctx, void *arg,
256
261
  }
257
262
 
258
263
  static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
259
- bool iomgr_success) {
264
+ grpc_error *error) {
260
265
  pick_first_lb_policy *p = arg;
261
266
  grpc_subchannel *selected_subchannel;
262
267
  pending_pick *pp;
263
268
  grpc_connected_subchannel *selected;
264
269
 
270
+ GRPC_ERROR_REF(error);
271
+
265
272
  gpr_mu_lock(&p->mu);
266
273
 
267
274
  selected = GET_SELECTED(p);
@@ -269,15 +276,17 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
269
276
  if (p->shutdown) {
270
277
  gpr_mu_unlock(&p->mu);
271
278
  GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "pick_first_connectivity");
279
+ GRPC_ERROR_UNREF(error);
272
280
  return;
273
281
  } else if (selected != NULL) {
274
282
  if (p->checking_connectivity == GRPC_CHANNEL_TRANSIENT_FAILURE) {
275
283
  /* if the selected channel goes bad, we're done */
276
- p->checking_connectivity = GRPC_CHANNEL_FATAL_FAILURE;
284
+ p->checking_connectivity = GRPC_CHANNEL_SHUTDOWN;
277
285
  }
278
286
  grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
279
- p->checking_connectivity, "selected_changed");
280
- if (p->checking_connectivity != GRPC_CHANNEL_FATAL_FAILURE) {
287
+ p->checking_connectivity, GRPC_ERROR_REF(error),
288
+ "selected_changed");
289
+ if (p->checking_connectivity != GRPC_CHANNEL_SHUTDOWN) {
281
290
  grpc_connected_subchannel_notify_on_state_change(
282
291
  exec_ctx, selected, p->base.interested_parties,
283
292
  &p->checking_connectivity, &p->connectivity_changed);
@@ -289,7 +298,8 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
289
298
  switch (p->checking_connectivity) {
290
299
  case GRPC_CHANNEL_READY:
291
300
  grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
292
- GRPC_CHANNEL_READY, "connecting_ready");
301
+ GRPC_CHANNEL_READY, GRPC_ERROR_NONE,
302
+ "connecting_ready");
293
303
  selected_subchannel = p->subchannels[p->checking_subchannel];
294
304
  selected =
295
305
  grpc_subchannel_get_connected_subchannel(selected_subchannel);
@@ -298,15 +308,16 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
298
308
  /* drop the pick list: we are connected now */
299
309
  GRPC_LB_POLICY_WEAK_REF(&p->base, "destroy_subchannels");
300
310
  gpr_atm_rel_store(&p->selected, (gpr_atm)selected);
301
- grpc_exec_ctx_enqueue(
302
- exec_ctx, grpc_closure_create(destroy_subchannels, p), true, NULL);
311
+ grpc_exec_ctx_sched(exec_ctx,
312
+ grpc_closure_create(destroy_subchannels, p),
313
+ GRPC_ERROR_NONE, NULL);
303
314
  /* update any calls that were waiting for a pick */
304
315
  while ((pp = p->pending_picks)) {
305
316
  p->pending_picks = pp->next;
306
317
  *pp->target = selected;
307
- grpc_pollset_set_del_pollset(exec_ctx, p->base.interested_parties,
308
- pp->pollset);
309
- grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, true, NULL);
318
+ grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent,
319
+ p->base.interested_parties);
320
+ grpc_exec_ctx_sched(exec_ctx, pp->on_complete, GRPC_ERROR_NONE, NULL);
310
321
  gpr_free(pp);
311
322
  }
312
323
  grpc_connected_subchannel_notify_on_state_change(
@@ -318,12 +329,13 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
318
329
  (p->checking_subchannel + 1) % p->num_subchannels;
319
330
  if (p->checking_subchannel == 0) {
320
331
  /* only trigger transient failure when we've tried all alternatives */
321
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
322
- GRPC_CHANNEL_TRANSIENT_FAILURE,
323
- "connecting_transient_failure");
332
+ grpc_connectivity_state_set(
333
+ exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
334
+ GRPC_ERROR_REF(error), "connecting_transient_failure");
324
335
  }
336
+ GRPC_ERROR_UNREF(error);
325
337
  p->checking_connectivity = grpc_subchannel_check_connectivity(
326
- p->subchannels[p->checking_subchannel]);
338
+ p->subchannels[p->checking_subchannel], &error);
327
339
  if (p->checking_connectivity == GRPC_CHANNEL_TRANSIENT_FAILURE) {
328
340
  grpc_subchannel_notify_on_state_change(
329
341
  exec_ctx, p->subchannels[p->checking_subchannel],
@@ -335,53 +347,60 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
335
347
  break;
336
348
  case GRPC_CHANNEL_CONNECTING:
337
349
  case GRPC_CHANNEL_IDLE:
338
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
339
- GRPC_CHANNEL_CONNECTING,
340
- "connecting_changed");
350
+ grpc_connectivity_state_set(
351
+ exec_ctx, &p->state_tracker, GRPC_CHANNEL_CONNECTING,
352
+ GRPC_ERROR_REF(error), "connecting_changed");
341
353
  grpc_subchannel_notify_on_state_change(
342
354
  exec_ctx, p->subchannels[p->checking_subchannel],
343
355
  p->base.interested_parties, &p->checking_connectivity,
344
356
  &p->connectivity_changed);
345
357
  break;
346
- case GRPC_CHANNEL_FATAL_FAILURE:
358
+ case GRPC_CHANNEL_SHUTDOWN:
347
359
  p->num_subchannels--;
348
360
  GPR_SWAP(grpc_subchannel *, p->subchannels[p->checking_subchannel],
349
361
  p->subchannels[p->num_subchannels]);
350
362
  GRPC_SUBCHANNEL_UNREF(exec_ctx, p->subchannels[p->num_subchannels],
351
363
  "pick_first");
352
364
  if (p->num_subchannels == 0) {
353
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
354
- GRPC_CHANNEL_FATAL_FAILURE,
355
- "no_more_channels");
365
+ grpc_connectivity_state_set(
366
+ exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN,
367
+ GRPC_ERROR_CREATE_REFERENCING("Pick first exhausted channels",
368
+ &error, 1),
369
+ "no_more_channels");
356
370
  while ((pp = p->pending_picks)) {
357
371
  p->pending_picks = pp->next;
358
372
  *pp->target = NULL;
359
- grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, true, NULL);
373
+ grpc_exec_ctx_sched(exec_ctx, pp->on_complete, GRPC_ERROR_NONE,
374
+ NULL);
360
375
  gpr_free(pp);
361
376
  }
362
377
  GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base,
363
378
  "pick_first_connectivity");
364
379
  } else {
365
- grpc_connectivity_state_set(exec_ctx, &p->state_tracker,
366
- GRPC_CHANNEL_TRANSIENT_FAILURE,
367
- "subchannel_failed");
380
+ grpc_connectivity_state_set(
381
+ exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE,
382
+ GRPC_ERROR_REF(error), "subchannel_failed");
368
383
  p->checking_subchannel %= p->num_subchannels;
384
+ GRPC_ERROR_UNREF(error);
369
385
  p->checking_connectivity = grpc_subchannel_check_connectivity(
370
- p->subchannels[p->checking_subchannel]);
386
+ p->subchannels[p->checking_subchannel], &error);
371
387
  goto loop;
372
388
  }
373
389
  }
374
390
  }
375
391
 
376
392
  gpr_mu_unlock(&p->mu);
393
+
394
+ GRPC_ERROR_UNREF(error);
377
395
  }
378
396
 
379
397
  static grpc_connectivity_state pf_check_connectivity(grpc_exec_ctx *exec_ctx,
380
- grpc_lb_policy *pol) {
398
+ grpc_lb_policy *pol,
399
+ grpc_error **error) {
381
400
  pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
382
401
  grpc_connectivity_state st;
383
402
  gpr_mu_lock(&p->mu);
384
- st = grpc_connectivity_state_check(&p->state_tracker);
403
+ st = grpc_connectivity_state_check(&p->state_tracker, error);
385
404
  gpr_mu_unlock(&p->mu);
386
405
  return st;
387
406
  }
@@ -404,7 +423,8 @@ static void pf_ping_one(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
404
423
  if (selected) {
405
424
  grpc_connected_subchannel_ping(exec_ctx, selected, closure);
406
425
  } else {
407
- grpc_exec_ctx_enqueue(exec_ctx, closure, false, NULL);
426
+ grpc_exec_ctx_sched(exec_ctx, closure, GRPC_ERROR_CREATE("Not connected"),
427
+ NULL);
408
428
  }
409
429
  }
410
430