GRPC Core  9.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 
29 };
30 
31 // State used for filters that enforce call deadlines.
32 // Must be the first field in the filter's call_data.
36  grpc_millis deadline);
38 
39  // We take a reference to the call stack for the timer callback.
45  // Closure to invoke when we receive trailing metadata.
46  // We use this to cancel the timer.
48  // The original recv_trailing_metadata_ready closure, which we chain to
49  // after our own closure is invoked.
51 };
52 
53 //
54 // NOTE: All of these functions require that the first field in
55 // elem->call_data is a grpc_deadline_state.
56 //
57 
58 // Cancels the existing timer and starts a new one with new_deadline.
59 //
60 // Note: It is generally safe to call this with an earlier deadline
61 // value than the current one, but not the reverse. No checks are done
62 // to ensure that the timer callback is not invoked while it is in the
63 // process of being reset, which means that attempting to increase the
64 // deadline may result in the timer being called twice.
65 //
66 // Note: Must be called while holding the call combiner.
68  grpc_millis new_deadline);
69 
70 // To be called from the client-side filter's start_transport_stream_op_batch()
71 // method. Ensures that the deadline timer is cancelled when the call
72 // is completed.
73 //
74 // Note: It is the caller's responsibility to chain to the next filter if
75 // necessary after this function returns.
76 //
77 // Note: Must be called while holding the call combiner.
80 
81 // Should deadline checking be performed (according to channel args)
83 
84 // Deadline filters for direct client channels and server channels.
85 // Note: Deadlines for non-direct client channels are handled by the
86 // client_channel filter.
89 
90 #endif /* GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H */
Definition: call_combiner.h:49
grpc_call_element * elem
Definition: client_channel.cc:112
grpc_deadline_timer_state
Definition: deadline_filter.h:25
@ GRPC_DEADLINE_STATE_INITIAL
Definition: deadline_filter.h:26
@ GRPC_DEADLINE_STATE_PENDING
Definition: deadline_filter.h:27
@ GRPC_DEADLINE_STATE_FINISHED
Definition: deadline_filter.h:28
const grpc_channel_filter grpc_server_deadline_filter
Definition: deadline_filter.cc:347
void grpc_deadline_state_reset(grpc_call_element *elem, grpc_millis new_deadline)
Definition: deadline_filter.cc:209
void grpc_deadline_state_client_start_transport_stream_op_batch(grpc_call_element *elem, grpc_transport_stream_op_batch *op)
Definition: deadline_filter.cc:217
const grpc_channel_filter grpc_client_deadline_filter
Definition: deadline_filter.cc:333
bool grpc_deadline_checking_enabled(const grpc_channel_args *args)
Definition: deadline_filter.cc:361
int64_t grpc_millis
Definition: exec_ctx.h:35
Definition: channel_stack.h:167
Definition: channel_stack.h:185
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: channel_stack.h:99
A closure over a grpc_iomgr_cb_func.
Definition: closure.h:56
Definition: deadline_filter.h:33
grpc_timer timer
Definition: deadline_filter.h:43
grpc_closure timer_callback
Definition: deadline_filter.h:44
~grpc_deadline_state()
Definition: deadline_filter.cc:207
grpc_closure * original_recv_trailing_metadata_ready
Definition: deadline_filter.h:50
grpc_deadline_timer_state timer_state
Definition: deadline_filter.h:42
grpc_core::CallCombiner * call_combiner
Definition: deadline_filter.h:41
grpc_call_stack * call_stack
Definition: deadline_filter.h:40
grpc_deadline_state(grpc_call_element *elem, grpc_call_stack *call_stack, grpc_core::CallCombiner *call_combiner, grpc_millis deadline)
Definition: deadline_filter.cc:184
grpc_closure recv_trailing_metadata_ready
Definition: deadline_filter.h:47
Definition: timer.h:30
Definition: transport.h:163