GRPC Core  0.11.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
call.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_INTERNAL_CORE_SURFACE_CALL_H
35 #define GRPC_INTERNAL_CORE_SURFACE_CALL_H
36 
39 #include <grpc/grpc.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /* Primitive operation types - grpc_op's get rewritten into these */
46 typedef enum {
60 
61 typedef union {
64  struct {
65  void (*set_value)(grpc_status_code status, void *user_data);
66  void *user_data;
67  } recv_status;
68  struct {
69  char **details;
71  } recv_status_details;
72  struct {
73  size_t count;
75  } send_metadata;
77  struct {
80  } send_status;
82 
83 typedef struct {
87 } grpc_ioreq;
88 
89 typedef void (*grpc_ioreq_completion_func)(grpc_call *call, int success,
90  void *user_data);
91 
92 grpc_call *grpc_call_create(grpc_channel *channel, grpc_call *parent_call,
93  gpr_uint32 propagation_mask,
95  const void *server_transport_data,
96  grpc_mdelem **add_initial_metadata,
97  size_t add_initial_metadata_count,
98  gpr_timespec send_deadline);
99 
102 
103 #ifdef GRPC_CALL_REF_COUNT_DEBUG
104 void grpc_call_internal_ref(grpc_call *call, const char *reason);
105 void grpc_call_internal_unref(grpc_call *call, const char *reason,
106  int allow_immediate_deletion);
107 #define GRPC_CALL_INTERNAL_REF(call, reason) \
108  grpc_call_internal_ref(call, reason)
109 #define GRPC_CALL_INTERNAL_UNREF(call, reason, allow_immediate_deletion) \
110  grpc_call_internal_unref(call, reason, allow_immediate_deletion)
111 #else
113 void grpc_call_internal_unref(grpc_call *call, int allow_immediate_deletion);
114 #define GRPC_CALL_INTERNAL_REF(call, reason) grpc_call_internal_ref(call)
115 #define GRPC_CALL_INTERNAL_UNREF(call, reason, allow_immediate_deletion) \
116  grpc_call_internal_unref(call, allow_immediate_deletion)
117 #endif
118 
120  grpc_call *call, const grpc_ioreq *reqs, size_t nreqs,
121  grpc_ioreq_completion_func on_complete, void *user_data);
122 
124 
125 /* Given the top call_element, get the call object. */
127 
128 extern int grpc_trace_batch;
129 
130 void grpc_call_log_batch(char *file, int line, gpr_log_severity severity,
131  grpc_call *call, const grpc_op *ops, size_t nops,
132  void *tag);
133 
134 void grpc_server_log_request_call(char *file, int line,
135  gpr_log_severity severity,
136  grpc_server *server, grpc_call **call,
137  grpc_call_details *details,
138  grpc_metadata_array *initial_metadata,
139  grpc_completion_queue *cq_bound_to_call,
140  grpc_completion_queue *cq_for_notification,
141  void *tag);
142 
143 void grpc_server_log_shutdown(char *file, int line, gpr_log_severity severity,
144  grpc_server *server, grpc_completion_queue *cq,
145  void *tag);
146 
147 /* Set a context pointer.
148  No thread safety guarantees are made wrt this value. */
150  void *value, void (*destroy)(void *value));
151 /* Get a context pointer. */
153 
154 #define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \
155  if (grpc_trace_batch) grpc_call_log_batch(sev, call, ops, nops, tag)
156 
157 #define GRPC_SERVER_LOG_REQUEST_CALL(sev, server, call, details, \
158  initial_metadata, cq_bound_to_call, \
159  cq_for_notifications, tag) \
160  if (grpc_trace_batch) \
161  grpc_server_log_request_call(sev, server, call, details, initial_metadata, \
162  cq_bound_to_call, cq_for_notifications, tag)
163 
164 #define GRPC_SERVER_LOG_SHUTDOWN(sev, server, cq, tag) \
165  if (grpc_trace_batch) grpc_server_log_shutdown(sev, server, cq, tag)
166 
168 
170  const grpc_call *call);
171 
173 
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_H */
Definition: call.h:56
const char * value
Definition: hpack_table.c:44
void grpc_server_log_shutdown(char *file, int line, gpr_log_severity severity, grpc_server *server, grpc_completion_queue *cq, void *tag)
Definition: call_log_batch.c:141
uint8_t gpr_uint8
Definition: port_platform.h:310
Definition: call.h:58
Definition: call.h:61
grpc_compression_algorithm
Definition: compression.h:50
Definition: channel.c:62
size_t * details_capacity
Definition: call.h:70
Definition: call.h:50
gpr_uint32 grpc_call_get_message_flags(const grpc_call *call)
Definition: call.c:576
Definition: metadata.h:70
void * grpc_call_context_get(grpc_call *call, grpc_context_index elem)
Definition: call.c:1743
Definition: grpc.h:254
Definition: byte_buffer.h:49
Definition: grpc.h:245
uint32_t gpr_uint32
Definition: port_platform.h:312
grpc_ioreq_op op
Definition: call.h:84
void(* grpc_ioreq_completion_func)(grpc_call *call, int success, void *user_data)
Definition: call.h:89
size_t count
Definition: call.h:73
gpr_log_severity
Definition: log.h:56
void grpc_server_log_request_call(char *file, int line, gpr_log_severity severity, grpc_server *server, grpc_call **call, grpc_call_details *details, grpc_metadata_array *initial_metadata, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag)
Definition: call_log_batch.c:125
grpc_call_error grpc_call_start_ioreq_and_call_back(grpc_call *call, const grpc_ioreq *reqs, size_t nreqs, grpc_ioreq_completion_func on_complete, void *user_data)
Definition: call.c:1280
Definition: call.h:51
grpc_call_error
Result of a grpc call.
Definition: grpc.h:162
grpc_status_code code
Definition: call.h:78
grpc_metadata * metadata
Definition: call.h:74
char ** details
Definition: call.h:69
grpc_call_stack * grpc_call_get_call_stack(grpc_call *call)
Definition: call.c:1535
A single metadata element.
Definition: grpc.h:207
void grpc_call_internal_ref(grpc_call *call)
Definition: call.c:457
Definition: metadata.h:78
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc.h:311
grpc_ioreq_op
Definition: call.h:46
gpr_uint32 flags
A copy of the write flags from grpc_op.
Definition: call.h:85
gpr_uint8 grpc_call_is_client(grpc_call *call)
Definition: call.c:1747
grpc_metadata_array * recv_metadata
Definition: call.h:62
Definition: completion_queue.c:54
void grpc_call_set_completion_queue(grpc_call *call, grpc_completion_queue *cq)
Definition: call.c:415
void grpc_call_log_batch(char *file, int line, gpr_log_severity severity, grpc_call *call, const grpc_op *ops, size_t nops, void *tag)
Definition: call_log_batch.c:110
grpc_ioreq_data data
Definition: call.h:86
grpc_compression_algorithm grpc_call_get_compression_algorithm(const grpc_call *call)
Definition: call.c:536
void grpc_call_context_set(grpc_call *call, grpc_context_index elem, void *value, void(*destroy)(void *value))
Definition: call.c:1734
grpc_call * grpc_call_create(grpc_channel *channel, grpc_call *parent_call, gpr_uint32 propagation_mask, grpc_completion_queue *cq, const void *server_transport_data, grpc_mdelem **add_initial_metadata, size_t add_initial_metadata_count, gpr_timespec send_deadline)
Definition: call.c:307
Definition: channel_stack.h:141
gpr_uint32 grpc_call_get_encodings_accepted_by_peer(grpc_call *call)
Returns a bitset for the encodings (compression algorithms) supported by call's peer.
Definition: call.c:572
void grpc_call_internal_unref(grpc_call *call, int allow_immediate_deletion)
Definition: call.c:505
grpc_context_index
Definition: context.h:38
grpc_byte_buffer ** recv_message
Definition: call.h:63
grpc_mdstr * details
Definition: call.h:79
grpc_byte_buffer * send_message
Definition: call.h:76
grpc_call * grpc_call_from_top_element(grpc_call_element *surface_element)
Definition: call.c:1394
Definition: time.h:63
grpc_status_code
Definition: status.h:41
Definition: channel_stack.h:124
Definition: call.h:48
grpc_completion_queue * grpc_call_get_completion_queue(grpc_call *call)
Definition: call.c:425
Definition: call.h:52
void * user_data
Definition: call.h:66
Definition: call.h:57
int grpc_trace_batch
Definition: call_log_batch.c:40
Definition: call.c:144
Definition: call.h:54
Definition: call.h:83
Definition: server.c:181