GRPC Core  18.0.0
call.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_SURFACE_CALL_H
20 #define GRPC_CORE_LIB_SURFACE_CALL_H
21 
23 
29 
30 #include <grpc/grpc.h>
32 
33 typedef void (*grpc_ioreq_completion_func)(grpc_call* call, int success,
34  void* user_data);
35 
36 typedef struct grpc_call_create_args {
39 
41  uint32_t propagation_mask;
42 
44  /* if not NULL, it'll be used in lieu of cq */
46 
47  const void* server_transport_data;
48 
51 
54 
55 /* Create a new call based on \a args.
56  Regardless of success or failure, always returns a valid new call into *call
57  */
59  grpc_call** call);
60 
62 
63 #ifndef NDEBUG
64 void grpc_call_internal_ref(grpc_call* call, const char* reason);
65 void grpc_call_internal_unref(grpc_call* call, const char* reason);
66 #define GRPC_CALL_INTERNAL_REF(call, reason) \
67  grpc_call_internal_ref(call, reason)
68 #define GRPC_CALL_INTERNAL_UNREF(call, reason) \
69  grpc_call_internal_unref(call, reason)
70 #else
73 #define GRPC_CALL_INTERNAL_REF(call, reason) grpc_call_internal_ref(call)
74 #define GRPC_CALL_INTERNAL_UNREF(call, reason) grpc_call_internal_unref(call)
75 #endif
76 
78 
80 
82  const grpc_op* ops,
83  size_t nops,
85 
86 /* gRPC core internal version of grpc_call_cancel that does not create
87  * exec_ctx. */
89 
90 /* Given the top call_element, get the call object. */
92 
93 void grpc_call_log_batch(const char* file, int line, gpr_log_severity severity,
94  const grpc_op* ops, size_t nops);
95 
96 /* Set a context pointer.
97  No thread safety guarantees are made wrt this value. */
98 /* TODO(#9731): add exec_ctx to destroy */
100  void* value, void (*destroy)(void* value));
101 /* Get a context pointer. */
103 
104 #define GRPC_CALL_LOG_BATCH(sev, ops, nops) \
105  do { \
106  if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \
107  grpc_call_log_batch(sev, ops, nops); \
108  } \
109  } while (0)
110 
111 uint8_t grpc_call_is_client(grpc_call* call);
112 
113 /* Get the estimated memory size for a call BESIDES the call stack. Combined
114  * with the size of the call stack, it helps estimate the arena size for the
115  * initial call. */
117 
118 /* Return an appropriate compression algorithm for the requested compression \a
119  * level in the context of \a call. */
121  grpc_call* call, grpc_compression_level level);
122 
123 /* Did this client call receive a trailers-only response */
124 /* TODO(markdroth): This is currently available only to the C++ API.
125  Move to surface API if requested by other languages. */
126 bool grpc_call_is_trailers_only(const grpc_call* call);
127 
128 /* Returns whether or not the call's receive message operation failed because of
129  * an error (as opposed to a graceful end-of-stream) */
130 /* TODO(markdroth): This is currently available only to the C++ API.
131  Move to surface API if requested by other languages. */
133 
136 
137 #endif /* GRPC_CORE_LIB_SURFACE_CALL_H */
void * grpc_call_context_get(grpc_call *call, grpc_context_index elem)
Definition: call.cc:2012
grpc_core::Arena * grpc_call_get_arena(grpc_call *call)
Definition: call.cc:1099
grpc_call_stack * grpc_call_get_call_stack(grpc_call *call)
Definition: call.cc:1101
void grpc_call_internal_ref(grpc_call *call, const char *reason)
Definition: call.cc:524
void grpc_call_set_completion_queue(grpc_call *call, grpc_completion_queue *cq)
Definition: call.cc:502
size_t grpc_call_get_initial_size_estimate()
Definition: call.cc:337
grpc_call_error grpc_call_start_batch_and_execute(grpc_call *call, const grpc_op *ops, size_t nops, grpc_closure *closure)
Definition: call.cc:1996
bool grpc_call_failed_before_recv_message(const grpc_call *c)
Definition: call.cc:2033
struct grpc_call_create_args grpc_call_create_args
grpc_core::TraceFlag grpc_call_error_trace
grpc_core::TraceFlag grpc_compression_trace
void grpc_call_log_batch(const char *file, int line, gpr_log_severity severity, const grpc_op *ops, size_t nops)
Definition: call_log_batch.cc:105
void(* grpc_ioreq_completion_func)(grpc_call *call, int success, void *user_data)
Definition: call.h:33
grpc_call * grpc_call_from_top_element(grpc_call_element *surface_element)
Definition: call.cc:666
bool grpc_call_is_trailers_only(const grpc_call *call)
Definition: call.cc:2025
grpc_error_handle grpc_call_create(const grpc_call_create_args *args, grpc_call **call)
Definition: call.cc:342
void grpc_call_cancel_internal(grpc_call *call)
Definition: call.cc:726
void grpc_call_context_set(grpc_call *call, grpc_context_index elem, void *value, void(*destroy)(void *value))
Definition: call.cc:2003
grpc_compression_algorithm grpc_call_compression_for_level(grpc_call *call, grpc_compression_level level)
Definition: call.cc:2018
uint8_t grpc_call_is_client(grpc_call *call)
Definition: call.cc:2016
void grpc_call_internal_unref(grpc_call *call, const char *reason)
Definition: call.cc:527
Definition: arena.h:44
Definition: server.h:43
Definition: trace.h:61
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:71
grpc_compression_algorithm
The various compression algorithms supported by gRPC (not sorted by compression level)
Definition: compression_types.h:57
grpc_context_index
Call object context pointers.
Definition: context.h:27
int64_t grpc_millis
Definition: exec_ctx.h:37
grpc_call_error
Result of a grpc call.
Definition: grpc_types.h:441
gpr_log_severity
GPR log API.
Definition: log.h:43
struct grpc_pollset_set grpc_pollset_set
Definition: pollset_set.h:31
grpc_closure closure
Definition: server.cc:460
Definition: call.h:36
size_t add_initial_metadata_count
Definition: call.h:50
grpc_core::Server * server
Definition: call.h:38
grpc_completion_queue * cq
Definition: call.h:43
uint32_t propagation_mask
Definition: call.h:41
grpc_pollset_set * pollset_set_alternative
Definition: call.h:45
grpc_mdelem * add_initial_metadata
Definition: call.h:49
grpc_millis send_deadline
Definition: call.h:52
const void * server_transport_data
Definition: call.h:47
grpc_call * parent
Definition: call.h:40
grpc_channel * channel
Definition: call.h:37
Definition: channel_stack.h:174
Definition: channel_stack.h:192
Definition: call.cc:139
Definition: channel.h:105
A closure over a grpc_iomgr_cb_func.
Definition: closure.h:56
Definition: completion_queue.cc:339
Definition: error_internal.h:41
Definition: metadata.h:98
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments)
Definition: grpc_types.h:624