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.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/Makefile +1114 -937
- data/include/grpc/census.h +71 -89
- data/include/grpc/compression.h +7 -7
- data/include/grpc/grpc.h +65 -68
- data/include/grpc/grpc_security.h +38 -38
- data/include/grpc/impl/codegen/alloc.h +7 -7
- data/include/grpc/impl/codegen/byte_buffer.h +13 -13
- data/include/grpc/impl/codegen/grpc_types.h +7 -2
- data/include/grpc/impl/codegen/log.h +5 -5
- data/include/grpc/impl/codegen/port_platform.h +14 -6
- data/include/grpc/impl/codegen/slice.h +15 -15
- data/include/grpc/impl/codegen/slice_buffer.h +17 -17
- data/include/grpc/impl/codegen/sync.h +26 -22
- data/include/grpc/impl/codegen/time.h +22 -24
- data/include/grpc/support/avl.h +9 -8
- data/include/grpc/support/cmdline.h +12 -12
- data/include/grpc/support/cpu.h +2 -2
- data/include/grpc/support/histogram.h +22 -22
- data/include/grpc/support/host_port.h +2 -2
- data/include/grpc/support/log_win32.h +1 -1
- data/include/grpc/support/string_util.h +2 -2
- data/include/grpc/support/subprocess.h +5 -5
- data/include/grpc/support/thd.h +9 -9
- data/include/grpc/support/useful.h +3 -1
- data/src/core/census/context.c +64 -85
- data/src/core/census/grpc_filter.c +2 -2
- data/src/core/census/mlog.c +600 -0
- data/src/core/census/mlog.h +95 -0
- data/src/core/channel/channel_args.c +67 -6
- data/src/core/channel/channel_args.h +7 -1
- data/src/core/channel/client_channel.c +26 -36
- data/src/core/channel/client_uchannel.c +1 -1
- data/src/core/channel/http_client_filter.c +2 -2
- data/src/core/channel/http_server_filter.c +2 -2
- data/src/core/channel/subchannel_call_holder.c +5 -7
- data/src/core/client_config/connector.c +3 -2
- data/src/core/client_config/connector.h +2 -2
- data/src/core/client_config/lb_policies/load_balancer_api.c +163 -0
- data/src/core/client_config/lb_policies/load_balancer_api.h +85 -0
- data/src/core/client_config/lb_policies/pick_first.c +10 -11
- data/src/core/client_config/lb_policies/round_robin.c +7 -8
- data/src/core/client_config/lb_policy.c +3 -3
- data/src/core/client_config/lb_policy.h +3 -2
- data/src/core/client_config/subchannel.c +51 -21
- data/src/core/client_config/subchannel.h +15 -6
- data/src/core/client_config/subchannel_index.c +261 -0
- data/src/core/client_config/subchannel_index.h +77 -0
- data/src/core/compression/{algorithm.c → compression_algorithm.c} +0 -0
- data/src/core/httpcli/httpcli.c +13 -11
- data/src/core/httpcli/httpcli.h +3 -2
- data/src/core/httpcli/httpcli_security_connector.c +7 -7
- data/src/core/iomgr/fd_posix.c +4 -2
- data/src/core/iomgr/iocp_windows.c +10 -6
- data/src/core/iomgr/iocp_windows.h +9 -2
- data/src/core/iomgr/iomgr.c +18 -2
- data/src/core/iomgr/iomgr_internal.h +5 -1
- data/src/core/iomgr/pollset.h +9 -10
- data/src/core/iomgr/pollset_multipoller_with_epoll.c +1 -0
- data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +10 -5
- data/src/core/iomgr/pollset_posix.c +30 -35
- data/src/core/iomgr/pollset_posix.h +10 -6
- data/src/core/iomgr/pollset_set.h +3 -9
- data/src/core/iomgr/pollset_set_posix.c +23 -3
- data/src/core/iomgr/pollset_set_posix.h +2 -18
- data/src/core/iomgr/pollset_set_windows.c +3 -3
- data/src/core/iomgr/pollset_set_windows.h +2 -2
- data/src/core/iomgr/pollset_windows.c +24 -21
- data/src/core/iomgr/pollset_windows.h +1 -5
- data/src/core/iomgr/tcp_client_posix.c +7 -5
- data/src/core/iomgr/tcp_posix.c +4 -2
- data/src/core/iomgr/tcp_server_windows.c +1 -2
- data/src/core/iomgr/timer.c +2 -3
- data/src/core/iomgr/timer.h +21 -1
- data/src/core/iomgr/timer_heap.c +10 -12
- data/src/core/iomgr/udp_server.c +5 -4
- data/src/core/iomgr/udp_server.h +1 -0
- data/src/core/iomgr/workqueue_posix.c +1 -0
- data/src/core/iomgr/workqueue_posix.h +3 -1
- data/src/core/proto/grpc/lb/v0/load_balancer.pb.c +119 -0
- data/src/core/proto/grpc/lb/v0/load_balancer.pb.h +182 -0
- data/src/core/security/{base64.c → b64.c} +1 -1
- data/src/core/security/{base64.h → b64.h} +1 -1
- data/src/core/security/client_auth_filter.c +0 -1
- data/src/core/security/credentials.c +12 -5
- data/src/core/security/credentials.h +3 -3
- data/src/core/security/google_default_credentials.c +24 -19
- data/src/core/security/handshake.c +15 -7
- data/src/core/security/handshake.h +2 -1
- data/src/core/security/json_token.c +1 -1
- data/src/core/security/jwt_verifier.c +1 -1
- data/src/core/security/security_connector.c +84 -64
- data/src/core/security/security_connector.h +42 -22
- data/src/core/security/security_context.c +8 -3
- data/src/core/security/server_auth_filter.c +2 -2
- data/src/core/security/server_secure_chttp2.c +7 -7
- data/src/core/support/avl.c +2 -2
- data/src/core/support/env_linux.c +17 -0
- data/src/core/support/{file.c → load_file.c} +2 -2
- data/src/core/support/{file.h → load_file.h} +4 -12
- data/src/core/support/sync.c +6 -1
- data/src/core/support/time_posix.c +1 -1
- data/src/core/{iomgr/timer_internal.h → support/tmpfile.h} +17 -23
- data/src/core/support/{file_posix.c → tmpfile_posix.c} +2 -2
- data/src/core/support/{file_win32.c → tmpfile_win32.c} +2 -2
- data/src/core/surface/alarm.c +3 -2
- data/src/core/surface/call.c +102 -52
- data/src/core/surface/channel_create.c +1 -1
- data/src/core/surface/completion_queue.c +73 -41
- data/src/core/surface/init.c +4 -0
- data/src/core/surface/lame_client.c +1 -2
- data/src/core/surface/secure_channel_create.c +6 -7
- data/src/core/surface/server.c +13 -5
- data/src/core/surface/validate_metadata.c +1 -1
- data/src/core/surface/version.c +1 -1
- data/src/core/transport/chttp2/internal.h +22 -10
- data/src/core/transport/chttp2/parsing.c +3 -3
- data/src/core/transport/chttp2/stream_lists.c +39 -21
- data/src/core/transport/chttp2/writing.c +19 -28
- data/src/core/transport/chttp2_transport.c +80 -37
- data/src/core/transport/metadata.c +8 -0
- data/src/core/transport/static_metadata.c +17 -17
- data/src/core/transport/static_metadata.h +3 -3
- data/src/core/transport/transport.c +2 -1
- data/src/core/transport/transport.h +12 -5
- data/src/ruby/ext/grpc/extconf.rb +1 -0
- data/src/ruby/ext/grpc/rb_call.c +6 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +12 -14
- data/src/ruby/ext/grpc/rb_channel.c +8 -14
- data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -12
- data/src/ruby/ext/grpc/rb_grpc.c +19 -18
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +8 -2
- data/src/ruby/lib/grpc/core/time_consts.rb +2 -2
- data/src/ruby/lib/grpc/errors.rb +2 -2
- data/src/ruby/lib/grpc/generic/rpc_server.rb +58 -39
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +2 -2
- data/src/ruby/pb/generate_proto_ruby.sh +2 -2
- data/src/ruby/pb/grpc/health/checker.rb +11 -11
- data/src/ruby/pb/grpc/health/v1/health.rb +28 -0
- data/src/ruby/pb/grpc/health/{v1alpha → v1}/health_services.rb +4 -4
- data/src/ruby/spec/client_server_spec.rb +2 -1
- data/src/ruby/spec/generic/rpc_server_spec.rb +3 -22
- data/src/ruby/spec/pb/health/checker_spec.rb +22 -36
- data/third_party/nanopb/pb.h +547 -0
- data/third_party/nanopb/pb_common.c +97 -0
- data/third_party/nanopb/pb_common.h +42 -0
- data/third_party/nanopb/pb_decode.c +1319 -0
- data/third_party/nanopb/pb_decode.h +149 -0
- data/third_party/nanopb/pb_encode.c +690 -0
- data/third_party/nanopb/pb_encode.h +154 -0
- metadata +32 -16
- data/src/ruby/pb/grpc/health/v1alpha/health.rb +0 -29
data/include/grpc/census.h
CHANGED
@@ -59,15 +59,15 @@ enum census_features {
|
|
59
59
|
* census_initialize() will return a non-zero value. It is an error to call
|
60
60
|
* census_initialize() more than once (without an intervening
|
61
61
|
* census_shutdown()). */
|
62
|
-
|
63
|
-
|
62
|
+
CENSUSAPI int census_initialize(int features);
|
63
|
+
CENSUSAPI void census_shutdown(void);
|
64
64
|
|
65
65
|
/** Return the features supported by the current census implementation (not all
|
66
66
|
* features will be available on all platforms). */
|
67
|
-
|
67
|
+
CENSUSAPI int census_supported(void);
|
68
68
|
|
69
69
|
/** Return the census features currently enabled. */
|
70
|
-
|
70
|
+
CENSUSAPI int census_enabled(void);
|
71
71
|
|
72
72
|
/**
|
73
73
|
A Census Context is a handle used by Census to represent the current tracing
|
@@ -80,18 +80,18 @@ CENSUS_API int census_enabled(void);
|
|
80
80
|
metrics will be recorded. Keys are unique within a context. */
|
81
81
|
typedef struct census_context census_context;
|
82
82
|
|
83
|
-
/* A tag is a key:value pair.
|
84
|
-
|
85
|
-
|
86
|
-
CENSUS_MAX_TAG_KB_LEN
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
and time in
|
83
|
+
/* A tag is a key:value pair. Both keys and values are nil-terminated strings,
|
84
|
+
containing printable ASCII characters (decimal 32-126). Keys must be at
|
85
|
+
least one character in length. Both keys and values can have at most
|
86
|
+
CENSUS_MAX_TAG_KB_LEN characters (including the terminating nil). The
|
87
|
+
maximum number of tags that can be propagated is
|
88
|
+
CENSUS_MAX_PROPAGATED_TAGS. Users should also remember that some systems
|
89
|
+
may have limits on, e.g., the number of bytes that can be transmitted as
|
90
|
+
metadata, and that larger tags means more memory consumed and time in
|
91
|
+
processing. */
|
91
92
|
typedef struct {
|
92
93
|
const char *key;
|
93
94
|
const char *value;
|
94
|
-
size_t value_len;
|
95
95
|
uint8_t flags;
|
96
96
|
} census_tag;
|
97
97
|
|
@@ -103,28 +103,25 @@ typedef struct {
|
|
103
103
|
/* Tag flags. */
|
104
104
|
#define CENSUS_TAG_PROPAGATE 1 /* Tag should be propagated over RPC */
|
105
105
|
#define CENSUS_TAG_STATS 2 /* Tag will be used for statistics aggregation */
|
106
|
-
#define
|
107
|
-
|
108
|
-
/* Flag values 8,16,32,64,128 are reserved for future/internal use. Clients
|
106
|
+
#define CENSUS_TAG_RESERVED 4 /* Reserved for internal use. */
|
107
|
+
/* Flag values 4,8,16,32,64,128 are reserved for future/internal use. Clients
|
109
108
|
should not use or rely on their values. */
|
110
109
|
|
111
110
|
#define CENSUS_TAG_IS_PROPAGATED(flags) (flags & CENSUS_TAG_PROPAGATE)
|
112
111
|
#define CENSUS_TAG_IS_STATS(flags) (flags & CENSUS_TAG_STATS)
|
113
|
-
#define CENSUS_TAG_IS_BINARY(flags) (flags & CENSUS_TAG_BINARY)
|
114
112
|
|
115
113
|
/* An instance of this structure is kept by every context, and records the
|
116
114
|
basic information associated with the creation of that context. */
|
117
115
|
typedef struct {
|
118
|
-
int n_propagated_tags;
|
119
|
-
int
|
120
|
-
int
|
121
|
-
int
|
122
|
-
int
|
123
|
-
int
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
CENSUS_MAX_PROPAGATED_TAGS limit. */
|
116
|
+
int n_propagated_tags; /* number of propagated tags */
|
117
|
+
int n_local_tags; /* number of non-propagated (local) tags */
|
118
|
+
int n_deleted_tags; /* number of tags that were deleted */
|
119
|
+
int n_added_tags; /* number of tags that were added */
|
120
|
+
int n_modified_tags; /* number of tags that were modified */
|
121
|
+
int n_invalid_tags; /* number of tags with bad keys or values (e.g.
|
122
|
+
longer than CENSUS_MAX_TAG_KV_LEN) */
|
123
|
+
int n_ignored_tags; /* number of tags ignored because of
|
124
|
+
CENSUS_MAX_PROPAGATED_TAGS limit. */
|
128
125
|
} census_context_status;
|
129
126
|
|
130
127
|
/* Create a new context, adding and removing tags from an existing context.
|
@@ -132,10 +129,10 @@ typedef struct {
|
|
132
129
|
to add as many tags in a single operation as is practical for the client.
|
133
130
|
@param base Base context to build upon. Can be NULL.
|
134
131
|
@param tags A set of tags to be added/changed/deleted. Tags with keys that
|
135
|
-
are in 'tags', but not 'base', are added to the
|
132
|
+
are in 'tags', but not 'base', are added to the context. Keys that are in
|
136
133
|
both 'tags' and 'base' will have their value/flags modified. Tags with keys
|
137
|
-
in both, but with NULL
|
138
|
-
|
134
|
+
in both, but with NULL values, will be deleted from the context. Tags with
|
135
|
+
invalid (too long or short) keys or values will be ignored.
|
139
136
|
If adding a tag will result in more than CENSUS_MAX_PROPAGATED_TAGS in either
|
140
137
|
binary or non-binary tags, they will be ignored, as will deletions of
|
141
138
|
tags that don't exist.
|
@@ -145,16 +142,16 @@ typedef struct {
|
|
145
142
|
tags used in its creation.
|
146
143
|
@return A new, valid census_context.
|
147
144
|
*/
|
148
|
-
|
145
|
+
CENSUSAPI census_context *census_context_create(
|
149
146
|
const census_context *base, const census_tag *tags, int ntags,
|
150
147
|
census_context_status const **status);
|
151
148
|
|
152
149
|
/* Destroy a context. Once this function has been called, the context cannot
|
153
150
|
be reused. */
|
154
|
-
|
151
|
+
CENSUSAPI void census_context_destroy(census_context *context);
|
155
152
|
|
156
153
|
/* Get a pointer to the original status from the context creation. */
|
157
|
-
|
154
|
+
CENSUSAPI const census_context_status *census_context_get_status(
|
158
155
|
const census_context *context);
|
159
156
|
|
160
157
|
/* Structure used for iterating over the tegs in a context. API clients should
|
@@ -168,50 +165,36 @@ typedef struct {
|
|
168
165
|
} census_context_iterator;
|
169
166
|
|
170
167
|
/* Initialize a census_tag_iterator. Must be called before first use. */
|
171
|
-
|
168
|
+
CENSUSAPI void census_context_initialize_iterator(
|
172
169
|
const census_context *context, census_context_iterator *iterator);
|
173
170
|
|
174
171
|
/* Get the contents of the "next" tag in the context. If there are no more
|
175
172
|
tags, returns 0 (and 'tag' contents will be unchanged), otherwise returns 1.
|
176
173
|
*/
|
177
|
-
|
178
|
-
|
174
|
+
CENSUSAPI int census_context_next_tag(census_context_iterator *iterator,
|
175
|
+
census_tag *tag);
|
179
176
|
|
180
177
|
/* Get a context tag by key. Returns 0 if the key is not present. */
|
181
|
-
|
182
|
-
|
178
|
+
CENSUSAPI int census_context_get_tag(const census_context *context,
|
179
|
+
const char *key, census_tag *tag);
|
183
180
|
|
184
181
|
/* Tag set encode/decode functionality. These functionas are intended
|
185
182
|
for use by RPC systems only, for purposes of transmitting/receiving contexts.
|
186
183
|
*/
|
187
184
|
|
188
|
-
/* Encode a context into a buffer.
|
189
|
-
buffer in two regions: one for printable tags, and one for binary tags.
|
185
|
+
/* Encode a context into a buffer.
|
190
186
|
@param context context to be encoded
|
191
|
-
@param buffer
|
192
|
-
printable tags.
|
187
|
+
@param buffer buffer into which the context will be encoded.
|
193
188
|
@param buf_size number of available bytes in buffer.
|
194
|
-
@
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
printable tags are encoded into
|
201
|
-
[buffer, buffer + *print_buf_size) and binary tags into
|
202
|
-
[returned-ptr, returned-ptr + *bin_buf_size) (and the returned
|
203
|
-
pointer should be buffer + *print_buf_size) */
|
204
|
-
CENSUS_API char *census_context_encode(const census_context *context,
|
205
|
-
char *buffer, size_t buf_size,
|
206
|
-
size_t *print_buf_size,
|
207
|
-
size_t *bin_buf_size);
|
208
|
-
|
209
|
-
/* Decode context buffers encoded with census_context_encode(). Returns NULL
|
189
|
+
@return The number of buffer bytes consumed for the encoded context, or
|
190
|
+
zero if the buffer was of insufficient size. */
|
191
|
+
CENSUSAPI size_t census_context_encode(const census_context *context,
|
192
|
+
char *buffer, size_t buf_size);
|
193
|
+
|
194
|
+
/* Decode context buffer encoded with census_context_encode(). Returns NULL
|
210
195
|
if there is an error in parsing either buffer. */
|
211
|
-
|
212
|
-
|
213
|
-
const char *bin_buffer,
|
214
|
-
size_t bin_size);
|
196
|
+
CENSUSAPI census_context *census_context_decode(const char *buffer,
|
197
|
+
size_t size);
|
215
198
|
|
216
199
|
/* Distributed traces can have a number of options. */
|
217
200
|
enum census_trace_mask_values {
|
@@ -221,10 +204,10 @@ enum census_trace_mask_values {
|
|
221
204
|
|
222
205
|
/** Get the current trace mask associated with this context. The value returned
|
223
206
|
will be the logical or of census_trace_mask_values values. */
|
224
|
-
|
207
|
+
CENSUSAPI int census_trace_mask(const census_context *context);
|
225
208
|
|
226
209
|
/** Set the trace mask associated with a context. */
|
227
|
-
|
210
|
+
CENSUSAPI void census_set_trace_mask(int trace_mask);
|
228
211
|
|
229
212
|
/* The concept of "operation" is a fundamental concept for Census. In an RPC
|
230
213
|
system, and operation typcially represents a single RPC, or a significant
|
@@ -272,7 +255,7 @@ typedef struct {
|
|
272
255
|
|
273
256
|
@return A timestamp representing the operation start time.
|
274
257
|
*/
|
275
|
-
|
258
|
+
CENSUSAPI census_timestamp census_start_rpc_op_timestamp(void);
|
276
259
|
|
277
260
|
/**
|
278
261
|
Represent functions to map RPC name ID to service/method names. Census
|
@@ -324,7 +307,7 @@ typedef struct {
|
|
324
307
|
|
325
308
|
@return A new census context.
|
326
309
|
*/
|
327
|
-
|
310
|
+
CENSUSAPI census_context *census_start_client_rpc_op(
|
328
311
|
const census_context *context, int64_t rpc_name_id,
|
329
312
|
const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask,
|
330
313
|
const census_timestamp *start_time);
|
@@ -332,8 +315,8 @@ CENSUS_API census_context *census_start_client_rpc_op(
|
|
332
315
|
/**
|
333
316
|
Add peer information to a context representing a client RPC operation.
|
334
317
|
*/
|
335
|
-
|
336
|
-
|
318
|
+
CENSUSAPI void census_set_rpc_client_peer(census_context *context,
|
319
|
+
const char *peer);
|
337
320
|
|
338
321
|
/**
|
339
322
|
Start a server RPC operation. Returns a new context to be used in future
|
@@ -353,7 +336,7 @@ CENSUS_API void census_set_rpc_client_peer(census_context *context,
|
|
353
336
|
|
354
337
|
@return A new census context.
|
355
338
|
*/
|
356
|
-
|
339
|
+
CENSUSAPI census_context *census_start_server_rpc_op(
|
357
340
|
const char *buffer, int64_t rpc_name_id,
|
358
341
|
const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask,
|
359
342
|
census_timestamp *start_time);
|
@@ -383,9 +366,9 @@ CENSUS_API census_context *census_start_server_rpc_op(
|
|
383
366
|
|
384
367
|
@return A new census context.
|
385
368
|
*/
|
386
|
-
|
387
|
-
|
388
|
-
|
369
|
+
CENSUSAPI census_context *census_start_op(census_context *context,
|
370
|
+
const char *family, const char *name,
|
371
|
+
int trace_mask);
|
389
372
|
|
390
373
|
/**
|
391
374
|
End an operation started by any of the census_start_*_op*() calls. The
|
@@ -396,7 +379,7 @@ CENSUS_API census_context *census_start_op(census_context *context,
|
|
396
379
|
@param status status associated with the operation. Not interpreted by
|
397
380
|
census.
|
398
381
|
*/
|
399
|
-
|
382
|
+
CENSUSAPI void census_end_op(census_context *context, int status);
|
400
383
|
|
401
384
|
#define CENSUS_TRACE_RECORD_START_OP ((uint32_t)0)
|
402
385
|
#define CENSUS_TRACE_RECORD_END_OP ((uint32_t)1)
|
@@ -408,8 +391,8 @@ CENSUS_API void census_end_op(census_context *context, int status);
|
|
408
391
|
@param buffer Pointer to buffer to use
|
409
392
|
@param n Number of bytes in buffer
|
410
393
|
*/
|
411
|
-
|
412
|
-
|
394
|
+
CENSUSAPI void census_trace_print(census_context *context, uint32_t type,
|
395
|
+
const char *buffer, size_t n);
|
413
396
|
|
414
397
|
/** Trace record. */
|
415
398
|
typedef struct {
|
@@ -430,7 +413,7 @@ typedef struct {
|
|
430
413
|
while scanning is ongoing.
|
431
414
|
@returns 0 on success, non-zero on failure (e.g. if a scan is already ongoing)
|
432
415
|
*/
|
433
|
-
|
416
|
+
CENSUSAPI int census_trace_scan_start(int consume);
|
434
417
|
|
435
418
|
/** Get a trace record. The data pointed to by the trace buffer is guaranteed
|
436
419
|
stable until the next census_get_trace_record() call (if the consume
|
@@ -441,10 +424,10 @@ CENSUS_API int census_trace_scan_start(int consume);
|
|
441
424
|
census_trace_scan_start()), 0 if there is no more trace data (and
|
442
425
|
trace_record will not be modified) or 1 otherwise.
|
443
426
|
*/
|
444
|
-
|
427
|
+
CENSUSAPI int census_get_trace_record(census_trace_record *trace_record);
|
445
428
|
|
446
429
|
/** End a scan previously started by census_trace_scan_start() */
|
447
|
-
|
430
|
+
CENSUSAPI void census_trace_scan_end();
|
448
431
|
|
449
432
|
/* Core stats collection API's. The following concepts are used:
|
450
433
|
* Aggregation: A collection of values. Census supports the following
|
@@ -475,8 +458,8 @@ typedef struct {
|
|
475
458
|
} census_value;
|
476
459
|
|
477
460
|
/* Record new usage values against the given context. */
|
478
|
-
|
479
|
-
|
461
|
+
CENSUSAPI void census_record_values(census_context *context,
|
462
|
+
census_value *values, size_t nvalues);
|
480
463
|
|
481
464
|
/** Type representing a particular aggregation */
|
482
465
|
typedef struct census_aggregation_ops census_aggregation_ops;
|
@@ -508,24 +491,24 @@ typedef struct census_view census_view;
|
|
508
491
|
|
509
492
|
/* TODO(aveitch): consider if context is the right argument type to pass in
|
510
493
|
tags. */
|
511
|
-
|
494
|
+
CENSUSAPI census_view *census_view_create(
|
512
495
|
uint32_t metric_id, const census_context *tags,
|
513
496
|
const census_aggregation *aggregations, size_t naggregations);
|
514
497
|
|
515
498
|
/** Destroy a previously created view. */
|
516
|
-
|
499
|
+
CENSUSAPI void census_view_delete(census_view *view);
|
517
500
|
|
518
501
|
/** Metric ID associated with a view */
|
519
|
-
|
502
|
+
CENSUSAPI size_t census_view_metric(const census_view *view);
|
520
503
|
|
521
504
|
/** Number of aggregations associated with view. */
|
522
|
-
|
505
|
+
CENSUSAPI size_t census_view_naggregations(const census_view *view);
|
523
506
|
|
524
507
|
/** Get tags associated with view. */
|
525
|
-
|
508
|
+
CENSUSAPI const census_context *census_view_tags(const census_view *view);
|
526
509
|
|
527
510
|
/** Get aggregation descriptors associated with a view. */
|
528
|
-
|
511
|
+
CENSUSAPI const census_aggregation *census_view_aggregrations(
|
529
512
|
const census_view *view);
|
530
513
|
|
531
514
|
/** Holds all the aggregation data for a particular view instantiation. Forms
|
@@ -545,11 +528,10 @@ typedef struct {
|
|
545
528
|
@param view View from which to get data.
|
546
529
|
@return Full set of data for all aggregations for the view.
|
547
530
|
*/
|
548
|
-
|
549
|
-
const census_view *view);
|
531
|
+
CENSUSAPI const census_view_data *census_view_get_data(const census_view *view);
|
550
532
|
|
551
533
|
/** Reset all view data to zero for the specified view */
|
552
|
-
|
534
|
+
CENSUSAPI void census_view_reset(census_view *view);
|
553
535
|
|
554
536
|
#ifdef __cplusplus
|
555
537
|
}
|
data/include/grpc/compression.h
CHANGED
@@ -46,33 +46,33 @@ extern "C" {
|
|
46
46
|
/** Parses the first \a name_length bytes of \a name as a
|
47
47
|
* grpc_compression_algorithm instance, updating \a algorithm. Returns 1 upon
|
48
48
|
* success, 0 otherwise. */
|
49
|
-
|
49
|
+
GRPCAPI int grpc_compression_algorithm_parse(
|
50
50
|
const char *name, size_t name_length,
|
51
51
|
grpc_compression_algorithm *algorithm);
|
52
52
|
|
53
53
|
/** Updates \a name with the encoding name corresponding to a valid \a
|
54
54
|
* algorithm. Returns 1 upon success, 0 otherwise. */
|
55
|
-
|
55
|
+
GRPCAPI int grpc_compression_algorithm_name(
|
56
56
|
grpc_compression_algorithm algorithm, char **name);
|
57
57
|
|
58
58
|
/** Returns the compression algorithm corresponding to \a level.
|
59
59
|
*
|
60
60
|
* It abort()s for unknown levels . */
|
61
|
-
|
61
|
+
GRPCAPI grpc_compression_algorithm
|
62
62
|
grpc_compression_algorithm_for_level(grpc_compression_level level);
|
63
63
|
|
64
|
-
|
64
|
+
GRPCAPI void grpc_compression_options_init(grpc_compression_options *opts);
|
65
65
|
|
66
66
|
/** Mark \a algorithm as enabled in \a opts. */
|
67
|
-
|
67
|
+
GRPCAPI void grpc_compression_options_enable_algorithm(
|
68
68
|
grpc_compression_options *opts, grpc_compression_algorithm algorithm);
|
69
69
|
|
70
70
|
/** Mark \a algorithm as disabled in \a opts. */
|
71
|
-
|
71
|
+
GRPCAPI void grpc_compression_options_disable_algorithm(
|
72
72
|
grpc_compression_options *opts, grpc_compression_algorithm algorithm);
|
73
73
|
|
74
74
|
/** Returns true if \a algorithm is marked as enabled in \a opts. */
|
75
|
-
|
75
|
+
GRPCAPI int grpc_compression_options_is_algorithm_enabled(
|
76
76
|
const grpc_compression_options *opts, grpc_compression_algorithm algorithm);
|
77
77
|
|
78
78
|
#ifdef __cplusplus
|
data/include/grpc/grpc.h
CHANGED
@@ -55,11 +55,11 @@ extern "C" {
|
|
55
55
|
* functionality lives in grpc_security.h.
|
56
56
|
*/
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
GRPCAPI void grpc_metadata_array_init(grpc_metadata_array *array);
|
59
|
+
GRPCAPI void grpc_metadata_array_destroy(grpc_metadata_array *array);
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
GRPCAPI void grpc_call_details_init(grpc_call_details *details);
|
62
|
+
GRPCAPI void grpc_call_details_destroy(grpc_call_details *details);
|
63
63
|
|
64
64
|
/** Registers a plugin to be initialized and destroyed with the library.
|
65
65
|
|
@@ -69,7 +69,7 @@ GRPC_API void grpc_call_details_destroy(grpc_call_details *details);
|
|
69
69
|
(and hence so will \a init and \a destroy).
|
70
70
|
It is safe to pass NULL to either argument. Plugins are destroyed in
|
71
71
|
the reverse order they were initialized. */
|
72
|
-
|
72
|
+
GRPCAPI void grpc_register_plugin(void (*init)(void), void (*destroy)(void));
|
73
73
|
|
74
74
|
/** Initialize the grpc library.
|
75
75
|
|
@@ -77,7 +77,7 @@ GRPC_API void grpc_register_plugin(void (*init)(void), void (*destroy)(void));
|
|
77
77
|
(To avoid overhead, little checking is done, and some things may work. We
|
78
78
|
do not warrant that they will continue to do so in future revisions of this
|
79
79
|
library). */
|
80
|
-
|
80
|
+
GRPCAPI void grpc_init(void);
|
81
81
|
|
82
82
|
/** Shut down the grpc library.
|
83
83
|
|
@@ -85,13 +85,13 @@ GRPC_API void grpc_init(void);
|
|
85
85
|
executing within the grpc library.
|
86
86
|
Prior to calling, all application owned grpc objects must have been
|
87
87
|
destroyed. */
|
88
|
-
|
88
|
+
GRPCAPI void grpc_shutdown(void);
|
89
89
|
|
90
90
|
/** Return a string representing the current version of grpc */
|
91
|
-
|
91
|
+
GRPCAPI const char *grpc_version_string(void);
|
92
92
|
|
93
93
|
/** Create a completion queue */
|
94
|
-
|
94
|
+
GRPCAPI grpc_completion_queue *grpc_completion_queue_create(void *reserved);
|
95
95
|
|
96
96
|
/** Blocks until an event is available, the completion queue is being shut down,
|
97
97
|
or deadline is reached.
|
@@ -101,9 +101,9 @@ GRPC_API grpc_completion_queue *grpc_completion_queue_create(void *reserved);
|
|
101
101
|
|
102
102
|
Callers must not call grpc_completion_queue_next and
|
103
103
|
grpc_completion_queue_pluck simultaneously on the same completion queue. */
|
104
|
-
|
105
|
-
|
106
|
-
|
104
|
+
GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
|
105
|
+
gpr_timespec deadline,
|
106
|
+
void *reserved);
|
107
107
|
|
108
108
|
/** Blocks until an event with tag 'tag' is available, the completion queue is
|
109
109
|
being shutdown or deadline is reached.
|
@@ -116,9 +116,9 @@ GRPC_API grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
|
|
116
116
|
|
117
117
|
Completion queues support a maximum of GRPC_MAX_COMPLETION_QUEUE_PLUCKERS
|
118
118
|
concurrently executing plucks at any time. */
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
GRPCAPI grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq,
|
120
|
+
void *tag, gpr_timespec deadline,
|
121
|
+
void *reserved);
|
122
122
|
|
123
123
|
/** Maximum number of outstanding grpc_completion_queue_pluck executions per
|
124
124
|
completion queue */
|
@@ -131,11 +131,11 @@ grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag,
|
|
131
131
|
|
132
132
|
After calling this function applications should ensure that no
|
133
133
|
NEW work is added to be published on this completion queue. */
|
134
|
-
|
134
|
+
GRPCAPI void grpc_completion_queue_shutdown(grpc_completion_queue *cq);
|
135
135
|
|
136
136
|
/** Destroy a completion queue. The caller must ensure that the queue is
|
137
137
|
drained and no threads are executing grpc_completion_queue_next */
|
138
|
-
|
138
|
+
GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue *cq);
|
139
139
|
|
140
140
|
/** Create a completion queue alarm instance associated to \a cq.
|
141
141
|
*
|
@@ -143,18 +143,18 @@ GRPC_API void grpc_completion_queue_destroy(grpc_completion_queue *cq);
|
|
143
143
|
* grpc_alarm_cancel), an event with tag \a tag will be added to \a cq. If the
|
144
144
|
* alarm expired, the event's success bit will be true, false otherwise (ie,
|
145
145
|
* upon cancellation). */
|
146
|
-
|
147
|
-
|
146
|
+
GRPCAPI grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq,
|
147
|
+
gpr_timespec deadline, void *tag);
|
148
148
|
|
149
149
|
/** Cancel a completion queue alarm. Calling this function over an alarm that
|
150
150
|
* has already fired has no effect. */
|
151
|
-
|
151
|
+
GRPCAPI void grpc_alarm_cancel(grpc_alarm *alarm);
|
152
152
|
|
153
153
|
/** Destroy the given completion queue alarm, cancelling it in the process. */
|
154
|
-
|
154
|
+
GRPCAPI void grpc_alarm_destroy(grpc_alarm *alarm);
|
155
155
|
|
156
156
|
/** Check the connectivity state of a channel. */
|
157
|
-
|
157
|
+
GRPCAPI grpc_connectivity_state
|
158
158
|
grpc_channel_check_connectivity_state(grpc_channel *channel,
|
159
159
|
int try_to_connect);
|
160
160
|
|
@@ -163,7 +163,7 @@ grpc_channel_check_connectivity_state(grpc_channel *channel,
|
|
163
163
|
tag will be enqueued on cq with success=1.
|
164
164
|
If deadline expires BEFORE the state is changed, tag will be enqueued on cq
|
165
165
|
with success=0. */
|
166
|
-
|
166
|
+
GRPCAPI void grpc_channel_watch_connectivity_state(
|
167
167
|
grpc_channel *channel, grpc_connectivity_state last_observed_state,
|
168
168
|
gpr_timespec deadline, grpc_completion_queue *cq, void *tag);
|
169
169
|
|
@@ -173,24 +173,23 @@ GRPC_API void grpc_channel_watch_connectivity_state(
|
|
173
173
|
If parent_call is non-NULL, it must be a server-side call. It will be used
|
174
174
|
to propagate properties from the server call to this new client call.
|
175
175
|
*/
|
176
|
-
|
176
|
+
GRPCAPI grpc_call *grpc_channel_create_call(
|
177
177
|
grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
|
178
178
|
grpc_completion_queue *completion_queue, const char *method,
|
179
179
|
const char *host, gpr_timespec deadline, void *reserved);
|
180
180
|
|
181
181
|
/** Ping the channels peer (load balanced channels will select one sub-channel
|
182
182
|
to ping); if the channel is not connected, posts a failed. */
|
183
|
-
|
184
|
-
|
185
|
-
void *reserved);
|
183
|
+
GRPCAPI void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq,
|
184
|
+
void *tag, void *reserved);
|
186
185
|
|
187
186
|
/** Pre-register a method/host pair on a channel. */
|
188
|
-
|
189
|
-
|
190
|
-
|
187
|
+
GRPCAPI void *grpc_channel_register_call(grpc_channel *channel,
|
188
|
+
const char *method, const char *host,
|
189
|
+
void *reserved);
|
191
190
|
|
192
191
|
/** Create a call given a handle returned from grpc_channel_register_call */
|
193
|
-
|
192
|
+
GRPCAPI grpc_call *grpc_channel_create_registered_call(
|
194
193
|
grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
|
195
194
|
grpc_completion_queue *completion_queue, void *registered_call_handle,
|
196
195
|
gpr_timespec deadline, void *reserved);
|
@@ -206,9 +205,9 @@ GRPC_API grpc_call *grpc_channel_create_registered_call(
|
|
206
205
|
needs to be synchronized. As an optimization, you may synchronize batches
|
207
206
|
containing just send operations independently from batches containing just
|
208
207
|
receive operations. */
|
209
|
-
|
210
|
-
|
211
|
-
|
208
|
+
GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call *call,
|
209
|
+
const grpc_op *ops, size_t nops,
|
210
|
+
void *tag, void *reserved);
|
212
211
|
|
213
212
|
/** Returns a newly allocated string representing the endpoint to which this
|
214
213
|
call is communicating with. The string is in the uri format accepted by
|
@@ -218,36 +217,36 @@ GRPC_API grpc_call_error grpc_call_start_batch(grpc_call *call,
|
|
218
217
|
WARNING: this value is never authenticated or subject to any security
|
219
218
|
related code. It must not be used for any authentication related
|
220
219
|
functionality. Instead, use grpc_auth_context. */
|
221
|
-
|
220
|
+
GRPCAPI char *grpc_call_get_peer(grpc_call *call);
|
222
221
|
|
223
222
|
struct census_context;
|
224
223
|
|
225
224
|
/* Set census context for a call; Must be called before first call to
|
226
225
|
grpc_call_start_batch(). */
|
227
|
-
|
228
|
-
|
226
|
+
GRPCAPI void grpc_census_call_set_context(grpc_call *call,
|
227
|
+
struct census_context *context);
|
229
228
|
|
230
229
|
/* Retrieve the calls current census context. */
|
231
|
-
|
230
|
+
GRPCAPI struct census_context *grpc_census_call_get_context(grpc_call *call);
|
232
231
|
|
233
232
|
/** Return a newly allocated string representing the target a channel was
|
234
233
|
created for. */
|
235
|
-
|
234
|
+
GRPCAPI char *grpc_channel_get_target(grpc_channel *channel);
|
236
235
|
|
237
236
|
/** Create a client channel to 'target'. Additional channel level configuration
|
238
237
|
MAY be provided by grpc_channel_args, though the expectation is that most
|
239
238
|
clients will want to simply pass NULL. See grpc_channel_args definition for
|
240
239
|
more on this. The data in 'args' need only live through the invocation of
|
241
240
|
this function. */
|
242
|
-
|
241
|
+
GRPCAPI grpc_channel *grpc_insecure_channel_create(
|
243
242
|
const char *target, const grpc_channel_args *args, void *reserved);
|
244
243
|
|
245
244
|
/** Create a lame client: this client fails every operation attempted on it. */
|
246
|
-
|
245
|
+
GRPCAPI grpc_channel *grpc_lame_client_channel_create(
|
247
246
|
const char *target, grpc_status_code error_code, const char *error_message);
|
248
247
|
|
249
248
|
/** Close and destroy a grpc channel */
|
250
|
-
|
249
|
+
GRPCAPI void grpc_channel_destroy(grpc_channel *channel);
|
251
250
|
|
252
251
|
/* Error handling for grpc_call
|
253
252
|
Most grpc_call functions return a grpc_error. If the error is not GRPC_OK
|
@@ -260,7 +259,7 @@ GRPC_API void grpc_channel_destroy(grpc_channel *channel);
|
|
260
259
|
THREAD-SAFETY grpc_call_cancel and grpc_call_cancel_with_status
|
261
260
|
are thread-safe, and can be called at any point before grpc_call_destroy
|
262
261
|
is called.*/
|
263
|
-
|
262
|
+
GRPCAPI grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved);
|
264
263
|
|
265
264
|
/** Called by clients to cancel an RPC on the server.
|
266
265
|
Can be called multiple times, from any thread.
|
@@ -268,13 +267,13 @@ GRPC_API grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved);
|
|
268
267
|
and description passed in.
|
269
268
|
Importantly, this function does not send status nor description to the
|
270
269
|
remote endpoint. */
|
271
|
-
|
270
|
+
GRPCAPI grpc_call_error
|
272
271
|
grpc_call_cancel_with_status(grpc_call *call, grpc_status_code status,
|
273
272
|
const char *description, void *reserved);
|
274
273
|
|
275
274
|
/** Destroy a call.
|
276
275
|
THREAD SAFETY: grpc_call_destroy is thread-compatible */
|
277
|
-
|
276
|
+
GRPCAPI void grpc_call_destroy(grpc_call *call);
|
278
277
|
|
279
278
|
/** Request notification of a new call.
|
280
279
|
Once a call is received, a notification tagged with \a tag_new is added to
|
@@ -284,7 +283,7 @@ GRPC_API void grpc_call_destroy(grpc_call *call);
|
|
284
283
|
to \a cq_bound_to_call.
|
285
284
|
Note that \a cq_for_notification must have been registered to the server via
|
286
285
|
\a grpc_server_register_completion_queue. */
|
287
|
-
|
286
|
+
GRPCAPI grpc_call_error
|
288
287
|
grpc_server_request_call(grpc_server *server, grpc_call **call,
|
289
288
|
grpc_call_details *details,
|
290
289
|
grpc_metadata_array *request_metadata,
|
@@ -299,14 +298,13 @@ grpc_server_request_call(grpc_server *server, grpc_call **call,
|
|
299
298
|
registered_method (as returned by this function).
|
300
299
|
Must be called before grpc_server_start.
|
301
300
|
Returns NULL on failure. */
|
302
|
-
|
303
|
-
|
304
|
-
const char *host);
|
301
|
+
GRPCAPI void *grpc_server_register_method(grpc_server *server,
|
302
|
+
const char *method, const char *host);
|
305
303
|
|
306
304
|
/** Request notification of a new pre-registered call. 'cq_for_notification'
|
307
305
|
must have been registered to the server via
|
308
306
|
grpc_server_register_completion_queue. */
|
309
|
-
|
307
|
+
GRPCAPI grpc_call_error grpc_server_request_registered_call(
|
310
308
|
grpc_server *server, void *registered_method, grpc_call **call,
|
311
309
|
gpr_timespec *deadline, grpc_metadata_array *request_metadata,
|
312
310
|
grpc_byte_buffer **optional_payload,
|
@@ -317,25 +315,25 @@ GRPC_API grpc_call_error grpc_server_request_registered_call(
|
|
317
315
|
be specified with args. If no additional configuration is needed, args can
|
318
316
|
be NULL. See grpc_channel_args for more. The data in 'args' need only live
|
319
317
|
through the invocation of this function. */
|
320
|
-
|
321
|
-
|
318
|
+
GRPCAPI grpc_server *grpc_server_create(const grpc_channel_args *args,
|
319
|
+
void *reserved);
|
322
320
|
|
323
321
|
/** Register a completion queue with the server. Must be done for any
|
324
322
|
notification completion queue that is passed to grpc_server_request_*_call
|
325
323
|
and to grpc_server_shutdown_and_notify. Must be performed prior to
|
326
324
|
grpc_server_start. */
|
327
|
-
|
328
|
-
|
329
|
-
|
325
|
+
GRPCAPI void grpc_server_register_completion_queue(grpc_server *server,
|
326
|
+
grpc_completion_queue *cq,
|
327
|
+
void *reserved);
|
330
328
|
|
331
329
|
/** Add a HTTP2 over plaintext over tcp listener.
|
332
330
|
Returns bound port number on success, 0 on failure.
|
333
331
|
REQUIRES: server not started */
|
334
|
-
|
335
|
-
|
332
|
+
GRPCAPI int grpc_server_add_insecure_http2_port(grpc_server *server,
|
333
|
+
const char *addr);
|
336
334
|
|
337
335
|
/** Start a server - tells all listeners to start listening */
|
338
|
-
|
336
|
+
GRPCAPI void grpc_server_start(grpc_server *server);
|
339
337
|
|
340
338
|
/** Begin shutting down a server.
|
341
339
|
After completion, no new calls or connections will be admitted.
|
@@ -344,19 +342,19 @@ GRPC_API void grpc_server_start(grpc_server *server);
|
|
344
342
|
Shutdown is idempotent, and all tags will be notified at once if multiple
|
345
343
|
grpc_server_shutdown_and_notify calls are made. 'cq' must have been
|
346
344
|
registered to this server via grpc_server_register_completion_queue. */
|
347
|
-
|
348
|
-
|
349
|
-
|
345
|
+
GRPCAPI void grpc_server_shutdown_and_notify(grpc_server *server,
|
346
|
+
grpc_completion_queue *cq,
|
347
|
+
void *tag);
|
350
348
|
|
351
349
|
/** Cancel all in-progress calls.
|
352
350
|
Only usable after shutdown. */
|
353
|
-
|
351
|
+
GRPCAPI void grpc_server_cancel_all_calls(grpc_server *server);
|
354
352
|
|
355
353
|
/** Destroy a server.
|
356
354
|
Shutdown must have completed beforehand (i.e. all tags generated by
|
357
355
|
grpc_server_shutdown_and_notify must have been received, and at least
|
358
356
|
one call to grpc_server_shutdown_and_notify must have been made). */
|
359
|
-
|
357
|
+
GRPCAPI void grpc_server_destroy(grpc_server *server);
|
360
358
|
|
361
359
|
/** Enable or disable a tracer.
|
362
360
|
|
@@ -366,18 +364,17 @@ GRPC_API void grpc_server_destroy(grpc_server *server);
|
|
366
364
|
|
367
365
|
Use of this function is not strictly thread-safe, but the
|
368
366
|
thread-safety issues raised by it should not be of concern. */
|
369
|
-
|
367
|
+
GRPCAPI int grpc_tracer_set_enabled(const char *name, int enabled);
|
370
368
|
|
371
369
|
/** Check whether a metadata key is legal (will be accepted by core) */
|
372
|
-
|
370
|
+
GRPCAPI int grpc_header_key_is_legal(const char *key, size_t length);
|
373
371
|
|
374
372
|
/** Check whether a non-binary metadata value is legal (will be accepted by
|
375
373
|
core) */
|
376
|
-
|
377
|
-
size_t length);
|
374
|
+
GRPCAPI int grpc_header_nonbin_value_is_legal(const char *value, size_t length);
|
378
375
|
|
379
376
|
/** Check whether a metadata key corresponds to a binary value */
|
380
|
-
|
377
|
+
GRPCAPI int grpc_is_binary_header(const char *key, size_t length);
|
381
378
|
|
382
379
|
#ifdef __cplusplus
|
383
380
|
}
|