34 #ifndef GRPCXX_IMPL_CODEGEN_CALL_H 35 #define GRPCXX_IMPL_CODEGEN_CALL_H 67 std::multimap<grpc::string_ref, grpc::string_ref>* metadata) {
68 for (
size_t i = 0; i < arr->
count; i++) {
70 metadata->insert(std::pair<grpc::string_ref, grpc::string_ref>(
81 const std::multimap<grpc::string, grpc::string>& metadata) {
82 if (metadata.empty()) {
89 for (
auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
90 metadata_array[i].
key = iter->first.c_str();
91 metadata_array[i].
value = iter->second.c_str();
94 return metadata_array;
107 inline uint32_t
flags()
const {
return flags_; }
163 void SetBit(
const uint32_t mask) { flags_ |= mask; }
165 void ClearBit(
const uint32_t mask) { flags_ &= ~mask; }
167 bool GetBit(
const uint32_t mask)
const {
return (flags_ & mask) != 0; }
178 void FinishOp(
bool* status,
int max_message_size) {}
184 maybe_compression_level_.is_set =
false;
188 const std::multimap<grpc::string, grpc::string>& metadata,
190 maybe_compression_level_.is_set =
false;
193 initial_metadata_count_ = metadata.size();
198 maybe_compression_level_.is_set =
true;
199 maybe_compression_level_.level = level;
212 maybe_compression_level_.is_set;
214 maybe_compression_level_.level;
216 void FinishOp(
bool* status,
int max_message_size) {
218 g_core_codegen_interface->
gpr_free(initial_metadata_);
229 } maybe_compression_level_;
239 Status SendMessage(
const M& message,
247 if (send_buf_ ==
nullptr)
return;
250 op->
flags = write_options_.flags();
254 write_options_.Clear();
256 void FinishOp(
bool* status,
int max_message_size) {
270 write_options_ = options;
283 : got_message(false),
285 allow_not_getting_message_(false) {}
296 if (message_ ==
nullptr)
return;
304 void FinishOp(
bool* status,
int max_message_size) {
305 if (message_ ==
nullptr)
return;
309 recv_buf_, message_, max_message_size)
317 if (!allow_not_getting_message_) {
327 bool allow_not_getting_message_;
330 namespace CallOpGenericRecvMessageHelper {
356 : got_message(false), allow_not_getting_message_(false) {}
364 deserialize_.reset(func);
374 if (!deserialize_)
return;
382 void FinishOp(
bool* status,
int max_message_size) {
383 if (!deserialize_)
return;
387 *status = deserialize_->Deserialize(recv_buf_, max_message_size).ok();
394 if (!allow_not_getting_message_) {
398 deserialize_.reset();
402 std::unique_ptr<CallOpGenericRecvMessageHelper::DeserializeFunc> deserialize_;
404 bool allow_not_getting_message_;
421 void FinishOp(
bool* status,
int max_message_size) { send_ =
false; }
432 const std::multimap<grpc::string, grpc::string>& trailing_metadata,
434 trailing_metadata_count_ = trailing_metadata.size();
436 send_status_available_ =
true;
443 if (!send_status_available_)
return;
447 trailing_metadata_count_;
451 send_status_details_.empty() ?
nullptr : send_status_details_.c_str();
456 void FinishOp(
bool* status,
int max_message_size) {
457 if (!send_status_available_)
return;
458 g_core_codegen_interface->
gpr_free(trailing_metadata_);
459 send_status_available_ =
false;
463 bool send_status_available_;
466 size_t trailing_metadata_count_;
475 context->initial_metadata_received_ =
true;
476 recv_initial_metadata_ = &context->recv_initial_metadata_;
481 if (!recv_initial_metadata_)
return;
482 memset(&recv_initial_metadata_arr_, 0,
sizeof(recv_initial_metadata_arr_));
489 void FinishOp(
bool* status,
int max_message_size) {
490 if (recv_initial_metadata_ ==
nullptr)
return;
492 recv_initial_metadata_ =
nullptr;
496 std::multimap<grpc::string_ref, grpc::string_ref>* recv_initial_metadata_;
505 recv_trailing_metadata_ = &context->trailing_metadata_;
506 recv_status_ = status;
511 if (recv_status_ ==
nullptr)
return;
512 memset(&recv_trailing_metadata_arr_, 0,
513 sizeof(recv_trailing_metadata_arr_));
514 status_details_ =
nullptr;
515 status_details_capacity_ = 0;
519 &recv_trailing_metadata_arr_;
523 &status_details_capacity_;
528 void FinishOp(
bool* status,
int max_message_size) {
529 if (recv_status_ ==
nullptr)
return;
530 FillMetadataMap(&recv_trailing_metadata_arr_, recv_trailing_metadata_);
532 static_cast<StatusCode>(status_code_),
534 g_core_codegen_interface->
gpr_free(status_details_);
535 recv_status_ =
nullptr;
539 std::multimap<grpc::string_ref, grpc::string_ref>* recv_trailing_metadata_;
543 char* status_details_;
544 size_t status_details_capacity_;
556 :
public std::enable_shared_from_this<CallOpSetCollectionInterface> {};
568 virtual void FillOps(
grpc_op* ops,
size_t* nops) = 0;
571 max_message_size_ = max_message_size;
575 void SetCollection(std::shared_ptr<CallOpSetCollectionInterface> collection) {
576 collection_ = collection;
590 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
591 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
592 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
603 this->Op1::AddOp(ops, nops);
604 this->Op2::AddOp(ops, nops);
605 this->Op3::AddOp(ops, nops);
606 this->Op4::AddOp(ops, nops);
607 this->Op5::AddOp(ops, nops);
608 this->Op6::AddOp(ops, nops);
612 this->Op1::FinishOp(status, max_message_size_);
613 this->Op2::FinishOp(status, max_message_size_);
614 this->Op3::FinishOp(status, max_message_size_);
615 this->Op4::FinishOp(status, max_message_size_);
616 this->Op5::FinishOp(status, max_message_size_);
617 this->Op6::FinishOp(status, max_message_size_);
633 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
634 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
635 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
640 return Base::FinalizeResult(tag, status) &&
false;
649 : call_hook_(call_hook), cq_(cq), call_(call), max_message_size_(-1) {}
652 int max_message_size)
653 : call_hook_(call_hook),
656 max_message_size_(max_message_size) {}
659 if (max_message_size_ > 0) {
662 call_hook_->PerformOpsOnCall(ops,
this);
674 int max_message_size_;
679 #endif // GRPCXX_IMPL_CODEGEN_CALL_H void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:431
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:62
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:334
void RecvMessage(R *message)
Definition: call.h:359
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:146
Default argument for CallOpSet.
Definition: call.h:175
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:414
CallOpServerSendStatus()
Definition: call.h:429
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:137
grpc_metadata_array * recv_initial_metadata
ownership of the array is with the caller, but ownership of the elements stays with the call object (...
Definition: grpc_types.h:366
grpc::string error_message() const
Return the instance's error message.
Definition: status.h:64
CallOpSendMessage()
Definition: call.h:234
std::string string
Definition: config.h:118
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:373
CompletionQueue * cq()
Definition: call.h:666
void SetCollection(std::shared_ptr< CallOpSetCollectionInterface > collection)
Mark this as belonging to a collection if needed.
Definition: call.h:575
void FinishOp(bool *status, int max_message_size)
Definition: call.h:382
virtual void grpc_metadata_array_destroy(grpc_metadata_array *array)=0
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:120
int max_message_size_
Definition: call.h:580
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:300
bool FinalizeResult(void **tag, bool *status) GRPC_OVERRIDE
Definition: call.h:638
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:563
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:306
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:216
void AllowNoMessage()
Definition: call.h:290
void FinishOp(bool *status, int max_message_size)
Definition: call.h:421
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:295
bool FinalizeResult(void **tag, bool *status) GRPC_OVERRIDE
Definition: call.h:611
void Clear()
Clear all flags.
Definition: call.h:104
#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:213
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
Definition: call.h:648
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:294
void FinishOp(bool *status, int max_message_size)
Definition: call.h:256
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:442
An abstract collection of CallOpSet's, to be used whenever CallOpSet objects must be thought of as a ...
Definition: call.h:555
WriteOptions()
Definition: call.h:100
Definition: byte_buffer.h:49
grpc_byte_buffer ** recv_message
ownership of the byte buffer is moved to the caller; the caller must call grpc_byte_buffer_destroy on...
Definition: grpc_types.h:370
void FillOps(grpc_op *ops, size_t *nops) GRPC_OVERRIDE
Fills in grpc_op, starting from ops[*nops] and moving upwards.
Definition: call.h:602
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:107
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata)
Definition: call.h:80
grpc_call * call()
Definition: call.h:665
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:112
Definition: client_context.h:154
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:157
void FinishOp(bool *status, int max_message_size)
Definition: call.h:528
virtual void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)=0
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:64
struct grpc_op::@11::@13 send_initial_metadata
struct grpc_op::@11::@15 recv_status_on_client
CallOpClientRecvStatus()
Definition: call.h:502
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:129
Status Deserialize(grpc_byte_buffer *buf, int max_message_size) GRPC_OVERRIDE
Definition: call.h:341
CallOpSet()
Definition: call.h:601
void FinishOp(bool *status, int max_message_size)
Definition: call.h:456
void AllowNoMessage()
Definition: call.h:368
void FillMetadataMap(grpc_metadata_array *arr, std::multimap< grpc::string_ref, grpc::string_ref > *metadata)
Definition: call.h:65
struct grpc_op::@11::@14 send_status_from_server
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:510
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:332
Receive initial metadata: one and only one MUST be made on the client, must not be made on the server...
Definition: grpc_types.h:311
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:177
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:62
CallOpSetInterface()
Definition: call.h:565
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:290
WriteOptions(const WriteOptions &other)
Definition: call.h:101
Primary implementaiton of CallOpSetInterface.
Definition: call.h:593
void ClientSendClose()
Definition: call.h:411
int max_message_size()
Definition: call.h:668
Per-message write options.
Definition: call.h:98
CallOpClientSendClose()
Definition: call.h:409
~DeserializeFuncType() GRPC_OVERRIDE
Definition: call.h:346
std::shared_ptr< CallOpSetCollectionInterface > collection_
Definition: call.h:581
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:155
CallOpRecvMessage()
Definition: call.h:282
StatusCode error_code() const
Return the instance's error code.
Definition: status.h:62
A thin wrapper around grpc_completion_queue (see / src/core/surface/completion_queue.h).
Definition: completion_queue.h:97
Status SendMessage(const M &message, const WriteOptions &options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:268
#define GRPC_FINAL
Definition: config.h:72
void FinishOp(bool *status, int max_message_size)
Definition: call.h:178
This class is a non owning reference to a string.
Definition: string_ref.h:56
bool got_message
Definition: call.h:292
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:504
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:50
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:658
void FinishOp(bool *status, int max_message_size)
Definition: call.h:304
void set_max_message_size(int max_message_size)
Definition: call.h:570
DeserializeFuncType(R *message)
Definition: call.h:340
Did it work? If it didn't, why?
Definition: status.h:45
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_message_size)
Definition: call.h:651
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:321
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:336
virtual void grpc_metadata_array_init(grpc_metadata_array *array)=0
void RecvMessage(R *message)
Definition: call.h:287
void * reserved
Reserved for future usage.
Definition: grpc_types.h:338
CallOpGenericRecvMessage()
Definition: call.h:355
virtual void gpr_free(void *p)=0
grpc_byte_buffer * send_message
Definition: grpc_types.h:354
bool got_message
Definition: call.h:370
A CallOpSet that does not post completions to the completion queue.
Definition: call.h:636
void set_output_tag(void *return_tag)
Definition: call.h:623
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:315
Channel and Server implement this to allow them to hook performing ops.
Definition: call_hook.h:43
#define GRPC_OVERRIDE
Definition: config.h:78
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:246
virtual ~DeserializeFunc()
Definition: call.h:334
struct grpc_metadata grpc_metadata
A single metadata element.
virtual void * gpr_malloc(size_t size)=0