34 #ifndef GRPCXX_IMPL_CODEGEN_CALL_H
35 #define GRPCXX_IMPL_CODEGEN_CALL_H
71 const std::multimap<grpc::string, grpc::string>& metadata,
72 size_t* metadata_count,
const grpc::string& optional_error_details) {
73 *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
74 if (*metadata_count == 0) {
81 for (
auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
85 if (!optional_error_details.empty()) {
86 metadata_array[i].
key =
91 return metadata_array;
99 : flags_(other.flags_), last_message_(other.last_message_) {}
105 inline uint32_t
flags()
const {
return flags_; }
175 last_message_ =
true;
182 last_message_ =
false;
198 void SetBit(
const uint32_t mask) { flags_ |= mask; }
200 void ClearBit(
const uint32_t mask) { flags_ &= ~mask; }
202 bool GetBit(
const uint32_t mask)
const {
return (flags_ & mask) != 0; }
224 const std::multimap<grpc::string, grpc::string>& metadata,
283 if (send_buf_ ==
nullptr)
return;
290 write_options_.
Clear();
305 write_options_ = options;
320 allow_not_getting_message_(false) {}
331 if (message_ ==
nullptr)
return;
340 if (message_ ==
nullptr)
return;
351 if (!allow_not_getting_message_) {
361 bool allow_not_getting_message_;
364 namespace CallOpGenericRecvMessageHelper {
389 :
got_message(false), allow_not_getting_message_(false) {}
397 deserialize_.reset(func);
407 if (!deserialize_)
return;
416 if (!deserialize_)
return;
420 *status = deserialize_->Deserialize(recv_buf_).ok();
427 if (!allow_not_getting_message_) {
431 deserialize_.reset();
435 std::unique_ptr<CallOpGenericRecvMessageHelper::DeserializeFunc> deserialize_;
437 bool allow_not_getting_message_;
465 const std::multimap<grpc::string, grpc::string>& trailing_metadata,
469 trailing_metadata, &trailing_metadata_count_, send_error_details_);
470 send_status_available_ =
true;
477 if (!send_status_available_)
return;
481 trailing_metadata_count_;
486 send_error_message_.empty() ?
nullptr : &error_message_slice_;
492 if (!send_status_available_)
return;
494 send_status_available_ =
false;
498 bool send_status_available_;
502 size_t trailing_metadata_count_;
512 context->initial_metadata_received_ =
true;
513 metadata_map_ = &context->recv_initial_metadata_;
518 if (metadata_map_ ==
nullptr)
return;
527 if (metadata_map_ ==
nullptr)
return;
529 metadata_map_ =
nullptr;
541 metadata_map_ = &context->trailing_metadata_;
542 recv_status_ = status;
548 if (recv_status_ ==
nullptr)
return;
559 if (recv_status_ ==
nullptr)
return;
563 if (iter != metadata_map_->
map()->end()) {
564 binary_error_details =
565 grpc::string(iter->second.begin(), iter->second.length());
567 *recv_status_ =
Status(static_cast<StatusCode>(status_code_),
570 binary_error_details);
572 recv_status_ =
nullptr;
591 :
public std::enable_shared_from_this<CallOpSetCollectionInterface> {};
606 void SetCollection(std::shared_ptr<CallOpSetCollectionInterface> collection) {
620 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
621 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
622 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
633 this->Op1::AddOp(ops, nops);
634 this->Op2::AddOp(ops, nops);
635 this->Op3::AddOp(ops, nops);
636 this->Op4::AddOp(ops, nops);
637 this->Op5::AddOp(ops, nops);
638 this->Op6::AddOp(ops, nops);
642 this->Op1::FinishOp(status);
643 this->Op2::FinishOp(status);
644 this->Op3::FinishOp(status);
645 this->Op4::FinishOp(status);
646 this->Op5::FinishOp(status);
647 this->Op6::FinishOp(status);
663 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
664 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
665 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
670 return Base::FinalizeResult(tag, status) &&
false;
679 : call_hook_(call_hook),
682 max_receive_message_size_(-1) {}
686 : call_hook_(call_hook),
689 max_receive_message_size_(max_receive_message_size) {}
704 int max_receive_message_size_;
709 #endif // GRPCXX_IMPL_CODEGEN_CALL_H
void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:464
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:85
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:469
void RecvMessage(R *message)
Definition: call.h:392
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_receive_message_size)
Definition: call.h:684
bool is_corked() const
Definition: call.h:167
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:40
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:144
Default argument for CallOpSet.
Definition: call.h:211
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:447
CallOpServerSendStatus()
Definition: call.h:462
void FinishOp(bool *status)
Definition: call.h:214
grpc_status_code
Definition: status.h:41
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:135
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:507
grpc::string error_message() const
Return the instance's error message.
Definition: status.h:70
CallOpSendMessage()
Definition: call.h:270
std::string string
Definition: config.h:50
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:406
void SetCollection(std::shared_ptr< CallOpSetCollectionInterface > collection)
Mark this as belonging to a collection if needed.
Definition: call.h:606
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:118
StatusCode GetCanonicalCode(const Status &status)
Definition: status_helper.h:41
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:433
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:598
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:439
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:174
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:338
void AllowNoMessage()
Definition: call.h:325
void FinishOp(bool *status)
Definition: call.h:415
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:330
void Clear()
Clear all flags.
Definition: call.h:102
virtual grpc_slice grpc_empty_slice()=0
#define GRPC_WRITE_BUFFER_HINT
Hint that the write may be buffered and need not go out on the wire immediately.
Definition: grpc_types.h:335
const char kBinaryErrorDetailsKey[]
Definition: call.h:66
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
Definition: call.h:678
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:427
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:476
An abstract collection of CallOpSet's, to be used whenever CallOpSet objects must be thought of as a ...
Definition: call.h:590
WriteOptions & clear_last_messsage()
Clears flag indicating that this is the last message in a stream, disabling coalescing.
Definition: call.h:181
Status Deserialize(grpc_byte_buffer *buf) override
Definition: call.h:375
WriteOptions()
Definition: call.h:97
bool FinalizeResult(void **tag, bool *status) override
Definition: call.h:668
struct grpc_op::@12::@19 recv_status_on_client
Definition: grpc_types.h:55
grpc_slice SliceReferencingString(const grpc::string &str)
Definition: slice.h:53
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:84
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:105
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:126
WriteOptions & clear_corked()
Definition: call.h:162
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:110
#define GRPC_SLICE_END_PTR(slice)
Definition: slice.h:135
Definition: client_context.h:154
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:192
void FillOps(grpc_op *ops, size_t *nops) override
Fills in grpc_op, starting from ops[*nops] and moving upwards.
Definition: call.h:632
virtual void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)=0
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:64
bool FinalizeResult(void **tag, bool *status) override
Definition: call.h:641
void FinishOp(bool *status)
Definition: call.h:491
CallOpClientRecvStatus()
Definition: call.h:538
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:127
struct grpc_byte_buffer * send_message
Definition: grpc_types.h:490
void FinishOp(bool *status)
Definition: call.h:454
CallOpSet()
Definition: call.h:631
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:304
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:513
void AllowNoMessage()
Definition: call.h:401
CompletionQueue * cq() const
Definition: call.h:696
int max_receive_message_size() const
Definition: call.h:698
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:547
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:467
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:444
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:213
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:63
CallOpSetInterface()
Definition: call.h:600
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:423
WriteOptions(const WriteOptions &other)
Definition: call.h:98
Primary implementaiton of CallOpSetInterface.
Definition: call.h:623
struct grpc_op::@12::@14 send_initial_metadata
virtual Status Deserialize(grpc_byte_buffer *buf)=0
void ClientSendClose()
Definition: call.h:444
Per-message write options.
Definition: call.h:95
CallOpClientSendClose()
Definition: call.h:442
std::shared_ptr< CallOpSetCollectionInterface > collection_
Definition: call.h:611
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:153
void FinishOp(bool *status)
Definition: call.h:339
CallOpRecvMessage()
Definition: call.h:317
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:101
virtual void PerformOpsOnCall(CallOpSetInterface *ops, Call *call)=0
~DeserializeFuncType() override
Definition: call.h:379
void FinishOp(bool *status)
Definition: call.h:292
struct grpc_op::@12::@16 send_status_from_server
virtual void grpc_slice_unref(grpc_slice slice)=0
bool got_message
Definition: call.h:327
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:73
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:540
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:56
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:691
WriteOptions & set_corked()
corked bit: aliases set_buffer_hint currently, with the intent that set_buffer_hint will be removed i...
Definition: call.h:157
DeserializeFuncType(R *message)
Definition: call.h:374
Did it work? If it didn't, why?
Definition: status.h:45
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:454
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:471
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata, size_t *metadata_count, const grpc::string &optional_error_details)
Definition: call.h:70
grpc_call * call() const
Definition: call.h:695
void RecvMessage(R *message)
Definition: call.h:322
void * reserved
Reserved for future usage.
Definition: grpc_types.h:473
CallOpGenericRecvMessage()
Definition: call.h:388
virtual void gpr_free(void *p)=0
bool got_message
Definition: call.h:403
A CallOpSet that does not post completions to the completion queue.
Definition: call.h:666
virtual void FillOps(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:558
void set_output_tag(void *return_tag)
Definition: call.h:653
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:448
Channel and Server implement this to allow them to hook performing ops.
Definition: call_hook.h:43
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:282
virtual ~DeserializeFunc()
Definition: call.h:368
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:190
virtual void * gpr_malloc(size_t size)=0