Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Craig Tiller | 9a4dddd | 2016-03-25 17:08:13 -0700 | [diff] [blame] | 19 | #ifndef GRPC_CORE_LIB_SURFACE_CALL_H |
| 20 | #define GRPC_CORE_LIB_SURFACE_CALL_H |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 21 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 22 | #include "src/core/lib/channel/channel_stack.h" |
| 23 | #include "src/core/lib/channel/context.h" |
| 24 | #include "src/core/lib/surface/api_trace.h" |
David Garcia Quintas | 13c2f6e | 2016-03-17 22:51:52 -0700 | [diff] [blame] | 25 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 26 | #include <grpc/grpc.h> |
David Garcia Quintas | 13c2f6e | 2016-03-17 22:51:52 -0700 | [diff] [blame] | 27 | #include <grpc/impl/codegen/compression_types.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 28 | |
David Garcia Quintas | 9c512bd | 2015-07-20 23:43:53 -0700 | [diff] [blame] | 29 | #ifdef __cplusplus |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 30 | extern "C" { |
David Garcia Quintas | 9c512bd | 2015-07-20 23:43:53 -0700 | [diff] [blame] | 31 | #endif |
| 32 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 33 | typedef void (*grpc_ioreq_completion_func)(grpc_exec_ctx *exec_ctx, |
| 34 | grpc_call *call, int success, |
| 35 | void *user_data); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 36 | |
Craig Tiller | 8e21465 | 2016-08-19 09:54:31 -0700 | [diff] [blame] | 37 | typedef struct grpc_call_create_args { |
| 38 | grpc_channel *channel; |
| 39 | |
| 40 | grpc_call *parent_call; |
| 41 | uint32_t propagation_mask; |
| 42 | |
| 43 | grpc_completion_queue *cq; |
| 44 | /* if not NULL, it'll be used in lieu of cq */ |
| 45 | grpc_pollset_set *pollset_set_alternative; |
| 46 | |
| 47 | const void *server_transport_data; |
| 48 | |
Craig Tiller | 7c70b6c | 2017-01-23 07:48:42 -0800 | [diff] [blame] | 49 | grpc_mdelem *add_initial_metadata; |
Craig Tiller | 8e21465 | 2016-08-19 09:54:31 -0700 | [diff] [blame] | 50 | size_t add_initial_metadata_count; |
| 51 | |
| 52 | gpr_timespec send_deadline; |
| 53 | } grpc_call_create_args; |
| 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 | */ |
Craig Tiller | a59c16c | 2016-10-31 07:25:01 -0700 | [diff] [blame] | 58 | grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx, |
| 59 | const grpc_call_create_args *args, |
Craig Tiller | 8e21465 | 2016-08-19 09:54:31 -0700 | [diff] [blame] | 60 | grpc_call **call); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 61 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 62 | void grpc_call_set_completion_queue(grpc_exec_ctx *exec_ctx, grpc_call *call, |
| 63 | grpc_completion_queue *cq); |
Craig Tiller | 166e250 | 2015-02-03 20:14:41 -0800 | [diff] [blame] | 64 | |
ncteisen | 9c43fc0 | 2017-06-08 16:06:23 -0700 | [diff] [blame] | 65 | #ifndef NDEBUG |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 66 | void grpc_call_internal_ref(grpc_call *call, const char *reason); |
| 67 | void grpc_call_internal_unref(grpc_exec_ctx *exec_ctx, grpc_call *call, |
| 68 | const char *reason); |
Craig Tiller | 16a3e13 | 2015-05-29 22:33:28 -0700 | [diff] [blame] | 69 | #define GRPC_CALL_INTERNAL_REF(call, reason) \ |
| 70 | grpc_call_internal_ref(call, reason) |
Craig Tiller | 9f7dc3a | 2015-09-22 10:47:08 -0700 | [diff] [blame] | 71 | #define GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, reason) \ |
| 72 | grpc_call_internal_unref(exec_ctx, call, reason) |
Craig Tiller | 4df412b | 2015-04-28 07:57:54 -0700 | [diff] [blame] | 73 | #else |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 74 | void grpc_call_internal_ref(grpc_call *call); |
| 75 | void grpc_call_internal_unref(grpc_exec_ctx *exec_ctx, grpc_call *call); |
Craig Tiller | 4df412b | 2015-04-28 07:57:54 -0700 | [diff] [blame] | 76 | #define GRPC_CALL_INTERNAL_REF(call, reason) grpc_call_internal_ref(call) |
Craig Tiller | 9f7dc3a | 2015-09-22 10:47:08 -0700 | [diff] [blame] | 77 | #define GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, reason) \ |
| 78 | grpc_call_internal_unref(exec_ctx, call) |
Craig Tiller | 4df412b | 2015-04-28 07:57:54 -0700 | [diff] [blame] | 79 | #endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 80 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 81 | grpc_call_stack *grpc_call_get_call_stack(grpc_call *call); |
Craig Tiller | d631cf3 | 2015-01-27 10:35:01 -0800 | [diff] [blame] | 82 | |
Craig Tiller | c7e1a2a | 2015-11-02 14:17:32 -0800 | [diff] [blame] | 83 | grpc_call_error grpc_call_start_batch_and_execute(grpc_exec_ctx *exec_ctx, |
| 84 | grpc_call *call, |
| 85 | const grpc_op *ops, |
| 86 | size_t nops, |
| 87 | grpc_closure *closure); |
| 88 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 89 | /* Given the top call_element, get the call object. */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 90 | grpc_call *grpc_call_from_top_element(grpc_call_element *surface_element); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 91 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 92 | void grpc_call_log_batch(char *file, int line, gpr_log_severity severity, |
| 93 | grpc_call *call, const grpc_op *ops, size_t nops, |
| 94 | void *tag); |
murgatroid99 | d47946b | 2015-03-09 14:27:07 -0700 | [diff] [blame] | 95 | |
Craig Tiller | 935cf42 | 2015-05-01 14:10:46 -0700 | [diff] [blame] | 96 | /* Set a context pointer. |
| 97 | No thread safety guarantees are made wrt this value. */ |
David Garcia Quintas | fafe995 | 2017-02-15 10:53:25 -0800 | [diff] [blame] | 98 | /* TODO(#9731): add exec_ctx to destroy */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 99 | void grpc_call_context_set(grpc_call *call, grpc_context_index elem, |
| 100 | void *value, void (*destroy)(void *value)); |
Craig Tiller | 935cf42 | 2015-05-01 14:10:46 -0700 | [diff] [blame] | 101 | /* Get a context pointer. */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 102 | void *grpc_call_context_get(grpc_call *call, grpc_context_index elem); |
Craig Tiller | 935cf42 | 2015-05-01 14:10:46 -0700 | [diff] [blame] | 103 | |
murgatroid99 | d47946b | 2015-03-09 14:27:07 -0700 | [diff] [blame] | 104 | #define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \ |
Craig Tiller | 84f75d4 | 2017-05-03 13:06:35 -0700 | [diff] [blame] | 105 | if (GRPC_TRACER_ON(grpc_api_trace)) \ |
| 106 | grpc_call_log_batch(sev, call, ops, nops, tag) |
murgatroid99 | d47946b | 2015-03-09 14:27:07 -0700 | [diff] [blame] | 107 | |
Craig Tiller | 7536af0 | 2015-12-22 13:49:30 -0800 | [diff] [blame] | 108 | uint8_t grpc_call_is_client(grpc_call *call); |
Julien Boeuf | 9f218dd | 2015-04-23 10:24:02 -0700 | [diff] [blame] | 109 | |
David Garcia Quintas | 13c2f6e | 2016-03-17 22:51:52 -0700 | [diff] [blame] | 110 | /* Return an appropriate compression algorithm for the requested compression \a |
| 111 | * level in the context of \a call. */ |
| 112 | grpc_compression_algorithm grpc_call_compression_for_level( |
| 113 | grpc_call *call, grpc_compression_level level); |
| 114 | |
Craig Tiller | 84f75d4 | 2017-05-03 13:06:35 -0700 | [diff] [blame] | 115 | extern grpc_tracer_flag grpc_call_error_trace; |
| 116 | extern grpc_tracer_flag grpc_compression_trace; |
Craig Tiller | 58b30cd | 2017-01-31 17:07:36 -0800 | [diff] [blame] | 117 | |
David Garcia Quintas | 9c512bd | 2015-07-20 23:43:53 -0700 | [diff] [blame] | 118 | #ifdef __cplusplus |
| 119 | } |
| 120 | #endif |
| 121 | |
Craig Tiller | 9a4dddd | 2016-03-25 17:08:13 -0700 | [diff] [blame] | 122 | #endif /* GRPC_CORE_LIB_SURFACE_CALL_H */ |