19 #ifndef GRPCXX_IMPL_CODEGEN_CALL_H
20 #define GRPCXX_IMPL_CODEGEN_CALL_H
58 const std::multimap<grpc::string, grpc::string>& metadata,
59 size_t* metadata_count,
const grpc::string& optional_error_details) {
60 *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
61 if (*metadata_count == 0) {
68 for (
auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
72 if (!optional_error_details.empty()) {
73 metadata_array[i].
key =
78 return metadata_array;
87 : flags_(other.flags_), last_message_(other.last_message_) {}
90 inline void Clear() { flags_ = 0; }
93 inline uint32_t
flags()
const {
return flags_; }
163 last_message_ =
true;
170 last_message_ =
false;
195 void SetBit(
const uint32_t mask) { flags_ |= mask; }
197 void ClearBit(
const uint32_t mask) { flags_ &= ~mask; }
199 bool GetBit(
const uint32_t mask)
const {
return (flags_ & mask) != 0; }
223 const std::multimap<grpc::string, grpc::string>& metadata,
300 if (!send_buf_.
Valid())
return;
307 write_options_.
Clear();
318 write_options_ = options;
325 message, send_buf_.bbuf_ptr(), &own_buf);
343 allow_not_getting_message_(false) {}
354 if (message_ ==
nullptr)
return;
363 if (message_ ==
nullptr)
return;
364 if (recv_buf_.
Valid()) {
376 if (!allow_not_getting_message_) {
386 bool allow_not_getting_message_;
396 class DeserializeFuncType final :
public DeserializeFunc {
412 :
got_message(false), allow_not_getting_message_(false) {}
419 deserialize_.reset(func);
429 if (!deserialize_)
return;
438 if (!deserialize_)
return;
439 if (recv_buf_.
Valid()) {
442 *status = deserialize_->Deserialize(&recv_buf_).ok();
450 if (!allow_not_getting_message_) {
454 deserialize_.reset();
458 std::unique_ptr<DeserializeFunc> deserialize_;
460 bool allow_not_getting_message_;
488 const std::multimap<grpc::string, grpc::string>& trailing_metadata,
492 trailing_metadata, &trailing_metadata_count_, send_error_details_);
493 send_status_available_ =
true;
500 if (!send_status_available_)
return;
504 trailing_metadata_count_;
509 send_error_message_.empty() ?
nullptr : &error_message_slice_;
515 if (!send_status_available_)
return;
517 send_status_available_ =
false;
521 bool send_status_available_;
525 size_t trailing_metadata_count_;
535 context->initial_metadata_received_ =
true;
536 metadata_map_ = &context->recv_initial_metadata_;
541 if (metadata_map_ ==
nullptr)
return;
550 if (metadata_map_ ==
nullptr)
return;
552 metadata_map_ =
nullptr;
564 metadata_map_ = &context->trailing_metadata_;
565 recv_status_ = status;
571 if (recv_status_ ==
nullptr)
return;
583 if (recv_status_ ==
nullptr)
return;
587 if (iter != metadata_map_->
map()->end()) {
588 binary_error_details =
589 grpc::string(iter->second.begin(), iter->second.length());
591 *recv_status_ =
Status(static_cast<StatusCode>(status_code_),
594 binary_error_details);
596 recv_status_ =
nullptr;
624 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
625 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
626 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
637 this->Op1::AddOp(ops, nops);
638 this->Op2::AddOp(ops, nops);
639 this->Op3::AddOp(ops, nops);
640 this->Op4::AddOp(ops, nops);
641 this->Op5::AddOp(ops, nops);
642 this->Op6::AddOp(ops, nops);
648 this->Op1::FinishOp(status);
649 this->Op2::FinishOp(status);
650 this->Op3::FinishOp(status);
651 this->Op4::FinishOp(status);
652 this->Op5::FinishOp(status);
653 this->Op6::FinishOp(status);
671 template <
class Op1 = CallNoOp<1>,
class Op2 = CallNoOp<2>,
672 class Op3 = CallNoOp<3>,
class Op4 = CallNoOp<4>,
673 class Op5 = CallNoOp<5>,
class Op6 = CallNoOp<6>>
678 return Base::FinalizeResult(tag, status) &&
false;
687 : call_hook_(call_hook),
690 max_receive_message_size_(-1) {}
694 : call_hook_(call_hook),
697 max_receive_message_size_(max_receive_message_size) {}
712 int max_receive_message_size_;
717 #endif // GRPCXX_IMPL_CODEGEN_CALL_H
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:500
void Clear()
Remove all data.
Definition: byte_buffer.h:72
union grpc_op::grpc_op_data data
bool is_corked() const
Definition: call.h:155
void * reserved
Reserved for future usage.
Definition: grpc_types.h:504
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:132
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:123
void FinishOp(bool *status)
Definition: call.h:514
void ClientSendClose()
Definition: call.h:467
virtual void grpc_call_ref(grpc_call *call)=0
grpc::string error_message() const
Return the instance's error message.
Definition: status.h:58
CallOpRecvMessage()
Definition: call.h:340
std::string string
Definition: config.h:35
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:106
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:553
struct grpc_byte_buffer * send_message
This op takes ownership of the slices in send_message.
Definition: grpc_types.h:530
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:465
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:470
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:26
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:299
void AllowNoMessage()
Definition: call.h:423
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:162
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:365
Status Deserialize(ByteBuffer *buf) override
Definition: call.h:399
grpc_stream_compression_level
Compression levels for stream compression algorithms.
Definition: compression_types.h:106
struct grpc_op::grpc_op_data::grpc_op_recv_message recv_message
Primary implementaiton of CallOpSetInterface.
Definition: call.h:627
#define GRPC_WRITE_THROUGH
Force this message to be written to the socket before completing it.
Definition: grpc_types.h:367
const char ** error_string
If this is not nullptr, it will be populated with the full fidelity error string for debugging purpos...
Definition: grpc_types.h:567
grpc_slice * status_details
Definition: grpc_types.h:563
void Clear()
Clear all flags.
Definition: call.h:90
virtual grpc_slice grpc_empty_slice()=0
WriteOptions & set_write_through()
Guarantee that all bytes have been written to the wire before completing this write (usually writes a...
Definition: call.h:176
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:81
#define GRPC_WRITE_BUFFER_HINT
Write Flags:
Definition: grpc_types.h:362
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
call is owned by the caller
Definition: call.h:686
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:460
bool got_message
Definition: call.h:350
virtual void grpc_call_unref(grpc_call *call)=0
void Duplicate()
Make a duplicate copy of the internals of this byte buffer so that we have our own owned version of i...
Definition: byte_buffer.h:82
WriteOptions()
Definition: call.h:85
WriteOptions & clear_last_message()
Clears flag indicating that this is the last message in a stream, disabling coalescing.
Definition: call.h:169
grpc_slice SliceReferencingString(const grpc::string &str)
Definition: slice.h:116
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:563
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:97
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:93
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:117
bool is_write_through() const
Definition: call.h:181
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:561
WriteOptions & clear_corked()
Definition: call.h:150
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:98
#define GRPC_SLICE_END_PTR(slice)
Definition: slice.h:126
CallOpClientSendClose()
Definition: call.h:465
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:162
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:189
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:570
Definition: byte_buffer.h:45
int max_receive_message_size() const
Definition: call.h:706
bool Valid() const
Is this ByteBuffer valid?
Definition: byte_buffer.h:97
Default argument for CallOpSet.
Definition: call.h:209
void FinishOp(bool *status)
Definition: call.h:582
A CallOpSet that does not post completions to the completion queue.
Definition: call.h:674
bool got_message
Definition: call.h:425
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:58
virtual void FillOps(grpc_call *call, grpc_op *ops, size_t *nops)=0
Fills in grpc_op, starting from ops[*nops] and moving upwards.
CallOpServerSendStatus()
Definition: call.h:485
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:647
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:115
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:428
void Release()
Forget underlying byte buffer without destroying Use this only for un-owned byte buffers.
Definition: byte_buffer.h:88
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:317
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata, size_t *metadata_count, const grpc::string &optional_error_details)
Definition: call.h:57
struct grpc_op::grpc_op_data::grpc_op_recv_initial_metadata recv_initial_metadata
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_receive_message_size)
Definition: call.h:692
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata send_initial_metadata
void FinishOp(bool *status)
Definition: call.h:437
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:498
virtual void PerformOpsOnCall(CallOpSetInterface *ops, Call *call)=0
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:475
void RecvMessage(R *message)
Definition: call.h:415
struct grpc_op::grpc_op_data::grpc_op_send_message send_message
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:46
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:499
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:456
WriteOptions(const WriteOptions &other)
Definition: call.h:86
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:470
CallOpClientRecvStatus()
Definition: call.h:561
Definition: byte_buffer.h:37
void FinishOp(bool *status)
Definition: call.h:477
Per-message write options.
Definition: call.h:83
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:539
void AllowNoMessage()
Definition: call.h:348
size_t trailing_metadata_count
Definition: grpc_types.h:533
CallOpSendMessage()
Definition: call.h:287
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:141
void FinishOp(bool *status)
Definition: call.h:212
StatusCode error_code() const
Return the instance's error code.
Definition: status.h:56
void FinishOp(bool *status)
Definition: call.h:362
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:94
grpc_call * call() const
Definition: call.h:703
virtual Status Deserialize(ByteBuffer *buf)=0
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:611
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:636
virtual void grpc_slice_unref(grpc_slice slice)=0
void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:487
virtual ~DeserializeFunc()
Definition: call.h:392
void RecvMessage(R *message)
Definition: call.h:345
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:61
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 set_output_tag(void *return_tag)
Definition: call.h:660
WriteOptions & set_corked()
corked bit: aliases set_buffer_hint currently, with the intent that set_buffer_hint will be removed i...
Definition: call.h:145
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:676
CompletionQueue * cq() const
Definition: call.h:704
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:211
Did it work? If it didn't, why?
Definition: status.h:30
void FinishOp(bool *status)
Definition: call.h:309
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:485
DeserializeFuncType(R *message)
Definition: call.h:398
grpc_status_code status
Definition: grpc_types.h:535
grpc_status_code * status
Definition: grpc_types.h:562
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:699
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:502
virtual void gpr_free(void *p)=0
This is an interface that Channel and Server implement to allow them to hook performing ops...
Definition: call_hook.h:30
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:479
A sequence of bytes.
Definition: byte_buffer.h:48
CallOpGenericRecvMessage()
Definition: call.h:411
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:353
CallOpSet()
Definition: call.h:635
const char kBinaryErrorDetailsKey[]
Definition: call.h:53
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:187
Straightforward wrapping of the C call object.
Definition: call.h:683
grpc_metadata * trailing_metadata
Definition: grpc_types.h:534
struct grpc_op::grpc_op_data::grpc_op_recv_status_on_client recv_status_on_client
virtual void * gpr_malloc(size_t size)=0
~DeserializeFuncType() override
Definition: call.h:403