polling_resolver.h
Go to the documentation of this file.
1 //
2 // Copyright 2015 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_CLIENT_CHANNEL_RESOLVER_POLLING_RESOLVER_H
18 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_POLLING_RESOLVER_H
19 
21 
22 #include <memory>
23 #include <string>
24 
25 #include "absl/types/optional.h"
26 
28 
40 
41 namespace grpc_core {
42 
43 // A base class for polling-based resolvers.
44 // Handles cooldown and backoff timers.
45 // Implementations need only to implement StartRequest().
46 class PollingResolver : public Resolver {
47  public:
49  Duration min_time_between_resolutions,
50  BackOff::Options backoff_options, TraceFlag* tracer);
51  ~PollingResolver() override;
52 
53  void StartLocked() override;
54  void RequestReresolutionLocked() override;
55  void ResetBackoffLocked() override;
56  void ShutdownLocked() override;
57 
58  protected:
59  // Implemented by subclass.
60  // Starts a request, returning an object representing the pending
61  // request. Orphaning that object should cancel the request.
62  // When the request is complete, the implementation must call
63  // OnRequestComplete() with the result.
65 
66  // To be invoked by the subclass when a request is complete.
68 
69  // Convenient accessor methods for subclasses.
70  const std::string& authority() const { return authority_; }
71  const std::string& name_to_resolve() const { return name_to_resolve_; }
73  const grpc_channel_args* channel_args() const { return channel_args_; }
74 
75  private:
77  void StartResolvingLocked();
78 
80 
81  static void OnNextResolution(void* arg, grpc_error_handle error);
83 
89  const grpc_channel_args* channel_args_ = nullptr;
90  std::shared_ptr<WorkSerializer> work_serializer_;
91  std::unique_ptr<ResultHandler> result_handler_;
96  bool shutdown_ = false;
109 };
110 
111 } // namespace grpc_core
112 
113 #endif // GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_POLLING_RESOLVER_H
trace.h
grpc_core::PollingResolver::authority
const std::string & authority() const
Definition: polling_resolver.h:70
grpc_core::PollingResolver::channel_args_
const grpc_channel_args * channel_args_
channel args
Definition: polling_resolver.h:89
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
grpc_core::PollingResolver::name_to_resolve
const std::string & name_to_resolve() const
Definition: polling_resolver.h:71
orphanable.h
backoff.h
grpc_core::PollingResolver::StartLocked
void StartLocked() override
Starts resolving.
Definition: polling_resolver.cc:69
grpc_core::PollingResolver::next_resolution_timer_
grpc_timer next_resolution_timer_
Definition: polling_resolver.h:101
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::PollingResolver::work_serializer_
std::shared_ptr< WorkSerializer > work_serializer_
Definition: polling_resolver.h:90
grpc_core::PollingResolver::request_
OrphanablePtr< Orphanable > request_
are we currently resolving?
Definition: polling_resolver.h:98
grpc_pollset_set
struct grpc_pollset_set grpc_pollset_set
Definition: iomgr_fwd.h:23
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
error
grpc_error_handle error
Definition: retry_filter.cc:499
closure.h
grpc_core::PollingResolver::name_to_resolve_
std::string name_to_resolve_
name to resolve
Definition: polling_resolver.h:87
grpc_timer
Definition: iomgr/timer.h:33
grpc_channel_args
Definition: grpc_types.h:132
grpc_core::PollingResolver::interested_parties_
grpc_pollset_set * interested_parties_
pollset_set to drive the name resolution process
Definition: polling_resolver.h:94
grpc_types.h
resolver_factory.h
grpc_core::PollingResolver::OnNextResolutionLocked
void OnNextResolutionLocked(grpc_error_handle error)
Definition: polling_resolver.cc:102
grpc_core::PollingResolver::OnNextResolution
static void OnNextResolution(void *arg, grpc_error_handle error)
Definition: polling_resolver.cc:95
grpc_core::PollingResolver::StartRequest
virtual OrphanablePtr< Orphanable > StartRequest()=0
grpc_core::PollingResolver::PollingResolver
PollingResolver(ResolverArgs args, const grpc_channel_args *channel_args, Duration min_time_between_resolutions, BackOff::Options backoff_options, TraceFlag *tracer)
Definition: polling_resolver.cc:43
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
grpc_core::PollingResolver::RequestReresolutionLocked
void RequestReresolutionLocked() override
Definition: polling_resolver.cc:71
re2::Result
TestInstance::Result Result
Definition: bloaty/third_party/re2/re2/testing/tester.cc:96
grpc_core::Resolver
Definition: resolver/resolver.h:53
work_serializer.h
grpc_core::Resolver::Result
Results returned by the resolver.
Definition: resolver/resolver.h:56
grpc_core::PollingResolver::backoff_
BackOff backoff_
retry backoff state
Definition: polling_resolver.h:108
absl::optional
Definition: abseil-cpp/absl/types/internal/optional.h:61
grpc_core::ResolverArgs
Definition: resolver_factory.h:41
arg
Definition: cmdline.cc:40
grpc_core::PollingResolver::MaybeStartResolvingLocked
void MaybeStartResolvingLocked()
Definition: polling_resolver.cc:168
grpc_core::PollingResolver::channel_args
const grpc_channel_args * channel_args() const
Definition: polling_resolver.h:73
time.h
error.h
grpc_core::PollingResolver::OnRequestComplete
void OnRequestComplete(Result result)
Definition: polling_resolver.cc:117
grpc_core::BackOff
Definition: backoff.h:32
grpc_core::PollingResolver
Definition: polling_resolver.h:46
grpc_core::PollingResolver::min_time_between_resolutions_
Duration min_time_between_resolutions_
min time between DNS requests
Definition: polling_resolver.h:104
resolver.h
grpc_core::TraceFlag
Definition: debug/trace.h:63
grpc_core::PollingResolver::ResetBackoffLocked
void ResetBackoffLocked() override
Definition: polling_resolver.cc:77
grpc_core::PollingResolver::result_handler_
std::unique_ptr< ResultHandler > result_handler_
Definition: polling_resolver.h:91
grpc_core::PollingResolver::StartResolvingLocked
void StartResolvingLocked()
Definition: polling_resolver.cc:204
grpc_core::PollingResolver::~PollingResolver
~PollingResolver() override
Definition: polling_resolver.cc:62
grpc_core::PollingResolver::on_next_resolution_
grpc_closure on_next_resolution_
Definition: polling_resolver.h:102
grpc_core::PollingResolver::authority_
std::string authority_
authority
Definition: polling_resolver.h:85
grpc_core::OrphanablePtr
std::unique_ptr< T, Deleter > OrphanablePtr
Definition: orphanable.h:64
grpc_core::PollingResolver::last_resolution_timestamp_
absl::optional< Timestamp > last_resolution_timestamp_
timestamp of last DNS request
Definition: polling_resolver.h:106
grpc_core::PollingResolver::ShutdownLocked
void ShutdownLocked() override
Shuts down the resolver.
Definition: polling_resolver.cc:84
timer.h
grpc_core::PollingResolver::interested_parties
grpc_pollset_set * interested_parties() const
Definition: polling_resolver.h:72
iomgr_fwd.h
grpc_error
Definition: error_internal.h:42
grpc_core::PollingResolver::OnRequestCompleteLocked
void OnRequestCompleteLocked(Result result)
Definition: polling_resolver.cc:124
grpc_core::Duration
Definition: src/core/lib/gprpp/time.h:122
grpc_core::BackOff::Options
Definition: backoff.h:46
grpc_core::PollingResolver::shutdown_
bool shutdown_
are we shutting down?
Definition: polling_resolver.h:96
grpc_closure
Definition: closure.h:56
grpc_core::PollingResolver::have_next_resolution_timer_
bool have_next_resolution_timer_
next resolution timer
Definition: polling_resolver.h:100
grpc_core::PollingResolver::tracer_
TraceFlag * tracer_
Definition: polling_resolver.h:92
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:53