34 #ifndef GRPCXX_IMPL_CODEGEN_CALL_H
35 #define GRPCXX_IMPL_CODEGEN_CALL_H
72 const std::multimap<grpc::string, grpc::string>& metadata,
73 size_t* metadata_count,
const grpc::string& optional_error_details) {
74 *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
75 if (*metadata_count == 0) {
82 for (
auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
86 if (!optional_error_details.empty()) {
87 metadata_array[i].
key =
92 return metadata_array;
100 : flags_(other.flags_), last_message_(other.last_message_) {}
106 inline uint32_t
flags()
const {
return flags_; }
176 last_message_ =
true;
183 last_message_ =
false;
199 void SetBit(
const uint32_t mask) { flags_ |= mask; }
201 void ClearBit(
const uint32_t mask) { flags_ &= ~mask; }
203 bool GetBit(
const uint32_t mask)
const {
return (flags_ & mask) != 0; }
225 const std::multimap<grpc::string, grpc::string>& metadata,
286 if (send_buf_ ==
nullptr)
return;
293 write_options_.
Clear();
308 write_options_ = options;
323 allow_not_getting_message_(false) {}
334 if (message_ ==
nullptr)
return;
343 if (message_ ==
nullptr)
return;
354 if (!allow_not_getting_message_) {
364 bool allow_not_getting_message_;
370 :
got_message(false), allow_not_getting_message_(false) {}
386 if (!deserialize_)
return;
395 if (!deserialize_)
return;
399 *status = deserialize_(recv_buf_).ok();
406 if (!allow_not_getting_message_) {
410 deserialize_ = DeserializeFunc();
414 typedef std::function<Status(grpc_byte_buffer*)> DeserializeFunc;
415 DeserializeFunc deserialize_;
417 bool allow_not_getting_message_;
445 const std::multimap<grpc::string, grpc::string>& trailing_metadata,
449 trailing_metadata, &trailing_metadata_count_, send_error_details_);
450 send_status_available_ =
true;
457 if (!send_status_available_)
return;
461 trailing_metadata_count_;
466 send_error_message_.empty() ?
nullptr : &error_message_slice_;
472 if (!send_status_available_)
return;
474 send_status_available_ =
false;
478 bool send_status_available_;
482 size_t trailing_metadata_count_;
492 context->initial_metadata_received_ =
true;
493 metadata_map_ = &context->recv_initial_metadata_;
498 if (metadata_map_ ==
nullptr)
return;
507 if (metadata_map_ ==
nullptr)
return;
509 metadata_map_ =
nullptr;
521 metadata_map_ = &context->trailing_metadata_;
522 recv_status_ = status;
528 if (recv_status_ ==
nullptr)
return;
539 if (recv_status_ ==
nullptr)
return;
543 if (iter != metadata_map_->
map()->end()) {
544 binary_error_details =
545 grpc::string(iter->second.begin(), iter->second.length());
547 *recv_status_ =
Status(static_cast<StatusCode>(status_code_),
550 binary_error_details);
552 recv_status_ =
nullptr;
580 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
581 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
582 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
593 this->Op1::AddOp(ops, nops);
594 this->Op2::AddOp(ops, nops);
595 this->Op3::AddOp(ops, nops);
596 this->Op4::AddOp(ops, nops);
597 this->Op5::AddOp(ops, nops);
598 this->Op6::AddOp(ops, nops);
604 this->Op1::FinishOp(status);
605 this->Op2::FinishOp(status);
606 this->Op3::FinishOp(status);
607 this->Op4::FinishOp(status);
608 this->Op5::FinishOp(status);
609 this->Op6::FinishOp(status);
626 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
627 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
628 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
633 return Base::FinalizeResult(tag, status) &&
false;
642 : call_hook_(call_hook),
645 max_receive_message_size_(-1) {}
649 : call_hook_(call_hook),
652 max_receive_message_size_(max_receive_message_size) {}
667 int max_receive_message_size_;
672 #endif // GRPCXX_IMPL_CODEGEN_CALL_H
void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:444
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:86
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:490
void RecvMessage(R *message)
Definition: call.h:373
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_receive_message_size)
Definition: call.h:647
bool is_corked() const
Definition: call.h:168
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:145
Default argument for CallOpSet.
Definition: call.h:212
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:427
CallOpServerSendStatus()
Definition: call.h:442
void FinishOp(bool *status)
Definition: call.h:215
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:136
virtual void grpc_call_ref(grpc_call *call)=0
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:528
grpc::string error_message() const
Return the instance's error message.
Definition: status.h:70
CallOpSendMessage()
Definition: call.h:273
std::string string
Definition: config.h:50
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:385
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:119
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:455
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:567
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:460
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:175
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:358
void AllowNoMessage()
Definition: call.h:328
void FinishOp(bool *status)
Definition: call.h:394
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:333
void Clear()
Clear all flags.
Definition: call.h:103
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:91
#define GRPC_WRITE_BUFFER_HINT
Write Flags:
Definition: grpc_types.h:355
const char kBinaryErrorDetailsKey[]
Definition: call.h:67
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
call is owned by the caller
Definition: call.h:641
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:450
virtual void grpc_call_unref(grpc_call *call)=0
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:456
WriteOptions & clear_last_messsage()
Clears flag indicating that this is the last message in a stream, disabling coalescing.
Definition: call.h:182
WriteOptions()
Definition: call.h:98
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:631
struct grpc_op::@12::@19 recv_status_on_client
Definition: grpc_types.h:56
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:83
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:106
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:127
WriteOptions & clear_corked()
Definition: call.h:163
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:111
#define GRPC_SLICE_END_PTR(slice)
Definition: slice.h:136
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:168
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:193
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
Called prior to returning from Next(), return value is the status of the operation (return status is ...
Definition: call.h:603
void FinishOp(bool *status)
Definition: call.h:471
CallOpClientRecvStatus()
Definition: call.h:518
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:128
struct grpc_byte_buffer * send_message
Definition: grpc_types.h:511
void FinishOp(bool *status)
Definition: call.h:434
CallOpSet()
Definition: call.h:591
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:307
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:534
void AllowNoMessage()
Definition: call.h:380
CompletionQueue * cq() const
Definition: call.h:659
int max_receive_message_size() const
Definition: call.h:661
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:527
Straightforward wrapping of the C call object.
Definition: call.h:638
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:488
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:465
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:214
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:64
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:446
WriteOptions(const WriteOptions &other)
Definition: call.h:99
Primary implementaiton of CallOpSetInterface.
Definition: call.h:583
struct grpc_op::@12::@14 send_initial_metadata
void ClientSendClose()
Definition: call.h:424
Per-message write options.
Definition: call.h:96
CallOpClientSendClose()
Definition: call.h:422
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:154
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:342
CallOpRecvMessage()
Definition: call.h:320
StatusCode error_code() const
Return the instance's error code.
Definition: status.h:68
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
void FinishOp(bool *status)
Definition: call.h:295
struct grpc_op::@12::@16 send_status_from_server
virtual void grpc_slice_unref(grpc_slice slice)=0
bool got_message
Definition: call.h:330
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:73
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:520
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:654
WriteOptions & set_corked()
corked bit: aliases set_buffer_hint currently, with the intent that set_buffer_hint will be removed i...
Definition: call.h:158
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:475
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:492
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:592
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata, size_t *metadata_count, const grpc::string &optional_error_details)
Definition: call.h:71
grpc_call * call() const
Definition: call.h:658
void RecvMessage(R *message)
Definition: call.h:325
void * reserved
Reserved for future usage.
Definition: grpc_types.h:494
CallOpGenericRecvMessage()
Definition: call.h:369
virtual void gpr_free(void *p)=0
bool got_message
Definition: call.h:382
A CallOpSet that does not post completions to the completion queue.
Definition: call.h:629
void FinishOp(bool *status)
Definition: call.h:538
void set_output_tag(void *return_tag)
Definition: call.h:615
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:469
This is an interface that Channel and Server implement to allow them to hook performing ops...
Definition: call_hook.h:44
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:285
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:191
virtual void * gpr_malloc(size_t size)=0