class GRPC::Core::XdsChannelCredentials

Public Class Methods

fallback_creds: (ChannelCredentials) fallback credentials to create click to toggle source
XDS credentials
Initializes Credential instances.
static VALUE grpc_rb_xds_channel_credentials_init(VALUE self,
                                                  VALUE fallback_creds) {
  grpc_rb_xds_channel_credentials* wrapper = NULL;
  grpc_channel_credentials* grpc_fallback_creds =
      grpc_rb_get_wrapped_channel_credentials(fallback_creds);
  grpc_channel_credentials* creds =
      grpc_xds_credentials_create(grpc_fallback_creds);
  if (creds == NULL) {
    rb_raise(rb_eRuntimeError,
             "the call to grpc_xds_credentials_create() failed, could not "
             "create a credentials, , see "
             "https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md for "
             "debugging tips");
    return Qnil;
  }

  TypedData_Get_Struct(self, grpc_rb_xds_channel_credentials,
                       &grpc_rb_xds_channel_credentials_data_type, wrapper);
  wrapper->wrapped = creds;

  /* Add the input objects as hidden fields to preserve them. */
  rb_ivar_set(self, id_fallback_creds, fallback_creds);

  return self;
}

Public Instance Methods

compose(*args) click to toggle source
static VALUE grpc_rb_xds_channel_credentials_compose(int argc, VALUE* argv,
                                                     VALUE self) {
  grpc_channel_credentials* creds;
  grpc_call_credentials* other;
  grpc_channel_credentials* prev = NULL;
  VALUE mark;
  if (argc == 0) {
    return self;
  }
  mark = rb_ary_new();
  rb_ary_push(mark, self);
  creds = grpc_rb_get_wrapped_xds_channel_credentials(self);
  for (int i = 0; i < argc; i++) {
    rb_ary_push(mark, argv[i]);
    other = grpc_rb_get_wrapped_call_credentials(argv[i]);
    creds = grpc_composite_channel_credentials_create(creds, other, NULL);
    if (prev != NULL) {
      grpc_channel_credentials_release(prev);
    }
    prev = creds;

    if (creds == NULL) {
      rb_raise(rb_eRuntimeError,
               "Failed to compose channel and call credentials");
    }
  }
  return grpc_rb_xds_wrap_channel_credentials(creds, mark);
}