GRPC Core  18.0.0
deadline_filter.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H
18 #define GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H
19 
21 
24 
25 namespace grpc_core {
26 class TimerState;
27 } // namespace grpc_core
28 
29 // State used for filters that enforce call deadlines.
30 // Must be the first field in the filter's call_data.
33  const grpc_call_element_args& args, grpc_millis deadline);
35 
36  // We take a reference to the call stack for the timer callback.
41  // Closure to invoke when we receive trailing metadata.
42  // We use this to cancel the timer.
44  // The original recv_trailing_metadata_ready closure, which we chain to
45  // after our own closure is invoked.
47 };
48 
49 //
50 // NOTE: All of these functions require that the first field in
51 // elem->call_data is a grpc_deadline_state.
52 //
53 
54 // Cancels the existing timer and starts a new one with new_deadline.
55 //
56 // Note: It is generally safe to call this with an earlier deadline
57 // value than the current one, but not the reverse. No checks are done
58 // to ensure that the timer callback is not invoked while it is in the
59 // process of being reset, which means that attempting to increase the
60 // deadline may result in the timer being called twice.
61 //
62 // Note: Must be called while holding the call combiner.
64  grpc_millis new_deadline);
65 
66 // To be called from the client-side filter's start_transport_stream_op_batch()
67 // method. Ensures that the deadline timer is cancelled when the call
68 // is completed.
69 //
70 // Note: It is the caller's responsibility to chain to the next filter if
71 // necessary after this function returns.
72 //
73 // Note: Must be called while holding the call combiner.
76 
77 // Should deadline checking be performed (according to channel args)
79 
80 // Deadline filters for direct client channels and server channels.
81 // Note: Deadlines for non-direct client channels are handled by the
82 // client_channel filter.
85 
86 #endif /* GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H */
Definition: arena.h:44
Definition: call_combiner.h:50
Definition: deadline_filter.cc:39
const grpc_channel_filter grpc_server_deadline_filter
Definition: deadline_filter.cc:353
void grpc_deadline_state_reset(grpc_call_element *elem, grpc_millis new_deadline)
Definition: deadline_filter.cc:216
void grpc_deadline_state_client_start_transport_stream_op_batch(grpc_call_element *elem, grpc_transport_stream_op_batch *op)
Definition: deadline_filter.cc:224
const grpc_channel_filter grpc_client_deadline_filter
Definition: deadline_filter.cc:339
bool grpc_deadline_checking_enabled(const grpc_channel_args *args)
Definition: deadline_filter.cc:367
int64_t grpc_millis
Definition: exec_ctx.h:37
Round Robin Policy.
Definition: backend_metric.cc:26
Definition: channel_stack.h:76
Definition: channel_stack.h:174
Definition: channel_stack.h:192
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: channel_stack.h:107
A closure over a grpc_iomgr_cb_func.
Definition: closure.h:56
Definition: deadline_filter.h:31
grpc_core::Arena * arena
Definition: deadline_filter.h:39
~grpc_deadline_state()
Definition: deadline_filter.cc:214
grpc_deadline_state(grpc_call_element *elem, const grpc_call_element_args &args, grpc_millis deadline)
Definition: deadline_filter.cc:190
grpc_closure * original_recv_trailing_metadata_ready
Definition: deadline_filter.h:46
grpc_core::TimerState * timer_state
Definition: deadline_filter.h:40
grpc_core::CallCombiner * call_combiner
Definition: deadline_filter.h:38
grpc_call_stack * call_stack
Definition: deadline_filter.h:37
grpc_closure recv_trailing_metadata_ready
Definition: deadline_filter.h:43
Definition: transport.h:163