grpc 0.13.0 → 0.13.1.pre1

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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/Makefile +1114 -937
  4. data/include/grpc/census.h +71 -89
  5. data/include/grpc/compression.h +7 -7
  6. data/include/grpc/grpc.h +65 -68
  7. data/include/grpc/grpc_security.h +38 -38
  8. data/include/grpc/impl/codegen/alloc.h +7 -7
  9. data/include/grpc/impl/codegen/byte_buffer.h +13 -13
  10. data/include/grpc/impl/codegen/grpc_types.h +7 -2
  11. data/include/grpc/impl/codegen/log.h +5 -5
  12. data/include/grpc/impl/codegen/port_platform.h +14 -6
  13. data/include/grpc/impl/codegen/slice.h +15 -15
  14. data/include/grpc/impl/codegen/slice_buffer.h +17 -17
  15. data/include/grpc/impl/codegen/sync.h +26 -22
  16. data/include/grpc/impl/codegen/time.h +22 -24
  17. data/include/grpc/support/avl.h +9 -8
  18. data/include/grpc/support/cmdline.h +12 -12
  19. data/include/grpc/support/cpu.h +2 -2
  20. data/include/grpc/support/histogram.h +22 -22
  21. data/include/grpc/support/host_port.h +2 -2
  22. data/include/grpc/support/log_win32.h +1 -1
  23. data/include/grpc/support/string_util.h +2 -2
  24. data/include/grpc/support/subprocess.h +5 -5
  25. data/include/grpc/support/thd.h +9 -9
  26. data/include/grpc/support/useful.h +3 -1
  27. data/src/core/census/context.c +64 -85
  28. data/src/core/census/grpc_filter.c +2 -2
  29. data/src/core/census/mlog.c +600 -0
  30. data/src/core/census/mlog.h +95 -0
  31. data/src/core/channel/channel_args.c +67 -6
  32. data/src/core/channel/channel_args.h +7 -1
  33. data/src/core/channel/client_channel.c +26 -36
  34. data/src/core/channel/client_uchannel.c +1 -1
  35. data/src/core/channel/http_client_filter.c +2 -2
  36. data/src/core/channel/http_server_filter.c +2 -2
  37. data/src/core/channel/subchannel_call_holder.c +5 -7
  38. data/src/core/client_config/connector.c +3 -2
  39. data/src/core/client_config/connector.h +2 -2
  40. data/src/core/client_config/lb_policies/load_balancer_api.c +163 -0
  41. data/src/core/client_config/lb_policies/load_balancer_api.h +85 -0
  42. data/src/core/client_config/lb_policies/pick_first.c +10 -11
  43. data/src/core/client_config/lb_policies/round_robin.c +7 -8
  44. data/src/core/client_config/lb_policy.c +3 -3
  45. data/src/core/client_config/lb_policy.h +3 -2
  46. data/src/core/client_config/subchannel.c +51 -21
  47. data/src/core/client_config/subchannel.h +15 -6
  48. data/src/core/client_config/subchannel_index.c +261 -0
  49. data/src/core/client_config/subchannel_index.h +77 -0
  50. data/src/core/compression/{algorithm.c → compression_algorithm.c} +0 -0
  51. data/src/core/httpcli/httpcli.c +13 -11
  52. data/src/core/httpcli/httpcli.h +3 -2
  53. data/src/core/httpcli/httpcli_security_connector.c +7 -7
  54. data/src/core/iomgr/fd_posix.c +4 -2
  55. data/src/core/iomgr/iocp_windows.c +10 -6
  56. data/src/core/iomgr/iocp_windows.h +9 -2
  57. data/src/core/iomgr/iomgr.c +18 -2
  58. data/src/core/iomgr/iomgr_internal.h +5 -1
  59. data/src/core/iomgr/pollset.h +9 -10
  60. data/src/core/iomgr/pollset_multipoller_with_epoll.c +1 -0
  61. data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +10 -5
  62. data/src/core/iomgr/pollset_posix.c +30 -35
  63. data/src/core/iomgr/pollset_posix.h +10 -6
  64. data/src/core/iomgr/pollset_set.h +3 -9
  65. data/src/core/iomgr/pollset_set_posix.c +23 -3
  66. data/src/core/iomgr/pollset_set_posix.h +2 -18
  67. data/src/core/iomgr/pollset_set_windows.c +3 -3
  68. data/src/core/iomgr/pollset_set_windows.h +2 -2
  69. data/src/core/iomgr/pollset_windows.c +24 -21
  70. data/src/core/iomgr/pollset_windows.h +1 -5
  71. data/src/core/iomgr/tcp_client_posix.c +7 -5
  72. data/src/core/iomgr/tcp_posix.c +4 -2
  73. data/src/core/iomgr/tcp_server_windows.c +1 -2
  74. data/src/core/iomgr/timer.c +2 -3
  75. data/src/core/iomgr/timer.h +21 -1
  76. data/src/core/iomgr/timer_heap.c +10 -12
  77. data/src/core/iomgr/udp_server.c +5 -4
  78. data/src/core/iomgr/udp_server.h +1 -0
  79. data/src/core/iomgr/workqueue_posix.c +1 -0
  80. data/src/core/iomgr/workqueue_posix.h +3 -1
  81. data/src/core/proto/grpc/lb/v0/load_balancer.pb.c +119 -0
  82. data/src/core/proto/grpc/lb/v0/load_balancer.pb.h +182 -0
  83. data/src/core/security/{base64.c → b64.c} +1 -1
  84. data/src/core/security/{base64.h → b64.h} +1 -1
  85. data/src/core/security/client_auth_filter.c +0 -1
  86. data/src/core/security/credentials.c +12 -5
  87. data/src/core/security/credentials.h +3 -3
  88. data/src/core/security/google_default_credentials.c +24 -19
  89. data/src/core/security/handshake.c +15 -7
  90. data/src/core/security/handshake.h +2 -1
  91. data/src/core/security/json_token.c +1 -1
  92. data/src/core/security/jwt_verifier.c +1 -1
  93. data/src/core/security/security_connector.c +84 -64
  94. data/src/core/security/security_connector.h +42 -22
  95. data/src/core/security/security_context.c +8 -3
  96. data/src/core/security/server_auth_filter.c +2 -2
  97. data/src/core/security/server_secure_chttp2.c +7 -7
  98. data/src/core/support/avl.c +2 -2
  99. data/src/core/support/env_linux.c +17 -0
  100. data/src/core/support/{file.c → load_file.c} +2 -2
  101. data/src/core/support/{file.h → load_file.h} +4 -12
  102. data/src/core/support/sync.c +6 -1
  103. data/src/core/support/time_posix.c +1 -1
  104. data/src/core/{iomgr/timer_internal.h → support/tmpfile.h} +17 -23
  105. data/src/core/support/{file_posix.c → tmpfile_posix.c} +2 -2
  106. data/src/core/support/{file_win32.c → tmpfile_win32.c} +2 -2
  107. data/src/core/surface/alarm.c +3 -2
  108. data/src/core/surface/call.c +102 -52
  109. data/src/core/surface/channel_create.c +1 -1
  110. data/src/core/surface/completion_queue.c +73 -41
  111. data/src/core/surface/init.c +4 -0
  112. data/src/core/surface/lame_client.c +1 -2
  113. data/src/core/surface/secure_channel_create.c +6 -7
  114. data/src/core/surface/server.c +13 -5
  115. data/src/core/surface/validate_metadata.c +1 -1
  116. data/src/core/surface/version.c +1 -1
  117. data/src/core/transport/chttp2/internal.h +22 -10
  118. data/src/core/transport/chttp2/parsing.c +3 -3
  119. data/src/core/transport/chttp2/stream_lists.c +39 -21
  120. data/src/core/transport/chttp2/writing.c +19 -28
  121. data/src/core/transport/chttp2_transport.c +80 -37
  122. data/src/core/transport/metadata.c +8 -0
  123. data/src/core/transport/static_metadata.c +17 -17
  124. data/src/core/transport/static_metadata.h +3 -3
  125. data/src/core/transport/transport.c +2 -1
  126. data/src/core/transport/transport.h +12 -5
  127. data/src/ruby/ext/grpc/extconf.rb +1 -0
  128. data/src/ruby/ext/grpc/rb_call.c +6 -0
  129. data/src/ruby/ext/grpc/rb_call_credentials.c +12 -14
  130. data/src/ruby/ext/grpc/rb_channel.c +8 -14
  131. data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -12
  132. data/src/ruby/ext/grpc/rb_grpc.c +19 -18
  133. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  134. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +8 -2
  135. data/src/ruby/lib/grpc/core/time_consts.rb +2 -2
  136. data/src/ruby/lib/grpc/errors.rb +2 -2
  137. data/src/ruby/lib/grpc/generic/rpc_server.rb +58 -39
  138. data/src/ruby/lib/grpc/version.rb +1 -1
  139. data/src/ruby/pb/README.md +2 -2
  140. data/src/ruby/pb/generate_proto_ruby.sh +2 -2
  141. data/src/ruby/pb/grpc/health/checker.rb +11 -11
  142. data/src/ruby/pb/grpc/health/v1/health.rb +28 -0
  143. data/src/ruby/pb/grpc/health/{v1alpha → v1}/health_services.rb +4 -4
  144. data/src/ruby/spec/client_server_spec.rb +2 -1
  145. data/src/ruby/spec/generic/rpc_server_spec.rb +3 -22
  146. data/src/ruby/spec/pb/health/checker_spec.rb +22 -36
  147. data/third_party/nanopb/pb.h +547 -0
  148. data/third_party/nanopb/pb_common.c +97 -0
  149. data/third_party/nanopb/pb_common.h +42 -0
  150. data/third_party/nanopb/pb_decode.c +1319 -0
  151. data/third_party/nanopb/pb_decode.h +149 -0
  152. data/third_party/nanopb/pb_encode.c +690 -0
  153. data/third_party/nanopb/pb_encode.h +154 -0
  154. metadata +32 -16
  155. data/src/ruby/pb/grpc/health/v1alpha/health.rb +0 -29
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  *
3
- * Copyright 2015, Google Inc.
3
+ * Copyright 2015-2016, Google Inc.
4
4
  * All rights reserved.
