Go to the documentation of this file.
19 #include <ruby/ruby.h>
23 #include <ruby/thread.h>
123 op->
op.api_callback_args.called_back = 1;
124 op->
op.api_callback_args.success = success;
155 if (
ch->bg_wrapped != NULL) {
161 ch->bg_wrapped = NULL;
179 if (
channel->credentials != Qnil) {
180 rb_gc_mark(
channel->credentials);
191 #ifdef RUBY_TYPED_FREE_IMMEDIATELY
192 RUBY_TYPED_FREE_IMMEDIATELY
214 VALUE channel_args = Qnil;
215 VALUE credentials = Qnil;
220 char* target_chars = NULL;
223 int stop_waiting_for_thread_start = 0;
227 rb_thread_call_without_gvl(
229 &stop_waiting_for_thread_start,
231 &stop_waiting_for_thread_start);
234 rb_scan_args(argc, argv,
"3", &
target, &channel_args, &credentials);
237 target_chars = StringValueCStr(
target);
239 if (
TYPE(credentials) == T_SYMBOL) {
241 rb_raise(rb_eTypeError,
242 "bad creds symbol, want :this_channel_is_insecure");
250 wrapper->credentials = credentials;
256 rb_raise(rb_eTypeError,
257 "bad creds, want ChannelCredentials or XdsChannelCredentials");
266 rb_thread_call_without_gvl(
270 if (
args.args != NULL) {
274 rb_raise(rb_eRuntimeError,
"could not create an rpc channel to target:%s",
293 if (
stack->bg->channel_destroyed) {
297 stack->try_to_connect);
315 VALUE try_to_connect_param = Qfalse;
320 rb_scan_args(argc, argv,
"01", &try_to_connect_param);
323 if (
wrapper->bg_wrapped == NULL) {
324 rb_raise(rb_eRuntimeError,
"closed!");
329 stack.try_to_connect = RTEST(try_to_connect_param) ? 1 : 0;
332 return LONG2NUM(
stack.out);
344 void* success = (
void*)0;
359 while (!
op->
op.api_callback_args.called_back) {
363 if (
op->
op.api_callback_args.success) {
393 void* op_success = 0;
398 if (
wrapper->bg_wrapped == NULL) {
399 rb_raise(rb_eRuntimeError,
"closed!");
403 if (!FIXNUM_P(last_state)) {
406 "bad type for last_state. want a GRPC::Core::ChannelState constant");
412 stack.last_state = NUM2LONG(last_state);
414 op_success = rb_thread_call_without_gvl(
418 return op_success ? Qtrue : Qfalse;
435 char* tmp_str = NULL;
441 host_slice_ptr = &host_slice;
444 flags = NUM2UINT(mask);
446 if (parent != Qnil) {
451 if (
wrapper->bg_wrapped == NULL) {
452 rb_raise(rb_eRuntimeError,
"closed!");
460 flags,
cq, method_slice, host_slice_ptr,
467 rb_raise(rb_eRuntimeError,
"cannot create call with method %s", tmp_str);
472 if (host_slice_ptr != NULL) {
491 if (
wrapper->bg_wrapped != NULL) {
493 wrapper->bg_wrapped, NULL, NULL);
508 res = rb_str_new2(
target);
518 while (
cur != NULL) {
553 while (bg != NULL && bg->
next != NULL) {
572 stack->wrapper->bg_wrapped =
607 op->
op.continuous_watch_callback_args.bg = bg;
657 "GRPC_RUBY: run_poll_channels_loop_no_gil - exit connection polling "
669 "GRPC_RUBY: run_poll_channels_loop_unblocking_func - begin aborting "
670 "connection polling");
692 "GRPC_RUBY: run_poll_channels_loop_unblocking_func - end aborting "
693 "connection polling");
701 "GRPC_RUBY: run_poll_channels_loop - create connection polling thread");
710 int* stop_waiting = (
int*)
arg;
725 int* stop_waiting = (
int*)
arg;
728 "GRPC_RUBY: interrupt wait for channel polling thread to start");
754 VALUE background_thread = Qnil;
766 if (!RTEST(background_thread)) {
775 VALUE grpc_rb_mPropagateMasks =
777 rb_define_const(grpc_rb_mPropagateMasks,
"DEADLINE",
779 rb_define_const(grpc_rb_mPropagateMasks,
"CENSUS_STATS_CONTEXT",
781 rb_define_const(grpc_rb_mPropagateMasks,
"CENSUS_TRACING_CONTEXT",
783 rb_define_const(grpc_rb_mPropagateMasks,
"CANCELLATION",
785 rb_define_const(grpc_rb_mPropagateMasks,
"DEFAULTS",
791 VALUE grpc_rb_mConnectivityStates =
793 rb_define_const(grpc_rb_mConnectivityStates,
"IDLE",
795 rb_define_const(grpc_rb_mConnectivityStates,
"CONNECTING",
797 rb_define_const(grpc_rb_mConnectivityStates,
"READY",
799 rb_define_const(grpc_rb_mConnectivityStates,
"TRANSIENT_FAILURE",
801 rb_define_const(grpc_rb_mConnectivityStates,
"FATAL_FAILURE",
848 return wrapper->bg_wrapped->channel;
GPRAPI void grpc_slice_unref(grpc_slice s)
static void * get_state_without_gil(void *arg)
GPRAPI void gpr_mu_unlock(gpr_mu *mu)
static VALUE run_poll_channels_loop(VALUE arg)
static void run_poll_channels_loop_unblocking_func(void *arg)
static void * set_abort_channel_polling_without_gil(void *arg)
struct watch_state_op::@49::@50 api_callback_args
#define GRPC_RB_MEMSIZE_UNAVAILABLE
GRPCAPI grpc_completion_queue * grpc_completion_queue_create_for_pluck(void *reserved)
void grpc_rb_hash_convert_to_channel_args(VALUE src_hash, grpc_channel_args *dst)
void grpc_ruby_shutdown()
#define GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH
grpc_channel * grpc_rb_get_wrapped_channel(VALUE v)
struct channel_init_try_register_stack channel_init_try_register_stack
GRPCAPI grpc_connectivity_state grpc_channel_check_connectivity_state(grpc_channel *channel, int try_to_connect)
static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask, VALUE method, VALUE host, VALUE deadline)
GPRAPI void gpr_free(void *ptr)
union watch_state_op::@49 op
@ GRPC_CHANNEL_TRANSIENT_FAILURE
GRPCAPI char * grpc_channel_get_target(grpc_channel *channel)
#define GRPC_ARG_ENABLE_CENSUS
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
struct get_state_stack get_state_stack
static bg_watched_channel * bg_watched_channel_list_create_and_add(grpc_channel *channel)
struct watch_state_op watch_state_op
static int conn_state(BIO *bio, BIO_CONNECT *c)
GPRAPI void * gpr_zalloc(size_t size)
static void * wait_for_watch_state_op_complete_without_gvl(void *arg)
static void * wait_until_channel_polling_thread_started_no_gil(void *)
grpc_channel_credentials * grpc_rb_get_wrapped_channel_credentials(VALUE v)
void grpc_rb_channel_polling_thread_start()
bg_watched_channel * bg_wrapped
static void Init_grpc_propagate_masks()
wrapped_grpc_channel * channel
#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG
struct grpc_rb_channel grpc_rb_channel
static int channel_polling_thread_started
static VALUE grpc_rb_channel_destroy(VALUE self)
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
GPRAPI void gpr_mu_init(gpr_mu *mu)
static void * run_poll_channels_loop_no_gil(void *arg)
bool grpc_rb_is_channel_credentials(VALUE v)
static void wait_for_watch_state_op_complete_unblocking_func(void *arg)
struct grpc_call grpc_call
#define GRPC_PROPAGATE_CENSUS_STATS_CONTEXT
GRPCAPI grpc_channel_credentials * grpc_insecure_credentials_create()
static bg_watched_channel * bg_watched_channel_list_head
GPRAPI int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline)
GPRAPI void gpr_mu_lock(gpr_mu *mu)
static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self)
static VALUE grpc_rb_cChannel
static void grpc_rb_channel_mark(void *p)
static void Init_grpc_connectivity_states()
grpc_channel_wrapper * wrapper
static void grpc_rb_channel_watch_connection_state_op_complete(watch_state_op *op, int success)
static VALUE grpc_rb_cChannelArgs
static grpc_completion_queue * channel_polling_cq
static void grpc_rb_channel_free_internal(void *p)
static void bg_watched_channel_list_free_and_remove(bg_watched_channel *bg)
static VALUE grpc_rb_channel_get_target(VALUE self)
@ GRPC_CHANNEL_CONNECTING
grpc_rb_channel * wrapper
static VALUE grpc_rb_channel_alloc(VALUE cls)
GPRAPI char * grpc_slice_to_c_string(grpc_slice s)
GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials *creds)
GRPCAPI grpc_call * grpc_channel_create_call(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *completion_queue, grpc_slice method, const grpc_slice *host, gpr_timespec deadline, void *reserved)
static void grpc_rb_channel_free(void *p)
static void grpc_rb_channel_try_register_connection_polling(bg_watched_channel *bg)
grpc_channel_credentials * grpc_rb_get_wrapped_xds_channel_credentials(VALUE v)
GRPCAPI grpc_channel * grpc_channel_create(const char *target, grpc_channel_credentials *creds, const grpc_channel_args *args)
GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len)
static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv, VALUE self)
#define GRPC_PROPAGATE_DEFAULTS
static void wait_until_channel_polling_thread_started_unblocking_func(void *)
static VALUE id_insecure_channel
static void * channel_safe_destroy_without_gil(void *arg)
gpr_timespec grpc_rb_time_timeval(VALUE time, int interval)
GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue *cq)
struct watch_state_stack watch_state_stack
#define ALLOC(class_name)
VALUE grpc_rb_wrap_call(grpc_call *c, grpc_completion_queue *q)
VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self)
struct bg_watched_channel * next
#define GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT
static gpr_mu global_connection_polling_mu
static rb_data_type_t grpc_channel_data_type
GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved)
GRPCAPI void grpc_completion_queue_shutdown(grpc_completion_queue *cq)
GRPCAPI void grpc_channel_destroy(grpc_channel *channel)
static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, VALUE last_state, VALUE deadline)
void grpc_ruby_fork_guard()
static void grpc_rb_channel_safe_destroy(bg_watched_channel *bg)
struct grpc_channel grpc_channel
grpc_call * grpc_rb_get_wrapped_call(VALUE v)
GRPCAPI void grpc_channel_watch_connectivity_state(grpc_channel *channel, grpc_connectivity_state last_observed_state, gpr_timespec deadline, grpc_completion_queue *cq, void *tag)
GPRAPI void gpr_cv_broadcast(gpr_cv *cv)
static gpr_cv global_connection_polling_cv
bg_watched_channel * bg_wrapped
struct watch_state_op::@49::@51 continuous_watch_callback_args
GRPCAPI grpc_completion_queue * grpc_completion_queue_create_for_next(void *reserved)
#define GRPC_PROPAGATE_DEADLINE
grpc_completion_type type
static int abort_channel_polling
watch_state_op_type op_type
static int bg_watched_channel_list_lookup(bg_watched_channel *bg)
if(p->owned &&p->wrapped !=NULL)
static grpc_completion_queue * cq
static void * channel_init_try_register_connection_polling_without_gil(void *arg)
GPRAPI void gpr_cv_init(gpr_cv *cv)
bool grpc_rb_is_xds_channel_credentials(VALUE v)
#define GRPC_ARG_MAX_CONCURRENT_STREAMS
#define GRPC_PROPAGATE_CANCELLATION
struct bg_watched_channel bg_watched_channel
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:59