| 1 |
# Copyright 2015 gRPC authors. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
cimport libc.time |
| 16 |
|
| 17 |
ctypedef ssize_t intptr_t |
| 18 |
ctypedef size_t uintptr_t |
| 19 |
ctypedef signed char int8_t |
| 20 |
ctypedef signed short int16_t |
| 21 |
ctypedef signed int int32_t |
| 22 |
ctypedef signed long long int64_t |
| 23 |
ctypedef unsigned char uint8_t |
| 24 |
ctypedef unsigned short uint16_t |
| 25 |
ctypedef unsigned int uint32_t |
| 26 |
ctypedef unsigned long long uint64_t |
| 27 |
|
| 28 |
# C++ Utilities |
| 29 |
|
| 30 |
# NOTE(lidiz) Unfortunately, we can't use "cimport" here because Cython |
| 31 |
# links it with exception handling. It introduces new dependencies. |
| 32 |
cdef extern from "<queue>" namespace "std" nogil: |
| 33 |
cdef cppclass queue[T]: |
| 34 |
queue() |
| 35 |
bint empty() |
| 36 |
T& front() |
| 37 |
T& back() |
| 38 |
void pop() |
| 39 |
void push(T&) |
| 40 |
size_t size() |
| 41 |
|
| 42 |
|
| 43 |
cdef extern from "<mutex>" namespace "std" nogil: |
| 44 |
cdef cppclass mutex: |
| 45 |
mutex() |
| 46 |
void lock() |
| 47 |
void unlock() |
| 48 |
|
| 49 |
cdef cppclass unique_lock[Mutex]: |
| 50 |
unique_lock(Mutex&) |
| 51 |
|
| 52 |
cdef extern from "<condition_variable>" namespace "std" nogil: |
| 53 |
cdef cppclass condition_variable: |
| 54 |
condition_variable() |
| 55 |
void notify_all() |
| 56 |
void wait(unique_lock[mutex]&) |
| 57 |
|
| 58 |
# gRPC Core Declarations |
| 59 |
|
| 60 |
cdef extern from "grpc/support/alloc.h": |
| 61 |
|
| 62 |
void *gpr_malloc(size_t size) nogil |
| 63 |
void *gpr_zalloc(size_t size) nogil |
| 64 |
void gpr_free(void *ptr) nogil |
| 65 |
void *gpr_realloc(void *p, size_t size) nogil |
| 66 |
|
| 67 |
|
| 68 |
cdef extern from "grpc/byte_buffer_reader.h": |
| 69 |
|
| 70 |
struct grpc_byte_buffer_reader: |
| 71 |
# We don't care about the internals |
| 72 |
pass |
| 73 |
|
| 74 |
|
| 75 |
cdef extern from "grpc/impl/codegen/grpc_types.h": |
| 76 |
ctypedef struct grpc_completion_queue_functor: |
| 77 |
void (*functor_run)(grpc_completion_queue_functor*, int); |
| 78 |
|
| 79 |
|
| 80 |
cdef extern from "grpc/grpc.h": |
| 81 |
|
| 82 |
ctypedef struct grpc_slice: |
| 83 |
# don't worry about writing out the members of grpc_slice; we never access |
| 84 |
# them directly. |
| 85 |
pass |
| 86 |
|
| 87 |
grpc_slice grpc_slice_ref(grpc_slice s) nogil |
| 88 |
void grpc_slice_unref(grpc_slice s) nogil |
| 89 |
grpc_slice grpc_empty_slice() nogil |
| 90 |
grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)) nogil |
| 91 |
grpc_slice grpc_slice_new_with_len( |
| 92 |
void *p, size_t len, void (*destroy)(void *, size_t)) nogil |
| 93 |
grpc_slice grpc_slice_malloc(size_t length) nogil |
| 94 |
grpc_slice grpc_slice_from_copied_string(const char *source) nogil |
| 95 |
grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len) nogil |
| 96 |
grpc_slice grpc_slice_copy(grpc_slice s) nogil |
| 97 |
|
| 98 |
# Declare functions for function-like macros (because Cython)... |
| 99 |
void *grpc_slice_start_ptr "GRPC_SLICE_START_PTR" (grpc_slice s) nogil |
| 100 |
size_t grpc_slice_length "GRPC_SLICE_LENGTH" (grpc_slice s) nogil |
| 101 |
|
| 102 |
const int GPR_MS_PER_SEC |
| 103 |
const int GPR_US_PER_SEC |
| 104 |
const int GPR_NS_PER_SEC |
| 105 |
|
| 106 |
ctypedef enum gpr_clock_type: |
| 107 |
GPR_CLOCK_MONOTONIC |
| 108 |
GPR_CLOCK_REALTIME |
| 109 |
GPR_CLOCK_PRECISE |
| 110 |
GPR_TIMESPAN |
| 111 |
|
| 112 |
ctypedef struct gpr_timespec: |
| 113 |
int64_t seconds "tv_sec" |
| 114 |
int32_t nanoseconds "tv_nsec" |
| 115 |
gpr_clock_type clock_type |
| 116 |
|
| 117 |
gpr_timespec gpr_time_0(gpr_clock_type type) nogil |
| 118 |
gpr_timespec gpr_inf_future(gpr_clock_type type) nogil |
| 119 |
gpr_timespec gpr_inf_past(gpr_clock_type type) nogil |
| 120 |
|
| 121 |
gpr_timespec gpr_now(gpr_clock_type clock) nogil |
| 122 |
|
| 123 |
gpr_timespec gpr_convert_clock_type(gpr_timespec t, |
| 124 |
gpr_clock_type target_clock) nogil |
| 125 |
|
| 126 |
gpr_timespec gpr_time_from_millis(int64_t ms, gpr_clock_type type) nogil |
| 127 |
gpr_timespec gpr_time_from_nanos(int64_t ns, gpr_clock_type type) nogil |
| 128 |
double gpr_timespec_to_micros(gpr_timespec t) nogil |
| 129 |
|
| 130 |
gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b) nogil |
| 131 |
|
| 132 |
int gpr_time_cmp(gpr_timespec a, gpr_timespec b) nogil |
| 133 |
|
| 134 |
ctypedef struct grpc_byte_buffer: |
| 135 |
# We don't care about the internals. |
| 136 |
pass |
| 137 |
|
| 138 |
grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices, |
| 139 |
size_t nslices) nogil |
| 140 |
size_t grpc_byte_buffer_length(grpc_byte_buffer *bb) nogil |
| 141 |
void grpc_byte_buffer_destroy(grpc_byte_buffer *byte_buffer) nogil |
| 142 |
|
| 143 |
int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader, |
| 144 |
grpc_byte_buffer *buffer) nogil |
| 145 |
int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, |
| 146 |
grpc_slice *slice) nogil |
| 147 |
void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader) nogil |
| 148 |
|
| 149 |
ctypedef enum grpc_status_code: |
| 150 |
GRPC_STATUS_OK |
| 151 |
GRPC_STATUS_CANCELLED |
| 152 |
GRPC_STATUS_UNKNOWN |
| 153 |
GRPC_STATUS_INVALID_ARGUMENT |
| 154 |
GRPC_STATUS_DEADLINE_EXCEEDED |
| 155 |
GRPC_STATUS_NOT_FOUND |
| 156 |
GRPC_STATUS_ALREADY_EXISTS |
| 157 |
GRPC_STATUS_PERMISSION_DENIED |
| 158 |
GRPC_STATUS_UNAUTHENTICATED |
| 159 |
GRPC_STATUS_RESOURCE_EXHAUSTED |
| 160 |
GRPC_STATUS_FAILED_PRECONDITION |
| 161 |
GRPC_STATUS_ABORTED |
| 162 |
GRPC_STATUS_OUT_OF_RANGE |
| 163 |
GRPC_STATUS_UNIMPLEMENTED |
| 164 |
GRPC_STATUS_INTERNAL |
| 165 |
GRPC_STATUS_UNAVAILABLE |
| 166 |
GRPC_STATUS_DATA_LOSS |
| 167 |
GRPC_STATUS__DO_NOT_USE |
| 168 |
|
| 169 |
const char *GRPC_ARG_ENABLE_CENSUS |
| 170 |
const char *GRPC_ARG_MAX_CONCURRENT_STREAMS |
| 171 |
const char *GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH |
| 172 |
const char *GRPC_ARG_MAX_SEND_MESSAGE_LENGTH |
| 173 |
const char *GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER |
| 174 |
const char *GRPC_ARG_DEFAULT_AUTHORITY |
| 175 |
const char *GRPC_ARG_PRIMARY_USER_AGENT_STRING |
| 176 |
const char *GRPC_ARG_SECONDARY_USER_AGENT_STRING |
| 177 |
const char *GRPC_SSL_TARGET_NAME_OVERRIDE_ARG |
| 178 |
const char *GRPC_SSL_SESSION_CACHE_ARG |
| 179 |
const char *_GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM \ |
| 180 |
"GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM" |
| 181 |
const char *GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL |
| 182 |
const char *GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET |
| 183 |
|
| 184 |
const int GRPC_WRITE_BUFFER_HINT |
| 185 |
const int GRPC_WRITE_NO_COMPRESS |
| 186 |
const int GRPC_WRITE_USED_MASK |
| 187 |
|
| 188 |
const int GRPC_INITIAL_METADATA_WAIT_FOR_READY |
| 189 |
const int GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET |
| 190 |
const int GRPC_INITIAL_METADATA_USED_MASK |
| 191 |
|
| 192 |
const int GRPC_MAX_COMPLETION_QUEUE_PLUCKERS |
| 193 |
|
| 194 |
ctypedef struct grpc_completion_queue: |
| 195 |
# We don't care about the internals (and in fact don't know them) |
| 196 |
pass |
| 197 |
|
| 198 |
ctypedef struct grpc_channel: |
| 199 |
# We don't care about the internals (and in fact don't know them) |
| 200 |
pass |
| 201 |
|
| 202 |
ctypedef struct grpc_server: |
| 203 |
# We don't care about the internals (and in fact don't know them) |
| 204 |
pass |
| 205 |
|
| 206 |
ctypedef struct grpc_call: |
| 207 |
# We don't care about the internals (and in fact don't know them) |
| 208 |
pass |
| 209 |
|
| 210 |
ctypedef enum grpc_arg_type: |
| 211 |
GRPC_ARG_STRING |
| 212 |
GRPC_ARG_INTEGER |
| 213 |
GRPC_ARG_POINTER |
| 214 |
|
| 215 |
ctypedef struct grpc_arg_pointer_vtable: |
| 216 |
void *(*copy)(void *) |
| 217 |
void (*destroy)(void *) |
| 218 |
int (*cmp)(void *, void *) |
| 219 |
|
| 220 |
ctypedef struct grpc_arg_value_pointer: |
| 221 |
void *address "p" |
| 222 |
grpc_arg_pointer_vtable *vtable |
| 223 |
|
| 224 |
union grpc_arg_value: |
| 225 |
char *string |
| 226 |
int integer |
| 227 |
grpc_arg_value_pointer pointer |
| 228 |
|
| 229 |
ctypedef struct grpc_arg: |
| 230 |
grpc_arg_type type |
| 231 |
char *key |
| 232 |
grpc_arg_value value |
| 233 |
|
| 234 |
ctypedef struct grpc_channel_args: |
| 235 |
size_t arguments_length "num_args" |
| 236 |
grpc_arg *arguments "args" |
| 237 |
|
| 238 |
ctypedef enum grpc_stream_compression_level: |
| 239 |
GRPC_STREAM_COMPRESS_LEVEL_NONE |
| 240 |
GRPC_STREAM_COMPRESS_LEVEL_LOW |
| 241 |
GRPC_STREAM_COMPRESS_LEVEL_MED |
| 242 |
GRPC_STREAM_COMPRESS_LEVEL_HIGH |
| 243 |
|
| 244 |
ctypedef enum grpc_call_error: |
| 245 |
GRPC_CALL_OK |
| 246 |
GRPC_CALL_ERROR |
| 247 |
GRPC_CALL_ERROR_NOT_ON_SERVER |
| 248 |
GRPC_CALL_ERROR_NOT_ON_CLIENT |
| 249 |
GRPC_CALL_ERROR_ALREADY_ACCEPTED |
| 250 |
GRPC_CALL_ERROR_ALREADY_INVOKED |
| 251 |
GRPC_CALL_ERROR_NOT_INVOKED |
| 252 |
GRPC_CALL_ERROR_ALREADY_FINISHED |
| 253 |
GRPC_CALL_ERROR_TOO_MANY_OPERATIONS |
| 254 |
GRPC_CALL_ERROR_INVALID_FLAGS |
| 255 |
GRPC_CALL_ERROR_INVALID_METADATA |
| 256 |
|
| 257 |
ctypedef enum grpc_cq_completion_type: |
| 258 |
GRPC_CQ_NEXT |
| 259 |
GRPC_CQ_PLUCK |
| 260 |
|
| 261 |
ctypedef enum grpc_cq_polling_type: |
| 262 |
GRPC_CQ_DEFAULT_POLLING |
| 263 |
GRPC_CQ_NON_LISTENING |
| 264 |
GRPC_CQ_NON_POLLING |
| 265 |
|
| 266 |
ctypedef struct grpc_completion_queue_attributes: |
| 267 |
int version |
| 268 |
grpc_cq_completion_type cq_completion_type |
| 269 |
grpc_cq_polling_type cq_polling_type |
| 270 |
void* cq_shutdown_cb |
| 271 |
|
| 272 |
ctypedef enum grpc_connectivity_state: |
| 273 |
GRPC_CHANNEL_IDLE |
| 274 |
GRPC_CHANNEL_CONNECTING |
| 275 |
GRPC_CHANNEL_READY |
| 276 |
GRPC_CHANNEL_TRANSIENT_FAILURE |
| 277 |
GRPC_CHANNEL_SHUTDOWN |
| 278 |
|
| 279 |
ctypedef struct grpc_metadata: |
| 280 |
grpc_slice key |
| 281 |
grpc_slice value |
| 282 |
# ignore the 'internal_data.obfuscated' fields. |
| 283 |
|
| 284 |
ctypedef enum grpc_completion_type: |
| 285 |
GRPC_QUEUE_SHUTDOWN |
| 286 |
GRPC_QUEUE_TIMEOUT |
| 287 |
GRPC_OP_COMPLETE |
| 288 |
|
| 289 |
ctypedef struct grpc_event: |
| 290 |
grpc_completion_type type |
| 291 |
int success |
| 292 |
void *tag |
| 293 |
|
| 294 |
ctypedef struct grpc_metadata_array: |
| 295 |
size_t count |
| 296 |
size_t capacity |
| 297 |
grpc_metadata *metadata |
| 298 |
|
| 299 |
void grpc_metadata_array_init(grpc_metadata_array *array) nogil |
| 300 |
void grpc_metadata_array_destroy(grpc_metadata_array *array) nogil |
| 301 |
|
| 302 |
ctypedef struct grpc_call_details: |
| 303 |
grpc_slice method |
| 304 |
grpc_slice host |
| 305 |
gpr_timespec deadline |
| 306 |
|
| 307 |
void grpc_call_details_init(grpc_call_details *details) nogil |
| 308 |
void grpc_call_details_destroy(grpc_call_details *details) nogil |
| 309 |
|
| 310 |
ctypedef enum grpc_op_type: |
| 311 |
GRPC_OP_SEND_INITIAL_METADATA |
| 312 |
GRPC_OP_SEND_MESSAGE |
| 313 |
GRPC_OP_SEND_CLOSE_FROM_CLIENT |
| 314 |
GRPC_OP_SEND_STATUS_FROM_SERVER |
| 315 |
GRPC_OP_RECV_INITIAL_METADATA |
| 316 |
GRPC_OP_RECV_MESSAGE |
| 317 |
GRPC_OP_RECV_STATUS_ON_CLIENT |
| 318 |
GRPC_OP_RECV_CLOSE_ON_SERVER |
| 319 |
|
| 320 |
ctypedef struct grpc_op_send_initial_metadata_maybe_compression_level: |
| 321 |
uint8_t is_set |
| 322 |
grpc_compression_level level |
| 323 |
|
| 324 |
ctypedef struct grpc_op_data_send_initial_metadata: |
| 325 |
size_t count |
| 326 |
grpc_metadata *metadata |
| 327 |
grpc_op_send_initial_metadata_maybe_compression_level maybe_compression_level |
| 328 |
|
| 329 |
ctypedef struct grpc_op_data_send_status_from_server: |
| 330 |
size_t trailing_metadata_count |
| 331 |
grpc_metadata *trailing_metadata |
| 332 |
grpc_status_code status |
| 333 |
grpc_slice *status_details |
| 334 |
|
| 335 |
ctypedef struct grpc_op_data_recv_status_on_client: |
| 336 |
grpc_metadata_array *trailing_metadata |
| 337 |
grpc_status_code *status |
| 338 |
grpc_slice *status_details |
| 339 |
char** error_string |
| 340 |
|
| 341 |
ctypedef struct grpc_op_data_recv_close_on_server: |
| 342 |
int *cancelled |
| 343 |
|
| 344 |
ctypedef struct grpc_op_data_send_message: |
| 345 |
grpc_byte_buffer *send_message |
| 346 |
|
| 347 |
ctypedef struct grpc_op_data_receive_message: |
| 348 |
grpc_byte_buffer **receive_message "recv_message" |
| 349 |
|
| 350 |
ctypedef struct grpc_op_data_receive_initial_metadata: |
| 351 |
grpc_metadata_array *receive_initial_metadata "recv_initial_metadata" |
| 352 |
|
| 353 |
union grpc_op_data: |
| 354 |
grpc_op_data_send_initial_metadata send_initial_metadata |
| 355 |
grpc_op_data_send_message send_message |
| 356 |
grpc_op_data_send_status_from_server send_status_from_server |
| 357 |
grpc_op_data_receive_initial_metadata receive_initial_metadata "recv_initial_metadata" |
| 358 |
grpc_op_data_receive_message receive_message "recv_message" |
| 359 |
grpc_op_data_recv_status_on_client receive_status_on_client "recv_status_on_client" |
| 360 |
grpc_op_data_recv_close_on_server receive_close_on_server "recv_close_on_server" |
| 361 |
|
| 362 |
ctypedef struct grpc_op: |
| 363 |
grpc_op_type type "op" |
| 364 |
uint32_t flags |
| 365 |
void * reserved |
| 366 |
grpc_op_data data |
| 367 |
|
| 368 |
void grpc_init() nogil |
| 369 |
void grpc_shutdown() nogil |
| 370 |
void grpc_shutdown_blocking() nogil |
| 371 |
int grpc_is_initialized() nogil |
| 372 |
|
| 373 |
ctypedef struct grpc_completion_queue_factory: |
| 374 |
pass |
| 375 |
|
| 376 |
grpc_completion_queue_factory *grpc_completion_queue_factory_lookup( |
| 377 |
const grpc_completion_queue_attributes* attributes) nogil |
| 378 |
grpc_completion_queue *grpc_completion_queue_create( |
| 379 |
const grpc_completion_queue_factory* factory, |
| 380 |
const grpc_completion_queue_attributes* attr, void* reserved) nogil |
| 381 |
grpc_completion_queue *grpc_completion_queue_create_for_next(void *reserved) nogil |
| 382 |
|
| 383 |
grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, |
| 384 |
gpr_timespec deadline, |
| 385 |
void *reserved) nogil |
| 386 |
grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag, |
| 387 |
gpr_timespec deadline, |
| 388 |
void *reserved) nogil |
| 389 |
void grpc_completion_queue_shutdown(grpc_completion_queue *cq) nogil |
| 390 |
void grpc_completion_queue_destroy(grpc_completion_queue *cq) nogil |
| 391 |
|
| 392 |
grpc_completion_queue *grpc_completion_queue_create_for_callback( |
| 393 |
grpc_completion_queue_functor* shutdown_callback, |
| 394 |
void *reserved) nogil |
| 395 |
|
| 396 |
grpc_call_error grpc_call_start_batch( |
| 397 |
grpc_call *call, const grpc_op *ops, size_t nops, void *tag, |
| 398 |
void *reserved) nogil |
| 399 |
grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved) nogil |
| 400 |
grpc_call_error grpc_call_cancel_with_status(grpc_call *call, |
| 401 |
grpc_status_code status, |
| 402 |
const char *description, |
| 403 |
void *reserved) nogil |
| 404 |
char *grpc_call_get_peer(grpc_call *call) nogil |
| 405 |
void grpc_call_unref(grpc_call *call) nogil |
| 406 |
|
| 407 |
grpc_call *grpc_channel_create_call( |
| 408 |
grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, |
| 409 |
grpc_completion_queue *completion_queue, grpc_slice method, |
| 410 |
const grpc_slice *host, gpr_timespec deadline, void *reserved) nogil |
| 411 |
grpc_connectivity_state grpc_channel_check_connectivity_state( |
| 412 |
grpc_channel *channel, int try_to_connect) nogil |
| 413 |
void grpc_channel_watch_connectivity_state( |
| 414 |
grpc_channel *channel, grpc_connectivity_state last_observed_state, |
| 415 |
gpr_timespec deadline, grpc_completion_queue *cq, void *tag) nogil |
| 416 |
char *grpc_channel_get_target(grpc_channel *channel) nogil |
| 417 |
void grpc_channel_destroy(grpc_channel *channel) nogil |
| 418 |
|
| 419 |
grpc_server *grpc_server_create( |
| 420 |
const grpc_channel_args *args, void *reserved) nogil |
| 421 |
grpc_call_error grpc_server_request_call( |
| 422 |
grpc_server *server, grpc_call **call, grpc_call_details *details, |
| 423 |
grpc_metadata_array *request_metadata, grpc_completion_queue |
| 424 |
*cq_bound_to_call, grpc_completion_queue *cq_for_notification, void |
| 425 |
*tag_new) nogil |
| 426 |
void grpc_server_register_completion_queue(grpc_server *server, |
| 427 |
grpc_completion_queue *cq, |
| 428 |
void *reserved) nogil |
| 429 |
|
| 430 |
ctypedef struct grpc_server_config_fetcher: |
| 431 |
pass |
| 432 |
|
| 433 |
void grpc_server_set_config_fetcher( |
| 434 |
grpc_server* server, grpc_server_config_fetcher* config_fetcher) nogil |
| 435 |
|
| 436 |
ctypedef struct grpc_server_xds_status_notifier: |
| 437 |
void (*on_serving_status_update)(void* user_data, const char* uri, |
| 438 |
grpc_status_code code, |
| 439 |
const char* error_message) |
| 440 |
void* user_data; |
| 441 |
|
| 442 |
grpc_server_config_fetcher* grpc_server_config_fetcher_xds_create( |
| 443 |
grpc_server_xds_status_notifier notifier, |
| 444 |
const grpc_channel_args* args) nogil |
| 445 |
|
| 446 |
|
| 447 |
void grpc_server_start(grpc_server *server) nogil |
| 448 |
void grpc_server_shutdown_and_notify( |
| 449 |
grpc_server *server, grpc_completion_queue *cq, void *tag) nogil |
| 450 |
void grpc_server_cancel_all_calls(grpc_server *server) nogil |
| 451 |
void grpc_server_destroy(grpc_server *server) nogil |
| 452 |
|
| 453 |
char* grpc_channelz_get_top_channels(intptr_t start_channel_id) |
| 454 |
char* grpc_channelz_get_servers(intptr_t start_server_id) |
| 455 |
char* grpc_channelz_get_server(intptr_t server_id) |
| 456 |
char* grpc_channelz_get_server_sockets(intptr_t server_id, |
| 457 |
intptr_t start_socket_id, |
| 458 |
intptr_t max_results) |
| 459 |
char* grpc_channelz_get_channel(intptr_t channel_id) |
| 460 |
char* grpc_channelz_get_subchannel(intptr_t subchannel_id) |
| 461 |
char* grpc_channelz_get_socket(intptr_t socket_id) |
| 462 |
|
| 463 |
grpc_slice grpc_dump_xds_configs() nogil |
| 464 |
|
| 465 |
|
| 466 |
cdef extern from "grpc/grpc_security.h": |
| 467 |
|
| 468 |
# Declare this as an enum, this is the only way to make it a const in |
| 469 |
# cython |
| 470 |
enum: GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX |
| 471 |
|
| 472 |
ctypedef enum grpc_ssl_roots_override_result: |
| 473 |
GRPC_SSL_ROOTS_OVERRIDE_OK |
| 474 |
GRPC_SSL_ROOTS_OVERRIDE_FAILED_PERMANENTLY |
| 475 |
GRPC_SSL_ROOTS_OVERRIDE_FAILED |
| 476 |
|
| 477 |
ctypedef enum grpc_ssl_client_certificate_request_type: |
| 478 |
GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, |
| 479 |
GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY |
| 480 |
GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY |
| 481 |
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY |
| 482 |
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY |
| 483 |
|
| 484 |
ctypedef enum grpc_security_level: |
| 485 |
GRPC_SECURITY_MIN |
| 486 |
GRPC_SECURITY_NONE = GRPC_SECURITY_MIN |
| 487 |
GRPC_INTEGRITY_ONLY |
| 488 |
GRPC_PRIVACY_AND_INTEGRITY |
| 489 |
GRPC_SECURITY_MAX = GRPC_PRIVACY_AND_INTEGRITY |
| 490 |
|
| 491 |
ctypedef enum grpc_ssl_certificate_config_reload_status: |
| 492 |
GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED |
| 493 |
GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW |
| 494 |
GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL |
| 495 |
|
| 496 |
ctypedef struct grpc_ssl_server_certificate_config: |
| 497 |
# We don't care about the internals |
| 498 |
pass |
| 499 |
|
| 500 |
ctypedef struct grpc_ssl_server_credentials_options: |
| 501 |
# We don't care about the internals |
| 502 |
pass |
| 503 |
|
| 504 |
grpc_ssl_server_certificate_config * grpc_ssl_server_certificate_config_create( |
| 505 |
const char *pem_root_certs, |
| 506 |
const grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, |
| 507 |
size_t num_key_cert_pairs) |
| 508 |
|
| 509 |
void grpc_ssl_server_certificate_config_destroy(grpc_ssl_server_certificate_config *config) |
| 510 |
|
| 511 |
ctypedef grpc_ssl_certificate_config_reload_status (*grpc_ssl_server_certificate_config_callback)( |
| 512 |
void *user_data, |
| 513 |
grpc_ssl_server_certificate_config **config) |
| 514 |
|
| 515 |
grpc_ssl_server_credentials_options *grpc_ssl_server_credentials_create_options_using_config( |
| 516 |
grpc_ssl_client_certificate_request_type client_certificate_request, |
| 517 |
grpc_ssl_server_certificate_config *certificate_config) |
| 518 |
|
| 519 |
grpc_ssl_server_credentials_options* grpc_ssl_server_credentials_create_options_using_config_fetcher( |
| 520 |
grpc_ssl_client_certificate_request_type client_certificate_request, |
| 521 |
grpc_ssl_server_certificate_config_callback cb, |
| 522 |
void *user_data) |
| 523 |
|
| 524 |
grpc_server_credentials *grpc_ssl_server_credentials_create_with_options( |
| 525 |
grpc_ssl_server_credentials_options *options) |
| 526 |
|
| 527 |
ctypedef struct grpc_ssl_pem_key_cert_pair: |
| 528 |
const char *private_key |
| 529 |
const char *certificate_chain "cert_chain" |
| 530 |
|
| 531 |
ctypedef struct grpc_channel_credentials: |
| 532 |
# We don't care about the internals (and in fact don't know them) |
| 533 |
pass |
| 534 |
|
| 535 |
ctypedef struct grpc_call_credentials: |
| 536 |
# We don't care about the internals (and in fact don't know them) |
| 537 |
pass |
| 538 |
|
| 539 |
ctypedef struct grpc_ssl_session_cache: |
| 540 |
# We don't care about the internals (and in fact don't know them) |
| 541 |
pass |
| 542 |
|
| 543 |
ctypedef struct verify_peer_options: |
| 544 |
# We don't care about the internals (and in fact don't know them) |
| 545 |
pass |
| 546 |
|
| 547 |
ctypedef void (*grpc_ssl_roots_override_callback)(char **pem_root_certs) |
| 548 |
|
| 549 |
grpc_ssl_session_cache *grpc_ssl_session_cache_create_lru(size_t capacity) |
| 550 |
void grpc_ssl_session_cache_destroy(grpc_ssl_session_cache* cache) |
| 551 |
|
| 552 |
void grpc_set_ssl_roots_override_callback( |
| 553 |
grpc_ssl_roots_override_callback cb) nogil |
| 554 |
|
| 555 |
grpc_channel_credentials *grpc_google_default_credentials_create(grpc_call_credentials* call_credentials) nogil |
| 556 |
grpc_channel_credentials *grpc_ssl_credentials_create( |
| 557 |
const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, |
| 558 |
verify_peer_options *verify_options, void *reserved) nogil |
| 559 |
grpc_channel_credentials *grpc_composite_channel_credentials_create( |
| 560 |
grpc_channel_credentials *creds1, grpc_call_credentials *creds2, |
| 561 |
void *reserved) nogil |
| 562 |
void grpc_channel_credentials_release(grpc_channel_credentials *creds) nogil |
| 563 |
|
| 564 |
grpc_channel_credentials *grpc_xds_credentials_create( |
| 565 |
grpc_channel_credentials *fallback_creds) nogil |
| 566 |
|
| 567 |
grpc_channel_credentials *grpc_insecure_credentials_create() nogil |
| 568 |
|
| 569 |
grpc_server_credentials *grpc_xds_server_credentials_create( |
| 570 |
grpc_server_credentials *fallback_creds) nogil |
| 571 |
|
| 572 |
grpc_server_credentials *grpc_insecure_server_credentials_create() nogil |
| 573 |
|
| 574 |
grpc_call_credentials *grpc_composite_call_credentials_create( |
| 575 |
grpc_call_credentials *creds1, grpc_call_credentials *creds2, |
| 576 |
void *reserved) nogil |
| 577 |
grpc_call_credentials *grpc_google_compute_engine_credentials_create( |
| 578 |
void *reserved) nogil |
| 579 |
grpc_call_credentials *grpc_service_account_jwt_access_credentials_create( |
| 580 |
const char *json_key, |
| 581 |
gpr_timespec token_lifetime, void *reserved) nogil |
| 582 |
grpc_call_credentials *grpc_google_refresh_token_credentials_create( |
| 583 |
const char *json_refresh_token, void *reserved) nogil |
| 584 |
grpc_call_credentials *grpc_google_iam_credentials_create( |
| 585 |
const char *authorization_token, const char *authority_selector, |
| 586 |
void *reserved) nogil |
| 587 |
void grpc_call_credentials_release(grpc_call_credentials *creds) nogil |
| 588 |
|
| 589 |
grpc_channel *grpc_channel_create( |
| 590 |
const char *target, grpc_channel_credentials *creds, |
| 591 |
const grpc_channel_args *args) nogil |
| 592 |
|
| 593 |
ctypedef struct grpc_server_credentials: |
| 594 |
# We don't care about the internals (and in fact don't know them) |
| 595 |
pass |
| 596 |
|
| 597 |
void grpc_server_credentials_release(grpc_server_credentials *creds) nogil |
| 598 |
|
| 599 |
int grpc_server_add_http2_port(grpc_server *server, const char *addr, |
| 600 |
grpc_server_credentials *creds) nogil |
| 601 |
|
| 602 |
grpc_call_error grpc_call_set_credentials(grpc_call *call, |
| 603 |
grpc_call_credentials *creds) nogil |
| 604 |
|
| 605 |
ctypedef struct grpc_auth_context: |
| 606 |
# We don't care about the internals (and in fact don't know them) |
| 607 |
pass |
| 608 |
|
| 609 |
ctypedef struct grpc_auth_metadata_context: |
| 610 |
const char *service_url |
| 611 |
const char *method_name |
| 612 |
const grpc_auth_context *channel_auth_context |
| 613 |
|
| 614 |
ctypedef void (*grpc_credentials_plugin_metadata_cb)( |
| 615 |
void *user_data, const grpc_metadata *creds_md, size_t num_creds_md, |
| 616 |
grpc_status_code status, const char *error_details) nogil |
| 617 |
|
| 618 |
ctypedef struct grpc_metadata_credentials_plugin: |
| 619 |
int (*get_metadata)( |
| 620 |
void *state, grpc_auth_metadata_context context, |
| 621 |
grpc_credentials_plugin_metadata_cb cb, void *user_data, |
| 622 |
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], |
| 623 |
size_t *num_creds_md, grpc_status_code *status, |
| 624 |
const char **error_details) except * |
| 625 |
void (*destroy)(void *state) except * |
| 626 |
void *state |
| 627 |
const char *type |
| 628 |
|
| 629 |
grpc_call_credentials *grpc_metadata_credentials_create_from_plugin( |
| 630 |
grpc_metadata_credentials_plugin plugin, grpc_security_level min_security_level, void *reserved) nogil |
| 631 |
|
| 632 |
ctypedef struct grpc_auth_property_iterator: |
| 633 |
pass |
| 634 |
|
| 635 |
ctypedef struct grpc_auth_property: |
| 636 |
char *name |
| 637 |
char *value |
| 638 |
size_t value_length |
| 639 |
|
| 640 |
grpc_auth_property *grpc_auth_property_iterator_next( |
| 641 |
grpc_auth_property_iterator *it) |
| 642 |
|
| 643 |
grpc_auth_property_iterator grpc_auth_context_property_iterator( |
| 644 |
const grpc_auth_context *ctx) |
| 645 |
|
| 646 |
grpc_auth_property_iterator grpc_auth_context_peer_identity( |
| 647 |
const grpc_auth_context *ctx) |
| 648 |
|
| 649 |
char *grpc_auth_context_peer_identity_property_name( |
| 650 |
const grpc_auth_context *ctx) |
| 651 |
|
| 652 |
grpc_auth_property_iterator grpc_auth_context_find_properties_by_name( |
| 653 |
const grpc_auth_context *ctx, const char *name) |
| 654 |
|
| 655 |
grpc_auth_context_peer_is_authenticated( |
| 656 |
const grpc_auth_context *ctx) |
| 657 |
|
| 658 |
grpc_auth_context *grpc_call_auth_context(grpc_call *call) |
| 659 |
|
| 660 |
void grpc_auth_context_release(grpc_auth_context *context) |
| 661 |
|
| 662 |
grpc_channel_credentials *grpc_local_credentials_create( |
| 663 |
grpc_local_connect_type type) |
| 664 |
grpc_server_credentials *grpc_local_server_credentials_create( |
| 665 |
grpc_local_connect_type type) |
| 666 |
|
| 667 |
ctypedef struct grpc_alts_credentials_options: |
| 668 |
# We don't care about the internals (and in fact don't know them) |
| 669 |
pass |
| 670 |
|
| 671 |
grpc_channel_credentials *grpc_alts_credentials_create( |
| 672 |
const grpc_alts_credentials_options *options) |
| 673 |
grpc_server_credentials *grpc_alts_server_credentials_create( |
| 674 |
const grpc_alts_credentials_options *options) |
| 675 |
|
| 676 |
grpc_alts_credentials_options* grpc_alts_credentials_client_options_create() |
| 677 |
grpc_alts_credentials_options* grpc_alts_credentials_server_options_create() |
| 678 |
void grpc_alts_credentials_options_destroy(grpc_alts_credentials_options *options) |
| 679 |
void grpc_alts_credentials_client_options_add_target_service_account(grpc_alts_credentials_options *options, const char *service_account) |
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
cdef extern from "grpc/compression.h": |
| 684 |
|
| 685 |
ctypedef enum grpc_compression_algorithm: |
| 686 |
GRPC_COMPRESS_NONE |
| 687 |
GRPC_COMPRESS_DEFLATE |
| 688 |
GRPC_COMPRESS_GZIP |
| 689 |
GRPC_COMPRESS_STREAM_GZIP |
| 690 |
GRPC_COMPRESS_ALGORITHMS_COUNT |
| 691 |
|
| 692 |
ctypedef enum grpc_compression_level: |
| 693 |
GRPC_COMPRESS_LEVEL_NONE |
| 694 |
GRPC_COMPRESS_LEVEL_LOW |
| 695 |
GRPC_COMPRESS_LEVEL_MED |
| 696 |
GRPC_COMPRESS_LEVEL_HIGH |
| 697 |
GRPC_COMPRESS_LEVEL_COUNT |
| 698 |
|
| 699 |
ctypedef struct grpc_compression_options: |
| 700 |
uint32_t enabled_algorithms_bitset |
| 701 |
|
| 702 |
int grpc_compression_algorithm_parse( |
| 703 |
grpc_slice value, grpc_compression_algorithm *algorithm) nogil |
| 704 |
int grpc_compression_algorithm_name(grpc_compression_algorithm algorithm, |
| 705 |
const char **name) nogil |
| 706 |
grpc_compression_algorithm grpc_compression_algorithm_for_level( |
| 707 |
grpc_compression_level level, uint32_t accepted_encodings) nogil |
| 708 |
void grpc_compression_options_init(grpc_compression_options *opts) nogil |
| 709 |
void grpc_compression_options_enable_algorithm( |
| 710 |
grpc_compression_options *opts, |
| 711 |
grpc_compression_algorithm algorithm) nogil |
| 712 |
void grpc_compression_options_disable_algorithm( |
| 713 |
grpc_compression_options *opts, |
| 714 |
grpc_compression_algorithm algorithm) nogil |
| 715 |
int grpc_compression_options_is_algorithm_enabled( |
| 716 |
const grpc_compression_options *opts, |
| 717 |
grpc_compression_algorithm algorithm) nogil |
| 718 |
|
| 719 |
cdef extern from "grpc/impl/codegen/compression_types.h": |
| 720 |
|
| 721 |
const char *_GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY \ |
| 722 |
"GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY" |
| 723 |
|
| 724 |
|
| 725 |
cdef extern from "grpc/grpc_security_constants.h": |
| 726 |
ctypedef enum grpc_local_connect_type: |
| 727 |
UDS |
| 728 |
LOCAL_TCP |