Class: GRPC::Core::Call
- Inherits:
-
Object
- Object
- GRPC::Core::Call
- Defined in:
- ext/grpc/rb_call.c
Constant Summary collapse
- INTERNAL_ALL_CALLs =
hash_all_calls
Instance Method Summary collapse
-
#cancel ⇒ Object
Called by clients to cancel an RPC on the server.
-
#initialize ⇒ Object
constructor
Init func that fails by raising an exception.
-
#initialize_copy(self) ⇒ Object
Init/Clone func that fails by raising an exception.
-
#metadata ⇒ Object
metadata = call.metadata.
-
#metadata=(metadata) ⇒ Object
call.metadata = metadata.
-
#cq=(CompletionQueue) ⇒ Object
GRPC::Core::CallOps::SEND_INITIAL_METADATA => <op_value>, GRPC::Core::CallOps::SEND_MESSAGE => <op_value>, …
-
#status ⇒ Object
status = call.status.
-
#status=(status) ⇒ Object
call.status = status.
Constructor Details
#initialize ⇒ Object
Init func that fails by raising an exception.
69 70 71 72 73 74 |
# File 'ext/grpc/rb_grpc.c', line 69 VALUE grpc_rb_cannot_init(VALUE self) { rb_raise(rb_eTypeError, "initialization of %s only allowed from the gRPC native layer", rb_obj_classname(self)); return Qnil; } |
Instance Method Details
#cancel ⇒ Object
Called by clients to cancel an RPC on the server.
Can be called multiple times, from any thread.
167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'ext/grpc/rb_call.c', line 167
static VALUE grpc_rb_call_cancel(VALUE self) {
grpc_call *call = NULL;
grpc_call_error err;
TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call);
err = grpc_call_cancel(call);
if (err != GRPC_CALL_OK) {
rb_raise(grpc_rb_eCallError, "cancel failed: %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
return Qnil;
}
|
#initialize_copy(self) ⇒ Object
Init/Clone func that fails by raising an exception.
77 78 79 80 81 82 |
# File 'ext/grpc/rb_grpc.c', line 77
VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self) {
rb_raise(rb_eTypeError,
"initialization of %s only allowed from the gRPC native layer",
rb_obj_classname(copy));
return Qnil;
}
|
#metadata ⇒ Object
metadata = call.metadata
Gets the metadata object saved the call.
209 210 211 |
# File 'ext/grpc/rb_call.c', line 209 static VALUE (VALUE self) { return rb_ivar_get(self, ); } |
#metadata=(metadata) ⇒ Object
call.metadata = metadata
Saves the metadata hash on the call.
218 219 220 221 222 223 224 225 226 |
# File 'ext/grpc/rb_call.c', line 218
static VALUE grpc_rb_call_set_metadata(VALUE self, VALUE metadata) {
if (!NIL_P(metadata) && TYPE(metadata) != T_HASH) {
rb_raise(rb_eTypeError, "bad metadata: got:<%s> want: <Hash>",
rb_obj_classname(metadata));
return Qnil;
}
return rb_ivar_set(self, id_metadata, metadata);
}
|
#cq=(CompletionQueue) ⇒ Object
GRPC::Core::CallOps::SEND_INITIAL_METADATA => <op_value>,
GRPC::Core::CallOps::SEND_MESSAGE => <op_value>,
...
}
tag = Object.new
timeout = 10
call.start_batch(cqueue, tag, timeout, ops)
Start a batch of operations defined in the array ops; when complete, post a
completion of type 'tag' to the completion queue bound to the call.
Also waits for the batch to complete, until timeout is reached.
The order of ops specified in the batch has no significance.
Only one operation of each type can be active at once in any given
batch
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'ext/grpc/rb_call.c', line 580
static VALUE grpc_rb_call_run_batch(VALUE self, VALUE cqueue, VALUE tag,
VALUE timeout, VALUE ops_hash) {
run_batch_stack st;
grpc_call *call = NULL;
grpc_event ev;
grpc_call_error err;
VALUE result = Qnil;
TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call);
/* Validate the ops args, adding them to a ruby array */
if (TYPE(ops_hash) != T_HASH) {
rb_raise(rb_eTypeError, "call#run_batch: ops hash should be a hash");
return Qnil;
}
grpc_run_batch_stack_init(&st);
grpc_run_batch_stack_fill_ops(&st, ops_hash);
/* call grpc_call_start_batch, then wait for it to complete using
* pluck_event */
err = grpc_call_start_batch(call, st.ops, st.op_num, ROBJECT(tag));
if (err != GRPC_CALL_OK) {
grpc_run_batch_stack_cleanup(&st);
rb_raise(grpc_rb_eCallError,
"grpc_call_start_batch failed with %s (code=%d)",
grpc_call_error_detail_of(err), err);
return Qnil;
}
ev = grpc_rb_completion_queue_pluck_event(cqueue, tag, timeout);
if (ev.type == GRPC_QUEUE_TIMEOUT) {
grpc_run_batch_stack_cleanup(&st);
rb_raise(grpc_rb_eOutOfTime, "grpc_call_start_batch timed out");
return Qnil;
}
if (!ev.success) {
grpc_run_batch_stack_cleanup(&st);
rb_raise(grpc_rb_eCallError, "start_batch completion failed");
return Qnil;
}
/* Build and return the BatchResult struct result */
result = grpc_run_batch_stack_build_result(&st);
grpc_run_batch_stack_cleanup(&st);
return result;
}
|
#status ⇒ Object
status = call.status
Gets the status object saved the call.
185 186 187 |
# File 'ext/grpc/rb_call.c', line 185 static VALUE grpc_rb_call_get_status(VALUE self) { return rb_ivar_get(self, id_status); } |
#status=(status) ⇒ Object
call.status = status
Saves a status object on the call.
194 195 196 197 198 199 200 201 202 |
# File 'ext/grpc/rb_call.c', line 194
static VALUE grpc_rb_call_set_status(VALUE self, VALUE status) {
if (!NIL_P(status) && rb_obj_class(status) != grpc_rb_sStatus) {
rb_raise(rb_eTypeError, "bad status: got:<%s> want: <Struct::Status>",
rb_obj_classname(status));
return Qnil;
}
return rb_ivar_set(self, id_status, status);
}
|