5
5
  *
6
6
  * Redistribution and use in source and binary forms, with or without
@@ -33,8 +33,9 @@
33
33
 
34
34
  #include "src/core/client_config/connector.h"
35
35
 
36
- void grpc_connector_ref(grpc_connector* connector) {
36
+ grpc_connector* grpc_connector_ref(grpc_connector* connector) {
37
37
  connector->vtable->ref(connector);
38
+ return connector;
38
39
  }
39
40
 
40
41
  void grpc_connector_unref(grpc_exec_ctx* exec_ctx, grpc_connector* connector) {
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  *
3
- * Copyright 2015, Google Inc.
3
+ * Copyright 2015-2016, Google Inc.
4
4
  * All rights reserved.
5
5
  *
6
6
  * Redistribution and use in source and binary forms, with or without
@@ -81,7 +81,7 @@ struct grpc_connector_vtable {
81
81
  grpc_connect_out_args *out_args, grpc_closure *notify);
82
82
  };
83
83
 
84
- void grpc_connector_ref(grpc_connector *connector);
84
+ grpc_connector *grpc_connector_ref(grpc_connector *connector);
85
85
  void grpc_connector_unref(grpc_exec_ctx *exec_ctx, grpc_connector *connector);
86
86
  /** Connect using the connector: max one outstanding call at a time */
87
87
  void grpc_connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
@@ -0,0 +1,163 @@
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
+
34
+ #include "src/core/client_config/lb_policies/load_balancer_api.h"
35
+ #include "third_party/nanopb/pb_decode.h"
36
+ #include "third_party/nanopb/pb_encode.h"
37
+
38
+ #include <grpc/support/alloc.h>
39
+
40
+ typedef struct decode_serverlist_arg {
41
+ int first_pass;
42
+ int i;
43
+ size_t num_servers;
44
+ grpc_grpclb_server **servers;
45
+ } decode_serverlist_arg;
46
+
47
+ /* invoked once for every Server in ServerList */
48
+ static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field,
49
+ void **arg) {
50
+ decode_serverlist_arg *dec_arg = *arg;
51
+ if (dec_arg->first_pass != 0) { /* first pass */
52
+ grpc_grpclb_server server;
53
+ if (!pb_decode(stream, grpc_lb_v0_Server_fields, &server)) {
54
+ return false;
55
+ }
56
+ dec_arg->num_servers++;
57
+ } else { /* second pass */
58
+ grpc_grpclb_server *server = gpr_malloc(sizeof(grpc_grpclb_server));
59
+ GPR_ASSERT(dec_arg->num_servers > 0);
60
+ if (dec_arg->i == 0) { /* first iteration of second pass */
61
+ dec_arg->servers =
62
+ gpr_malloc(sizeof(grpc_grpclb_server *) * dec_arg->num_servers);
63
+ }
64
+ if (!pb_decode(stream, grpc_lb_v0_Server_fields, server)) {
65
+ return false;
66
+ }
67
+ dec_arg->servers[dec_arg->i++] = server;
68
+ }
69
+
70
+ return true;
71
+ }
72
+
73
+ grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name) {
74
+ grpc_grpclb_request *req = gpr_malloc(sizeof(grpc_grpclb_request));
75
+
76
+ req->has_client_stats = 0; /* TODO(dgq): add support for stats once defined */
77
+ req->has_initial_request = 1;
78
+ req->initial_request.has_name = 1;
79
+ strncpy(req->initial_request.name, lb_service_name,
80
+ GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH);
81
+ return req;
82
+ }
83
+
84
+ gpr_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) {
85
+ size_t encoded_length;
86
+ pb_ostream_t sizestream;
87
+ pb_ostream_t outputstream;
88
+ gpr_slice slice;
89
+ memset(&sizestream, 0, sizeof(pb_ostream_t));
90
+ pb_encode(&sizestream, grpc_lb_v0_LoadBalanceRequest_fields, request);
91
+ encoded_length = sizestream.bytes_written;
92
+
93
+ slice = gpr_slice_malloc(encoded_length);
94
+ outputstream =
95
+ pb_ostream_from_buffer(GPR_SLICE_START_PTR(slice), encoded_length);
96
+ GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v0_LoadBalanceRequest_fields,
97
+ request) != 0);
98
+ return slice;
99
+ }
100
+
101
+ void grpc_grpclb_request_destroy(grpc_grpclb_request *request) {
102
+ gpr_free(request);
103
+ }
104
+
105
+ grpc_grpclb_response *grpc_grpclb_response_parse(gpr_slice encoded_response) {
106
+ bool status;
107
+ pb_istream_t stream =
108
+ pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_response),
109
+ GPR_SLICE_LENGTH(encoded_response));
110
+ grpc_grpclb_response *res = gpr_malloc(sizeof(grpc_grpclb_response));
111
+ memset(res, 0, sizeof(*res));
112
+ status = pb_decode(&stream, grpc_lb_v0_LoadBalanceResponse_fields, res);
113
+ GPR_ASSERT(status == true);
114
+ return res;
115
+ }
116
+
117
+ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
118
+ gpr_slice encoded_response) {
119
+ grpc_grpclb_serverlist *sl = gpr_malloc(sizeof(grpc_grpclb_serverlist));
120
+ bool status;
121
+ decode_serverlist_arg arg;
122
+ pb_istream_t stream =
123
+ pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_response),
124
+ GPR_SLICE_LENGTH(encoded_response));
125
+ pb_istream_t stream_at_start = stream;
126
+ grpc_grpclb_response *res = gpr_malloc(sizeof(grpc_grpclb_response));
127
+ memset(res, 0, sizeof(*res));
128
+ memset(&arg, 0, sizeof(decode_serverlist_arg));
129
+
130
+ res->server_list.servers.funcs.decode = decode_serverlist;
131
+ res->server_list.servers.arg = &arg;
132
+ arg.first_pass = 1;
133
+ status = pb_decode(&stream, grpc_lb_v0_LoadBalanceResponse_fields, res);
134
+ GPR_ASSERT(status == true);
135
+ GPR_ASSERT(arg.num_servers > 0);
136
+
137
+ arg.first_pass = 0;
138
+ status =
139
+ pb_decode(&stream_at_start, grpc_lb_v0_LoadBalanceResponse_fields, res);
140
+ GPR_ASSERT(status == true);
141
+ GPR_ASSERT(arg.servers != NULL);
142
+
143
+ sl->num_servers = arg.num_servers;
144
+ sl->servers = arg.servers;
145
+ if (res->server_list.has_expiration_interval) {
146
+ sl->expiration_interval = res->server_list.expiration_interval;
147
+ }
148
+ grpc_grpclb_response_destroy(res);
149
+ return sl;
150
+ }
151
+
152
+ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist) {
153
+ size_t i;
154
+ for (i = 0; i < serverlist->num_servers; i++) {
155
+ gpr_free(serverlist->servers[i]);
156
+ }
157
+ gpr_free(serverlist->servers);
158
+ gpr_free(serverlist);
159
+ }
160
+
161
+ void grpc_grpclb_response_destroy(grpc_grpclb_response *response) {
162
+ gpr_free(response);
163
+ }
@@ -0,0 +1,85 @@
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
+
34
+ #ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H
35
+ #define GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H
36
+
37
+ #include <grpc/support/slice_buffer.h>
38
+
39
+ #include "src/core/client_config/lb_policy_factory.h"
40
+ #include "src/core/proto/grpc/lb/v0/load_balancer.pb.h"
41
+
42
+ #ifdef __cplusplus
43
+ extern "C" {
44
+ #endif
45
+
46
+ #define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128
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;
52
+ typedef struct grpc_grpclb_serverlist {
53
+ grpc_grpclb_server **servers;
54
+ size_t num_servers;
55
+ grpc_grpclb_duration expiration_interval;
56
+ } grpc_grpclb_serverlist;
57
+
58
+ /** Create a request for a gRPC LB service under \a lb_service_name */
59
+ grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name);
60
+
61
+ /** Protocol Buffers v3-encode \a request */
62
+ gpr_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request);
63
+
64
+ /** Destroy \a request */
65
+ void grpc_grpclb_request_destroy(grpc_grpclb_request *request);
66
+
67
+ /** Parse (ie, decode) the bytes in \a encoded_response as a \a
68
+ * grpc_grpclb_response */
69
+ grpc_grpclb_response *grpc_grpclb_response_parse(gpr_slice encoded_response);
70
+
71
+ /** Destroy \a serverlist */
72
+ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist);
73
+
74
+ /** Parse the list of servers from an encoded \a grpc_grpclb_response */
75
+ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
76
+ gpr_slice encoded_response);
77
+
78
+ /** Destroy \a response */
79
+ void grpc_grpclb_response_destroy(grpc_grpclb_response *response);
80
+
81
+ #ifdef __cplusplus
82
+ }
83
+ #endif
84
+
85
+ #endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H */
@@ -31,8 +31,8 @@
31
31
  *
