grpc.pxi 26 KB

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