GRPC Core  9.0.0
grpc_ares_wrapper.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
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
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  */
18 
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H
21 
23 
28 
29 #define GRPC_DNS_ARES_DEFAULT_QUERY_TIMEOUT_MS 120000
30 
32 
34 
35 #define GRPC_CARES_TRACE_LOG(format, ...) \
36  do { \
37  if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_cares_resolver)) { \
38  gpr_log(GPR_DEBUG, "(c-ares resolver) " format, __VA_ARGS__); \
39  } \
40  } while (0)
41 
43 
44 /* Asynchronously resolve \a name. Use \a default_port if a port isn't
45  designated in \a name, otherwise use the port in \a name. grpc_ares_init()
46  must be called at least once before this function. \a on_done may be
47  called directly in this function without being scheduled with \a exec_ctx,
48  so it must not try to acquire locks that are being held by the caller. */
49 extern void (*grpc_resolve_address_ares)(const char* name,
50  const char* default_port,
51  grpc_pollset_set* interested_parties,
52  grpc_closure* on_done,
53  grpc_resolved_addresses** addresses);
54 
55 /* Asynchronously resolve \a name. It will try to resolve grpclb SRV records in
56  addition to the normal address records. For normal address records, it uses
57  \a default_port if a port isn't designated in \a name, otherwise it uses the
58  port in \a name. grpc_ares_init() must be called at least once before this
59  function. \a on_done may be called directly in this function without being
60  scheduled with \a exec_ctx, so it must not try to acquire locks that are
61  being held by the caller. The returned grpc_ares_request object is owned
62  by the caller and it is safe to free after on_done is called back. */
63 extern grpc_ares_request* (*grpc_dns_lookup_ares_locked)(
64  const char* dns_server, const char* name, const char* default_port,
65  grpc_pollset_set* interested_parties, grpc_closure* on_done,
66  std::unique_ptr<grpc_core::ServerAddressList>* addresses, bool check_grpclb,
67  char** service_config_json, int query_timeout_ms,
68  grpc_core::Combiner* combiner);
69 
70 /* Cancel the pending grpc_ares_request \a request */
71 extern void (*grpc_cancel_ares_request_locked)(grpc_ares_request* request);
72 
73 /* Initialize gRPC ares wrapper. Must be called at least once before
74  grpc_resolve_address_ares(). */
76 
77 /* Uninitialized gRPC ares wrapper. If there was more than one previous call to
78  grpc_ares_init(), this function uninitializes the gRPC ares wrapper only if
79  it has been called the same number of times as grpc_ares_init(). */
80 void grpc_ares_cleanup(void);
81 
85 
86 /* Indicates whether or not AAAA queries should be attempted. */
87 /* E.g., return false if ipv6 is known to not be available. */
89 
90 /* Sorts destinations in lb_addrs according to RFC 6724. */
92  grpc_core::ServerAddressList* addresses);
93 
94 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H \
95  */
Definition: combiner.h:33
Definition: trace.h:61
void(* grpc_cancel_ares_request_locked)(grpc_ares_request *request)
Definition: grpc_ares_wrapper_fallback.cc:47
grpc_error * grpc_ares_init(void)
Definition: grpc_ares_wrapper_fallback.cc:50
void grpc_cares_wrapper_address_sorting_sort(grpc_core::ServerAddressList *addresses)
bool grpc_ares_query_ipv6()
void(* grpc_resolve_address_ares)(const char *name, const char *default_port, grpc_pollset_set *interested_parties, grpc_closure *on_done, grpc_resolved_addresses **addresses)
Definition: grpc_ares_wrapper_fallback.cc:60
grpc_core::TraceFlag grpc_trace_cares_resolver
grpc_core::TraceFlag grpc_trace_cares_address_sorting
void grpc_ares_cleanup(void)
Definition: grpc_ares_wrapper_fallback.cc:52
void grpc_ares_complete_request_locked(grpc_ares_request *request)
Schedules the desired callback for request completion and destroys the grpc_ares_request.
struct grpc_pollset_set grpc_pollset_set
Definition: pollset_set.h:31
Definition: grpc_ares_wrapper_fallback.cc:25
A closure over a grpc_iomgr_cb_func.
Definition: closure.h:56
Definition: error_internal.h:39
Definition: resolve_address.h:49