19 #ifndef GRPCXX_IMPL_CODEGEN_CALL_H
20 #define GRPCXX_IMPL_CODEGEN_CALL_H
57 const std::multimap<grpc::string, grpc::string>& metadata,
58 size_t* metadata_count,
const grpc::string& optional_error_details) {
59 *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
60 if (*metadata_count == 0) {
67 for (
auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
71 if (!optional_error_details.empty()) {
72 metadata_array[i].
key =
77 return metadata_array;
85 : flags_(other.flags_), last_message_(other.last_message_) {}
88 inline void Clear() { flags_ = 0; }
91 inline uint32_t
flags()
const {
return flags_; }
161 last_message_ =
true;
168 last_message_ =
false;
184 void SetBit(
const uint32_t mask) { flags_ |= mask; }
186 void ClearBit(
const uint32_t mask) { flags_ &= ~mask; }
188 bool GetBit(
const uint32_t mask)
const {
return (flags_ & mask) != 0; }
210 const std::multimap<grpc::string, grpc::string>& metadata,
271 if (send_buf_ ==
nullptr)
return;
278 write_options_.
Clear();
293 write_options_ = options;
308 allow_not_getting_message_(false) {}
319 if (message_ ==
nullptr)
return;
328 if (message_ ==
nullptr)
return;
339 if (!allow_not_getting_message_) {
349 bool allow_not_getting_message_;
352 namespace CallOpGenericRecvMessageHelper {
377 :
got_message(false), allow_not_getting_message_(false) {}
385 deserialize_.reset(func);
395 if (!deserialize_)
return;
404 if (!deserialize_)
return;
408 *status = deserialize_->Deserialize(recv_buf_).ok();
415 if (!allow_not_getting_message_) {
419 deserialize_.reset();
423 std::unique_ptr<CallOpGenericRecvMessageHelper::DeserializeFunc> deserialize_;
425 bool allow_not_getting_message_;
453 const std::multimap<grpc::string, grpc::string>& trailing_metadata,
457 trailing_metadata, &trailing_metadata_count_, send_error_details_);
458 send_status_available_ =
true;
465 if (!send_status_available_)
return;
469 trailing_metadata_count_;
474 send_error_message_.empty() ?
nullptr : &error_message_slice_;
480 if (!send_status_available_)
return;
482 send_status_available_ =
false;
486 bool send_status_available_;
490 size_t trailing_metadata_count_;
500 context->initial_metadata_received_ =
true;
501 metadata_map_ = &context->recv_initial_metadata_;
506 if (metadata_map_ ==
nullptr)
return;
515 if (metadata_map_ ==
nullptr)
return;
517 metadata_map_ =
nullptr;
529 metadata_map_ = &context->trailing_metadata_;
530 recv_status_ = status;
536 if (recv_status_ ==
nullptr)
return;
547 if (recv_status_ ==
nullptr)
return;
551 if (iter != metadata_map_->
map()->end()) {
552 binary_error_details =
553 grpc::string(iter->second.begin(), iter->second.length());
555 *recv_status_ =
Status(static_cast<StatusCode>(status_code_),
558 binary_error_details);
560 recv_status_ =
nullptr;
588 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
589 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
590 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
601 this->Op1::AddOp(ops, nops);
602 this->Op2::AddOp(ops, nops);
603 this->Op3::AddOp(ops, nops);
604 this->Op4::AddOp(ops, nops);
605 this->Op5::AddOp(ops, nops);
606 this->Op6::AddOp(ops, nops);
612 this->Op1::FinishOp(status);
613 this->Op2::FinishOp(status);
614 this->Op3::FinishOp(status);
615 this->Op4::FinishOp(status);
616 this->Op5::FinishOp(status);
617 this->Op6::FinishOp(status);
635 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
636 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
637 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
642 return Base::FinalizeResult(tag, status) &&
false;
651 : call_hook_(call_hook),
654 max_receive_message_size_(-1) {}
658 : call_hook_(call_hook),
661 max_receive_message_size_(max_receive_message_size) {}
676 int max_receive_message_size_;
681 #endif // GRPCXX_IMPL_CODEGEN_CALL_H
void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:452
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:71
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:489
union grpc_op::grpc_op_data data
void RecvMessage(R *message)
Definition: call.h:380
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_receive_message_size)
Definition: call.h:656
bool is_corked() const
Definition: call.h:153
void * reserved
Reserved for future usage.
Definition: grpc_types.h:493
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:25
WriteOptions & clear_buffer_hint()
Clears flag indicating that the write may be buffered and need not go out on the wire immediately...
Definition: call.h:130
Default argument for CallOpSet.
Definition: call.h:197
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:435
CallOpServerSendStatus()
Definition: call.h:450
void FinishOp(bool *status)
Definition: call.h:200
grpc_status_code
Definition: status.h:26
WriteOptions & set_buffer_hint()
Sets flag indicating that the write may be buffered and need not go out on the wire immediately...
Definition: call.h:121
virtual void grpc_call_ref(grpc_call *call)=0
grpc::string error_message() const
Return the instance's error message.
Definition: status.h:58
CallOpSendMessage()
Definition: call.h:258
std::string string
Definition: config.h:35
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:394
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:104
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:533
struct grpc_byte_buffer * send_message
Definition: grpc_types.h:510
Send a close from the client: one and only one instance MUST be sent from the client, unless the call was cancelled - in which case this can be skipped.
Definition: grpc_types.h:454
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:575
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:459
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call.h:160
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:357
void AllowNoMessage()
Definition: call.h:313
void FinishOp(bool *status)
Definition: call.h:403
struct grpc_op::grpc_op_data::grpc_op_recv_message recv_message
grpc_slice * status_details
Definition: grpc_types.h:543
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:318
void Clear()
Clear all flags.
Definition: call.h:88
virtual grpc_slice grpc_empty_slice()=0
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:76
#define GRPC_WRITE_BUFFER_HINT
Write Flags:
Definition: grpc_types.h:354
const char kBinaryErrorDetailsKey[]
Definition: call.h:52
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
call is owned by the caller
Definition: call.h:650
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:449
virtual void grpc_call_unref(grpc_call *call)=0
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:464
WriteOptions & clear_last_messsage()
Clears flag indicating that this is the last message in a stream, disabling coalescing.
Definition: call.h:167
Status Deserialize(grpc_byte_buffer *buf) override
Definition: call.h:363
WriteOptions()
Definition: call.h:83
bool FinalizeResult(void **tag, bool *status) override
Called prior to returning from Next(), return value is the status of the operation (return status is ...
Definition: call.h:640
Definition: grpc_types.h:41
grpc_slice SliceReferencingString(const grpc::string &str)
Definition: slice.h:38
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:68
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:91
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:112
grpc_metadata_array * trailing_metadata
ownership of the array is with the caller, but ownership of the elements stays with the call object (...
Definition: grpc_types.h:541
WriteOptions & clear_corked()
Definition: call.h:148
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:96
#define GRPC_SLICE_END_PTR(slice)
Definition: slice.h:121
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:153
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:178
virtual void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)=0
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:49
bool FinalizeResult(void **tag, bool *status) override
Called prior to returning from Next(), return value is the status of the operation (return status is ...
Definition: call.h:611
void FinishOp(bool *status)
Definition: call.h:479
CallOpClientRecvStatus()
Definition: call.h:526
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:113
void FinishOp(bool *status)
Definition: call.h:442
CallOpSet()
Definition: call.h:599
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:292
void AllowNoMessage()
Definition: call.h:389
CompletionQueue * cq() const
Definition: call.h:668
int max_receive_message_size() const
Definition: call.h:670
struct grpc_op::grpc_op_data::grpc_op_recv_initial_metadata recv_initial_metadata
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:535
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata send_initial_metadata
Straightforward wrapping of the C call object.
Definition: call.h:647
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:487
virtual grpc_slice grpc_slice_from_static_buffer(const void *buffer, size_t length)=0
Receive initial metadata: one and only one MUST be made on the client, must not be made on the server...
Definition: grpc_types.h:464
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:199
struct grpc_op::grpc_op_data::grpc_op_send_message send_message
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:49
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:445
WriteOptions(const WriteOptions &other)
Definition: call.h:84
Primary implementaiton of CallOpSetInterface.
Definition: call.h:591
virtual Status Deserialize(grpc_byte_buffer *buf)=0
void ClientSendClose()
Definition: call.h:432
Per-message write options.
Definition: call.h:81
grpc_slice * status_details
optional: set to NULL if no details need sending, non-NULL if they do pointer will not be retained pa...
Definition: grpc_types.h:519
CallOpClientSendClose()
Definition: call.h:430
size_t trailing_metadata_count
Definition: grpc_types.h:513
bool get_buffer_hint() const
Get value for the flag indicating that the write may be buffered and need not go out on the wire imme...
Definition: call.h:139
virtual void FillOps(grpc_call *call, grpc_op *ops, size_t *nops)=0
Fills in grpc_op, starting from ops[*nops] and moving upwards.
void FinishOp(bool *status)
Definition: call.h:327
CallOpRecvMessage()
Definition: call.h:305
StatusCode error_code() const
Return the instance's error code.
Definition: status.h:56
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:86
virtual void PerformOpsOnCall(CallOpSetInterface *ops, Call *call)=0
~DeserializeFuncType() override
Definition: call.h:367
void FinishOp(bool *status)
Definition: call.h:280
virtual void grpc_slice_unref(grpc_slice slice)=0
bool got_message
Definition: call.h:315
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:61
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:528
struct grpc_op::grpc_op_data::grpc_op_send_status_from_server send_status_from_server
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:41
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:663
WriteOptions & set_corked()
corked bit: aliases set_buffer_hint currently, with the intent that set_buffer_hint will be removed i...
Definition: call.h:143
DeserializeFuncType(R *message)
Definition: call.h:362
Did it work? If it didn't, why?
Definition: status.h:30
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:474
grpc_status_code status
Definition: grpc_types.h:515
grpc_status_code * status
Definition: grpc_types.h:542
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:491
void FillOps(grpc_call *call, grpc_op *ops, size_t *nops) override
Fills in grpc_op, starting from ops[*nops] and moving upwards.
Definition: call.h:600
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata, size_t *metadata_count, const grpc::string &optional_error_details)
Definition: call.h:56
grpc_call * call() const
Definition: call.h:667
void RecvMessage(R *message)
Definition: call.h:310
CallOpGenericRecvMessage()
Definition: call.h:376
virtual void gpr_free(void *p)=0
bool got_message
Definition: call.h:391
A CallOpSet that does not post completions to the completion queue.
Definition: call.h:638
void FinishOp(bool *status)
Definition: call.h:546
void set_output_tag(void *return_tag)
Definition: call.h:624
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:468
This is an interface that Channel and Server implement to allow them to hook performing ops...
Definition: call_hook.h:29
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:270
virtual ~DeserializeFunc()
Definition: call.h:356
bool is_last_message() const
Get value for the flag indicating that this is the last message, and should be coalesced with trailin...
Definition: call.h:176
grpc_metadata * trailing_metadata
Definition: grpc_types.h:514
struct grpc_op::grpc_op_data::grpc_op_recv_status_on_client recv_status_on_client
virtual void * gpr_malloc(size_t size)=0