GRPC Core 0.10.0.0

- Main Page
- Data Structures
- Files

- File List
- Globals

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
37 #include "src/core/channel/channel_stack.h"
38 #include "src/core/channel/context.h"
39 #include <grpc/grpc.h>
40
41 /* Primitive operation types - grpc_op's get rewritten into these */
42 typedef enum {
43 GRPC_IOREQ_RECV_INITIAL_METADATA,
44 GRPC_IOREQ_RECV_MESSAGE,
45 GRPC_IOREQ_RECV_TRAILING_METADATA,
46 GRPC_IOREQ_RECV_STATUS,
47 GRPC_IOREQ_RECV_STATUS_DETAILS,
48 GRPC_IOREQ_RECV_CLOSE,
49 GRPC_IOREQ_SEND_INITIAL_METADATA,
50 GRPC_IOREQ_SEND_MESSAGE,
51 GRPC_IOREQ_SEND_TRAILING_METADATA,
52 GRPC_IOREQ_SEND_STATUS,
53 GRPC_IOREQ_SEND_CLOSE,
54 GRPC_IOREQ_OP_COUNT
55 } grpc_ioreq_op;
56
57 typedef union {
58 grpc_metadata_array *recv_metadata;
59 grpc_byte_buffer **recv_message;
60 struct {
61 void (*set_value)(grpc_status_code status, void *user_data);
62 void *user_data;
63 } recv_status;
64 struct {
65 char **details;
66 size_t *details_capacity;
67 } recv_status_details;
68 struct {
69 size_t count;
70 grpc_metadata *metadata;
71 } send_metadata;
72 grpc_byte_buffer *send_message;
73 struct {
74 grpc_status_code code;
75 grpc_mdstr *details;
76 } send_status;
77 } grpc_ioreq_data;
78
79 typedef struct {
80 grpc_ioreq_op op;
81 gpr_uint32 flags;
82 grpc_ioreq_data data;
83 } grpc_ioreq;
84
85 typedef void (*grpc_ioreq_completion_func)(grpc_call *call, int success,
86 void *user_data);
87
88 grpc_call *grpc_call_create(grpc_channel *channel, grpc_completion_queue *cq,
89 const void *server_transport_data,
90 grpc_mdelem **add_initial_metadata,
91 size_t add_initial_metadata_count,
92 gpr_timespec send_deadline);
93
94 void grpc_call_set_completion_queue(grpc_call *call, grpc_completion_queue *cq);
95 grpc_completion_queue *grpc_call_get_completion_queue(grpc_call *call);
96
97 #ifdef GRPC_CALL_REF_COUNT_DEBUG
98 void grpc_call_internal_ref(grpc_call *call, const char *reason);
99 void grpc_call_internal_unref(grpc_call *call, const char *reason,
100 int allow_immediate_deletion);
101 #define GRPC_CALL_INTERNAL_REF(call, reason) \
102 grpc_call_internal_ref(call, reason)
103 #define GRPC_CALL_INTERNAL_UNREF(call, reason, allow_immediate_deletion) \
104 grpc_call_internal_unref(call, reason, allow_immediate_deletion)
105 #else
106 void grpc_call_internal_ref(grpc_call *call);
107 void grpc_call_internal_unref(grpc_call *call, int allow_immediate_deletion);
108 #define GRPC_CALL_INTERNAL_REF(call, reason) grpc_call_internal_ref(call)
109 #define GRPC_CALL_INTERNAL_UNREF(call, reason, allow_immediate_deletion) \
110 grpc_call_internal_unref(call, allow_immediate_deletion)
111 #endif
112
113 grpc_call_error grpc_call_start_ioreq_and_call_back(
114 grpc_call *call, const grpc_ioreq *reqs, size_t nreqs,
115 grpc_ioreq_completion_func on_complete, void *user_data);
116
117 grpc_call_stack *grpc_call_get_call_stack(grpc_call *call);
118
119 /* Given the top call_element, get the call object. */
120 grpc_call *grpc_call_from_top_element(grpc_call_element *surface_element);
121
122 extern int grpc_trace_batch;
123
124 void grpc_call_log_batch(char *file, int line, gpr_log_severity severity,
125 grpc_call *call, const grpc_op *ops, size_t nops,
126 void *tag);
127
128 void grpc_server_log_request_call(char *file, int line,
129 gpr_log_severity severity,
130 grpc_server *server, grpc_call **call,
131 grpc_call_details *details,
132 grpc_metadata_array *initial_metadata,
133 grpc_completion_queue *cq_bound_to_call,
134 grpc_completion_queue *cq_for_notification,
135 void *tag);
136
137 void grpc_server_log_shutdown(char *file, int line, gpr_log_severity severity,
138 grpc_server *server, grpc_completion_queue *cq,
139 void *tag);
140
141 /* Set a context pointer.
142 No thread safety guarantees are made wrt this value. */
143 void grpc_call_context_set(grpc_call *call, grpc_context_index elem,
144 void *value, void (*destroy)(void *value));
145 /* Get a context pointer. */
146 void *grpc_call_context_get(grpc_call *call, grpc_context_index elem);
147
148 #define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \
149 if (grpc_trace_batch) grpc_call_log_batch(sev, call, ops, nops, tag)
150
151 #define GRPC_SERVER_LOG_REQUEST_CALL(sev, server, call, details, \
152 initial_metadata, cq_bound_to_call, \
153 cq_for_notifications, tag) \
154 if (grpc_trace_batch) \
155 grpc_server_log_request_call(sev, server, call, details, initial_metadata, \
156 cq_bound_to_call, cq_for_notifications, tag)
157
158 #define GRPC_SERVER_LOG_SHUTDOWN(sev, server, cq, tag) \
159 if (grpc_trace_batch) grpc_server_log_shutdown(sev, server, cq, tag)
160
161 gpr_uint8 grpc_call_is_client(grpc_call *call);
162
163 #endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_H */
GRPC_IOREQ_SEND_STATUS
Definition: call.h:52
value
const char * value
Definition: hpack_table.c:44
grpc_call_create
grpc_call * grpc_call_create(grpc_channel *channel, 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:293
grpc_server_log_shutdown
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:140
gpr_uint8
uint8_t gpr_uint8
Definition: port_platform.h:307
GRPC_IOREQ_OP_COUNT
Definition: call.h:54
grpc_ioreq_data
Definition: call.h:57
grpc_channel
Definition: channel.c:61
GRPC_IOREQ_RECV_TRAILING_METADATA
Definition: call.h:45
grpc_ioreq_data::details_capacity
size_t * details_capacity
Definition: call.h:66
GRPC_IOREQ_RECV_STATUS
Definition: call.h:46
channel_stack.h
grpc_mdstr
Definition: metadata.h:70
grpc_call_context_get
void * grpc_call_context_get(grpc_call *call, grpc_context_index elem)
Definition: call.c:1583
grpc_call_details
Definition: grpc.h:244
grpc_byte_buffer
Definition: byte_buffer.h:49
grpc_metadata_array
Definition: grpc.h:235
gpr_uint32
uint32_t gpr_uint32
Definition: port_platform.h:309
grpc_ioreq::op
grpc_ioreq_op op
Definition: call.h:80
grpc_ioreq_completion_func
void(* grpc_ioreq_completion_func)(grpc_call *call, int success, void *user_data)
Definition: call.h:85
grpc_ioreq_data::count
size_t count
Definition: call.h:69
gpr_log_severity
gpr_log_severity
Definition: log.h:56
grpc_server_log_request_call
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:124
grpc_call_start_ioreq_and_call_back
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:1167
GRPC_IOREQ_RECV_STATUS_DETAILS
Definition: call.h:47
grpc_call_error
grpc_call_error
Result of a grpc call.
Definition: grpc.h:156
grpc_ioreq_data::code
grpc_status_code code
Definition: call.h:74
grpc_ioreq_data::metadata
grpc_metadata * metadata
Definition: call.h:70
grpc_ioreq_data::details
char ** details
Definition: call.h:65
grpc_call_get_call_stack
grpc_call_stack * grpc_call_get_call_stack(grpc_call *call)
Definition: call.c:1397
grpc_metadata
A single metadata element.
Definition: grpc.h:197
grpc_call_internal_ref
void grpc_call_internal_ref(grpc_call *call)
Definition: call.c:399
grpc_mdelem
Definition: metadata.h:78
grpc_op
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc.h:287
grpc_ioreq_op
grpc_ioreq_op
Definition: call.h:42
grpc_ioreq::flags
gpr_uint32 flags
A copy of the write flags from grpc_op.
Definition: call.h:81
grpc_call_is_client
gpr_uint8 grpc_call_is_client(grpc_call *call)
Definition: call.c:1587
grpc_ioreq_data::recv_metadata
grpc_metadata_array * recv_metadata
Definition: call.h:58
grpc_completion_queue
Definition: completion_queue.c:49
grpc_call_set_completion_queue
void grpc_call_set_completion_queue(grpc_call *call, grpc_completion_queue *cq)
Definition: call.c:357
GRPC_IOREQ_RECV_INITIAL_METADATA
Definition: call.h:43
grpc_call_log_batch
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
grpc_ioreq_data data
Definition: call.h:82
context.h
grpc_call_context_set
void grpc_call_context_set(grpc_call *call, grpc_context_index elem, void *value, void(*destroy)(void *value))
Definition: call.c:1574
grpc_call_stack
Definition: channel_stack.h:141
grpc_call_internal_unref
void grpc_call_internal_unref(grpc_call *call, int allow_immediate_deletion)
Definition: call.c:447
grpc_context_index
grpc_context_index
Definition: context.h:38
grpc_ioreq_data::recv_message
grpc_byte_buffer ** recv_message
Definition: call.h:59
grpc_ioreq_data::details
grpc_mdstr * details
Definition: call.h:75
GRPC_IOREQ_SEND_TRAILING_METADATA
Definition: call.h:51
grpc_ioreq_data::send_message
grpc_byte_buffer * send_message
Definition: call.h:72
grpc_call_from_top_element
grpc_call * grpc_call_from_top_element(grpc_call_element *surface_element)
Definition: call.c:1261
gpr_timespec
Definition: time.h:60
grpc_status_code
grpc_status_code
Definition: status.h:41
grpc_call_element
Definition: channel_stack.h:124
GRPC_IOREQ_RECV_MESSAGE
Definition: call.h:44
grpc_call_get_completion_queue
grpc_completion_queue * grpc_call_get_completion_queue(grpc_call *call)
Definition: call.c:367
GRPC_IOREQ_RECV_CLOSE
Definition: call.h:48
grpc_ioreq_data::user_data
void * user_data
Definition: call.h:62
GRPC_IOREQ_SEND_CLOSE
Definition: call.h:53
grpc.h
GRPC_IOREQ_SEND_INITIAL_METADATA
Definition: call.h:49
grpc_trace_batch
int grpc_trace_batch
Definition: call_log_batch.c:40
grpc_call
Definition: call.c:143
GRPC_IOREQ_SEND_MESSAGE
Definition: call.h:50
grpc_ioreq
Definition: call.h:79
grpc_server
Definition: server.c:181