backoff.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_LIB_BACKOFF_BACKOFF_H
20 #define GRPC_CORE_LIB_BACKOFF_BACKOFF_H
21 
23 
24 #include "absl/random/random.h"
25 
27 
28 namespace grpc_core {
29 
32 class BackOff {
33  public:
34  class Options;
35 
37  explicit BackOff(const Options& options);
38 
41 
44  void Reset();
45 
46  class Options {
47  public:
50  return *this;
51  }
54  return *this;
55  }
57  jitter_ = jitter;
58  return *this;
59  }
62  return *this;
63  }
67  double multiplier() const { return multiplier_; }
69  double jitter() const { return jitter_; }
71  Duration max_backoff() const { return max_backoff_; }
72 
73  private:
75  double multiplier_;
76  double jitter_;
78  }; // class Options
79 
80  private:
83  bool initial_;
86 };
87 
88 } // namespace grpc_core
89 #endif /* GRPC_CORE_LIB_BACKOFF_BACKOFF_H */
grpc_core::BackOff::rand_gen_
absl::BitGen rand_gen_
Definition: backoff.h:82
grpc_core::BackOff::NextAttemptTime
Timestamp NextAttemptTime()
Returns the time at which the next attempt should start.
Definition: backoff.cc:31
grpc_core
Definition: call_metric_recorder.h:31
options
double_dict options[]
Definition: capstone_test.c:55
grpc_core::Timestamp
Definition: src/core/lib/gprpp/time.h:62
grpc_core::BackOff::BackOff
BackOff(const Options &options)
Initialize backoff machinery - does not need to be destroyed.
Definition: backoff.cc:29
grpc_core::BackOff::options_
const Options options_
Definition: backoff.h:81
grpc_core::BackOff::Options::initial_backoff
Duration initial_backoff() const
how long to wait after the first failure before retrying
Definition: backoff.h:65
grpc_core::BackOff::Options::max_backoff_
Duration max_backoff_
Definition: backoff.h:77
grpc_core::BackOff::Options::set_initial_backoff
Options & set_initial_backoff(Duration initial_backoff)
Definition: backoff.h:48
time.h
grpc_core::BackOff
Definition: backoff.h:32
grpc_core::BackOff::Options::jitter_
double jitter_
Definition: backoff.h:76
grpc_core::BackOff::current_backoff_
Duration current_backoff_
current delay before retries
Definition: backoff.h:85
absl::random_internal::NonsecureURBGBase< random_internal::randen_engine< uint64_t > >
grpc_core::BackOff::Reset
void Reset()
Definition: backoff.cc:44
grpc_core::BackOff::Options::multiplier
double multiplier() const
factor with which to multiply backoff after a failed retry
Definition: backoff.h:67
grpc_core::BackOff::Options::set_max_backoff
Options & set_max_backoff(Duration max_backoff)
Definition: backoff.h:60
grpc_core::BackOff::Options::initial_backoff_
Duration initial_backoff_
Definition: backoff.h:74
grpc_core::Duration
Definition: src/core/lib/gprpp/time.h:122
grpc_core::BackOff::Options
Definition: backoff.h:46
grpc_core::BackOff::Options::set_jitter
Options & set_jitter(double jitter)
Definition: backoff.h:56
grpc_core::BackOff::initial_
bool initial_
Definition: backoff.h:83
grpc_core::BackOff::Options::jitter
double jitter() const
amount to randomize backoffs
Definition: backoff.h:69
grpc_core::BackOff::Options::set_multiplier
Options & set_multiplier(double multiplier)
Definition: backoff.h:52
grpc_core::BackOff::Options::multiplier_
double multiplier_
Definition: backoff.h:75
grpc_core::BackOff::Options::max_backoff
Duration max_backoff() const
maximum time between retries
Definition: backoff.h:71
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:35