GRPC C++
1.39.1
|
#include <grpc/support/port_platform.h>
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include <grpc/compression.h>
#include <grpc/grpc.h>
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/compression/algorithm_metadata.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/gpr/alloc.h"
#include "src/core/lib/gpr/time_precise.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/arena.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/slice/slice_utils.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/call_test_only.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/surface/validate_metadata.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/transport/static_metadata.h"
#include "src/core/lib/transport/status_metadata.h"
#include "src/core/lib/transport/transport.h"
Data Structures | |
struct | batch_control |
struct | parent_call |
struct | child_call |
struct | grpc_call |
struct | cancel_state |
Macros | |
#define | MAX_CONCURRENT_BATCHES 6 |
The maximum number of concurrent batches possible. More... | |
#define | MAX_SEND_EXTRA_METADATA_COUNT 3 |
#define | ESTIMATED_MDELEM_COUNT 16 |
#define | RECV_NONE ((gpr_atm)0) |
#define | RECV_INITIAL_METADATA_FIRST ((gpr_atm)1) |
#define | CALL_STACK_FROM_CALL(call) |
#define | CALL_FROM_CALL_STACK(call_stack) |
#define | CALL_ELEM_FROM_CALL(call, idx) grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx) |
#define | CALL_FROM_TOP_ELEM(top_elem) CALL_FROM_CALL_STACK(grpc_call_stack_from_top_element(top_elem)) |
#define | REF_REASON reason |
#define | REF_ARG , const char* reason |
Variables | |
grpc_core::TraceFlag | grpc_call_error_trace (false, "call_error") |
grpc_core::TraceFlag | grpc_compression_trace (false, "compression") |
#define CALL_ELEM_FROM_CALL | ( | call, | |
idx | |||
) | grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx) |
#define CALL_FROM_CALL_STACK | ( | call_stack | ) |
#define CALL_FROM_TOP_ELEM | ( | top_elem | ) | CALL_FROM_CALL_STACK(grpc_call_stack_from_top_element(top_elem)) |
#define CALL_STACK_FROM_CALL | ( | call | ) |
#define ESTIMATED_MDELEM_COUNT 16 |
#define MAX_CONCURRENT_BATCHES 6 |
The maximum number of concurrent batches possible.
Based upon the maximum number of individually queueable ops in the batch api:
#define MAX_SEND_EXTRA_METADATA_COUNT 3 |
#define RECV_INITIAL_METADATA_FIRST ((gpr_atm)1) |
#define RECV_NONE ((gpr_atm)0) |
#define REF_ARG , const char* reason |
#define REF_REASON reason |
void* grpc_call_arena_alloc | ( | grpc_call * | call, |
size_t | size | ||
) |
Allocate memory in the grpc_call arena: this memory is automatically discarded at call completion.
grpc_call_error grpc_call_cancel | ( | grpc_call * | call, |
void * | reserved | ||
) |
Error handling for grpc_call Most grpc_call functions return a grpc_error.
If the error is not GRPC_OK then the operation failed due to some unsatisfied precondition. If a grpc_call fails, it's guaranteed that no change to the call state has been made. Cancel an RPC. Can be called multiple times, from any thread. THREAD-SAFETY grpc_call_cancel and grpc_call_cancel_with_status are thread-safe, and can be called at any point before grpc_call_unref is called.
void grpc_call_cancel_internal | ( | grpc_call * | call | ) |
grpc_call_error grpc_call_cancel_with_status | ( | grpc_call * | call, |
grpc_status_code | status, | ||
const char * | description, | ||
void * | reserved | ||
) |
Cancel an RPC.
Can be called multiple times, from any thread. If a status has not been received for the call, set it to the status code and description passed in. Importantly, this function does not send status nor description to the remote endpoint. Note that description doesn't need be a static string. It doesn't need to be alive after the call to grpc_call_cancel_with_status completes.
grpc_compression_algorithm grpc_call_compression_for_level | ( | grpc_call * | call, |
grpc_compression_level | level | ||
) |
void* grpc_call_context_get | ( | grpc_call * | call, |
grpc_context_index | elem | ||
) |
void grpc_call_context_set | ( | grpc_call * | call, |
grpc_context_index | elem, | ||
void * | value, | ||
void(*)(void *value) | destroy | ||
) |
grpc_error_handle grpc_call_create | ( | const grpc_call_create_args * | args, |
grpc_call ** | out_call | ||
) |
const char* grpc_call_error_to_string | ( | grpc_call_error | error | ) |
Convert grpc_call_error values to a string.
bool grpc_call_failed_before_recv_message | ( | const grpc_call * | c | ) |
grpc_call* grpc_call_from_top_element | ( | grpc_call_element * | surface_element | ) |
grpc_core::Arena* grpc_call_get_arena | ( | grpc_call * | call | ) |
grpc_call_stack* grpc_call_get_call_stack | ( | grpc_call * | call | ) |
size_t grpc_call_get_initial_size_estimate | ( | ) |
char* grpc_call_get_peer | ( | grpc_call * | call | ) |
Returns a newly allocated string representing the endpoint to which this call is communicating with.
The string is in the uri format accepted by grpc_channel_create. The returned string should be disposed of with gpr_free().
WARNING: this value is never authenticated or subject to any security related code. It must not be used for any authentication related functionality. Instead, use grpc_auth_context.
void grpc_call_internal_ref | ( | grpc_call * | c, |
const char * | reason | ||
) |
void grpc_call_internal_unref | ( | grpc_call * | c, |
const char * | reason | ||
) |
uint8_t grpc_call_is_client | ( | grpc_call * | call | ) |
bool grpc_call_is_trailers_only | ( | const grpc_call * | call | ) |
void grpc_call_ref | ( | grpc_call * | call | ) |
Ref a call.
THREAD SAFETY: grpc_call_ref is thread-compatible
void grpc_call_set_completion_queue | ( | grpc_call * | call, |
grpc_completion_queue * | cq | ||
) |
grpc_call_error grpc_call_start_batch | ( | grpc_call * | call, |
const grpc_op * | ops, | ||
size_t | nops, | ||
void * | tag, | ||
void * | reserved | ||
) |
Start a batch of operations defined in the array ops; when complete, post a completion of type 'tag' to the completion queue bound to the call.
The order of ops specified in the batch has no significance. Only one operation of each type can be active at once in any given batch. If a call to grpc_call_start_batch returns GRPC_CALL_OK you must call grpc_completion_queue_next or grpc_completion_queue_pluck on the completion queue associated with 'call' for work to be performed. If a call to grpc_call_start_batch returns any value other than GRPC_CALL_OK it is guaranteed that no state associated with 'call' is changed and it is not appropriate to call grpc_completion_queue_next or grpc_completion_queue_pluck consequent to the failed grpc_call_start_batch call. If a call to grpc_call_start_batch with an empty batch returns GRPC_CALL_OK, the tag is put in the completion queue immediately. THREAD SAFETY: access to grpc_call_start_batch in multi-threaded environment needs to be synchronized. As an optimization, you may synchronize batches containing just send operations independently from batches containing just receive operations. Access to grpc_call_start_batch with an empty batch is thread-compatible.
grpc_call_error grpc_call_start_batch_and_execute | ( | grpc_call * | call, |
const grpc_op * | ops, | ||
size_t | nops, | ||
grpc_closure * | closure | ||
) |
grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm | ( | grpc_call * | call | ) |
Return the message compression algorithm from call.
uint32_t grpc_call_test_only_get_encodings_accepted_by_peer | ( | grpc_call * | call | ) |
Returns a bitset for the encodings (compression algorithms) supported by call's peer.
To be indexed by grpc_compression_algorithm enum values.
grpc_stream_compression_algorithm grpc_call_test_only_get_incoming_stream_encodings | ( | grpc_call * | call | ) |
uint32_t grpc_call_test_only_get_message_flags | ( | grpc_call * | call | ) |
Return the message flags from call.
void grpc_call_unref | ( | grpc_call * | call | ) |
Unref a call.
THREAD SAFETY: grpc_call_unref is thread-compatible
grpc_core::TraceFlag grpc_call_error_trace(false, "call_error") | ( | false | , |
"call_error" | |||
) |
grpc_core::TraceFlag grpc_compression_trace(false, "compression") | ( | false | , |
"compression" | |||
) |