32
32
  */
33
33
 
34
- #include "src/core/client_config/lb_policy_factory.h"
35
34
  #include "src/core/client_config/lb_policies/pick_first.h"
35
+ #include "src/core/client_config/lb_policy_factory.h"
36
36
 
37
37
  #include <string.h>
38
38
 
@@ -119,7 +119,7 @@ void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
119
119
  while (pp != NULL) {
120
120
  pending_pick *next = pp->next;
121
121
  *pp->target = NULL;
122
- grpc_pollset_set_del_pollset(exec_ctx, &p->base.interested_parties,
122
+ grpc_pollset_set_del_pollset(exec_ctx, p->base.interested_parties,
123
123
  pp->pollset);
124
124
  grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, true, NULL);
125
125
  gpr_free(pp);
@@ -137,7 +137,7 @@ static void pf_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
137
137
  while (pp != NULL) {
138
138
  pending_pick *next = pp->next;
139
139
  if (pp->target == target) {
140
- grpc_pollset_set_del_pollset(exec_ctx, &p->base.interested_parties,
140
+ grpc_pollset_set_del_pollset(exec_ctx, p->base.interested_parties,
141
141
  pp->pollset);
142
142
  *target = NULL;
143
143
  grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, false, NULL);
@@ -158,7 +158,7 @@ static void start_picking(grpc_exec_ctx *exec_ctx, pick_first_lb_policy *p) {
158
158
  GRPC_LB_POLICY_WEAK_REF(&p->base, "pick_first_connectivity");
159
159
  grpc_subchannel_notify_on_state_change(
160
160
  exec_ctx, p->subchannels[p->checking_subchannel],
161
- &p->base.interested_parties, &p->checking_connectivity,
161
+ p->base.interested_parties, &p->checking_connectivity,
162
162
  &p->connectivity_changed);
163
163
  }
164
164
 
@@ -195,8 +195,7 @@ int pf_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, grpc_pollset *pollset,
195
195
  if (!p->started_picking) {
196
196
  start_picking(exec_ctx, p);
197
197
  }
198
- grpc_pollset_set_add_pollset(exec_ctx, &p->base.interested_parties,
199
- pollset);
198
+ grpc_pollset_set_add_pollset(exec_ctx, p->base.interested_parties, pollset);
200
199
  pp = gpr_malloc(sizeof(*pp));
201
200
  pp->next = p->pending_picks;
202
201
  pp->pollset = pollset;
@@ -253,7 +252,7 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
253
252
  p->checking_connectivity, "selected_changed");
254
253
  if (p->checking_connectivity != GRPC_CHANNEL_FATAL_FAILURE) {
255
254
  grpc_connected_subchannel_notify_on_state_change(
256
- exec_ctx, selected, &p->base.interested_parties,
255
+ exec_ctx, selected, p->base.interested_parties,
257
256
  &p->checking_connectivity, &p->connectivity_changed);
258
257
  } else {
259
258
  GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &p->base, "pick_first_connectivity");
@@ -278,13 +277,13 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
278
277
  while ((pp = p->pending_picks)) {
279
278
  p->pending_picks = pp->next;
280
279
  *pp->target = selected;
281
- grpc_pollset_set_del_pollset(exec_ctx, &p->base.interested_parties,
280
+ grpc_pollset_set_del_pollset(exec_ctx, p->base.interested_parties,
282
281
  pp->pollset);
283
282
  grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, true, NULL);
284
283
  gpr_free(pp);
285
284
  }
286
285
  grpc_connected_subchannel_notify_on_state_change(
287
- exec_ctx, selected, &p->base.interested_parties,
286
+ exec_ctx, selected, p->base.interested_parties,
288
287
  &p->checking_connectivity, &p->connectivity_changed);
289
288
  break;
290
289
  case GRPC_CHANNEL_TRANSIENT_FAILURE:
@@ -298,7 +297,7 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
298
297
  if (p->checking_connectivity == GRPC_CHANNEL_TRANSIENT_FAILURE) {
299
298
  grpc_subchannel_notify_on_state_change(
300
299
  exec_ctx, p->subchannels[p->checking_subchannel],
301
- &p->base.interested_parties, &p->checking_connectivity,
300
+ p->base.interested_parties, &p->checking_connectivity,
302
301
  &p->connectivity_changed);
303
302
  } else {
304
303
  goto loop;
@@ -311,7 +310,7 @@ static void pf_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
311
310
  "connecting_changed");
312
311
  grpc_subchannel_notify_on_state_change(
313
312
  exec_ctx, p->subchannels[p->checking_subchannel],
314
- &p->base.interested_parties, &p->checking_connectivity,
313
+ p->base.interested_parties, &p->checking_connectivity,
315
314
  &p->connectivity_changed);
316
315
  break;
317
316
  case GRPC_CHANNEL_FATAL_FAILURE:
@@ -260,7 +260,7 @@ static void rr_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
260
260
  while (pp != NULL) {
261
261
  pending_pick *next = pp->next;
262
262
  if (pp->target == target) {
263
- grpc_pollset_set_del_pollset(exec_ctx, &p->base.interested_parties,
263
+ grpc_pollset_set_del_pollset(exec_ctx, p->base.interested_parties,
264
264
  pp->pollset);
265
265
  *target = NULL;
266
266
  grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, false, NULL);
@@ -285,7 +285,7 @@ static void start_picking(grpc_exec_ctx *exec_ctx, round_robin_lb_policy *p) {
285
285
  subchannel_data *sd = p->subchannels[i];
286
286
  sd->connectivity_state = GRPC_CHANNEL_IDLE;
287
287
  grpc_subchannel_notify_on_state_change(
288
- exec_ctx, sd->subchannel, &p->base.interested_parties,
288
+ exec_ctx, sd->subchannel, p->base.interested_parties,
289
289
  &sd->connectivity_state, &sd->connectivity_changed_closure);
290
290
  GRPC_LB_POLICY_WEAK_REF(&p->base, "round_robin_connectivity");
291
291
  }
@@ -322,8 +322,7 @@ int rr_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, grpc_pollset *pollset,
322
322
  if (!p->started_picking) {
323
323
  start_picking(exec_ctx, p);
324
324
  }
325
- grpc_pollset_set_add_pollset(exec_ctx, &p->base.interested_parties,
326
- pollset);
325
+ grpc_pollset_set_add_pollset(exec_ctx, p->base.interested_parties, pollset);
327
326
  pp = gpr_malloc(sizeof(*pp));
328
327
  pp->next = p->pending_picks;
329
328
  pp->pollset = pollset;
@@ -374,13 +373,13 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
374
373
  "[RR CONN CHANGED] TARGET <-- SUBCHANNEL %p (NODE %p)",
375
374
  selected->subchannel, selected);
376
375
  }
377
- grpc_pollset_set_del_pollset(exec_ctx, &p->base.interested_parties,
376
+ grpc_pollset_set_del_pollset(exec_ctx, p->base.interested_parties,
378
377
  pp->pollset);
379
378
  grpc_exec_ctx_enqueue(exec_ctx, pp->on_complete, true, NULL);
380
379
  gpr_free(pp);
381
380
  }
382
381
  grpc_subchannel_notify_on_state_change(
383
- exec_ctx, sd->subchannel, &p->base.interested_parties,
382
+ exec_ctx, sd->subchannel, p->base.interested_parties,
384
383
  &sd->connectivity_state, &sd->connectivity_changed_closure);
385
384
  break;
386
385
  case GRPC_CHANNEL_CONNECTING:
@@ -389,13 +388,13 @@ static void rr_connectivity_changed(grpc_exec_ctx *exec_ctx, void *arg,
389
388
  sd->connectivity_state,
390
389
  "connecting_changed");
391
390
  grpc_subchannel_notify_on_state_change(
392
- exec_ctx, sd->subchannel, &p->base.interested_parties,
391
+ exec_ctx, sd->subchannel, p->base.interested_parties,
393
392
  &sd->connectivity_state, &sd->connectivity_changed_closure);
394
393
  break;
395
394
  case GRPC_CHANNEL_TRANSIENT_FAILURE:
396
395
  /* renew state notification */
397
396
  grpc_subchannel_notify_on_state_change(
398
- exec_ctx, sd->subchannel, &p->base.interested_parties,
397
+ exec_ctx, sd->subchannel, p->base.interested_parties,
399
398
  &sd->connectivity_state, &sd->connectivity_changed_closure);
400
399
 
401
400
  /* remove from ready list if still present */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  *
3
- * Copyright 2015, Google Inc.
3
+ * Copyright 2015-2016, Google Inc.
4
4
  * All rights reserved.
5
5
  *
6
6
  * Redistribution and use in source and binary forms, with or without
@@ -39,7 +39,7 @@ void grpc_lb_policy_init(grpc_lb_policy *policy,
39
39
  const grpc_lb_policy_vtable *vtable) {
40
40
  policy->vtable = vtable;
41
41
  gpr_atm_no_barrier_store(&policy->ref_pair, 1 << WEAK_REF_BITS);
42
- grpc_pollset_set_init(&policy->interested_parties);
42
+ policy->interested_parties = grpc_pollset_set_create();
43
43
  }
44
44
 
45
45
  #ifdef GRPC_LB_POLICY_REFCOUNT_DEBUG
@@ -93,7 +93,7 @@ void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx,
93
93
  gpr_atm old_val =
94
94
  ref_mutate(policy, -(gpr_atm)1, 1 REF_MUTATE_PASS_ARGS("WEAK_UNREF"));
95
95
  if (old_val == 1) {
96
- grpc_pollset_set_destroy(&policy->interested_parties);
96
+ grpc_pollset_set_destroy(policy->interested_parties);
97
97
  policy->vtable->destroy(exec_ctx, policy);
98
98
  }
99
99
  }