aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/backoff/backoff.h
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2017-11-10 12:23:12 -0800
committerGravatar ncteisen <ncteisen@gmail.com>2017-11-10 12:23:12 -0800
commit72afb76f5e64a2dc43a40e544821be3119d7702d (patch)
treee59632295d408ec8a3b56c9b0f363cd11b34d5e8 /src/core/lib/backoff/backoff.h
parentdfd16dd154e2f8ae42f002db396574002eb257f8 (diff)
parent67520b0ffd78f4bf1c73b360204382b0f4197852 (diff)
Merge branch 'master' of https://github.com/grpc/grpc into tracing++
Lot's of manual work to make this merge work
Diffstat (limited to 'src/core/lib/backoff/backoff.h')
-rw-r--r--src/core/lib/backoff/backoff.h57
1 files changed, 37 insertions, 20 deletions
diff --git a/src/core/lib/backoff/backoff.h b/src/core/lib/backoff/backoff.h
index 80e49ea52a..1067281403 100644
--- a/src/core/lib/backoff/backoff.h
+++ b/src/core/lib/backoff/backoff.h
@@ -27,37 +27,54 @@ extern "C" {
typedef struct {
/// const: how long to wait after the first failure before retrying
- grpc_millis initial_connect_timeout;
+ grpc_millis initial_backoff;
+
/// const: factor with which to multiply backoff after a failed retry
double multiplier;
+
/// const: amount to randomize backoffs
double jitter;
- /// const: minimum time between retries in milliseconds
- grpc_millis min_timeout_millis;
- /// const: maximum time between retries in milliseconds
- grpc_millis max_timeout_millis;
+
+ /// const: minimum time between retries
+ grpc_millis min_connect_timeout;
+
+ /// const: maximum time between retries
+ grpc_millis max_backoff;
+
+ /// current delay before retries
+ grpc_millis current_backoff;
/// random number generator
uint32_t rng_state;
-
- /// current retry timeout in milliseconds
- grpc_millis current_timeout_millis;
} grpc_backoff;
+typedef struct {
+ /// Deadline to be used for the current attempt.
+ grpc_millis current_deadline;
+
+ /// Deadline to be used for the next attempt, following the backoff strategy.
+ grpc_millis next_attempt_start_time;
+} grpc_backoff_result;
+
/// Initialize backoff machinery - does not need to be destroyed
-void grpc_backoff_init(grpc_backoff *backoff,
- grpc_millis initial_connect_timeout, double multiplier,
- double jitter, grpc_millis min_timeout_millis,
- grpc_millis max_timeout_millis);
-
-/// Begin retry loop: returns a timespec for the NEXT retry
-grpc_millis grpc_backoff_begin(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff);
-/// Step a retry loop: returns a timespec for the NEXT retry
-grpc_millis grpc_backoff_step(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff);
+void grpc_backoff_init(grpc_backoff* backoff, grpc_millis initial_backoff,
+ double multiplier, double jitter,
+ grpc_millis min_connect_timeout,
+ grpc_millis max_backoff);
+
+/// Begin retry loop: returns the deadlines to be used for the current attempt
+/// and the subsequent retry, if any.
+grpc_backoff_result grpc_backoff_begin(grpc_exec_ctx* exec_ctx,
+ grpc_backoff* backoff);
+
+/// Step a retry loop: returns the deadlines to be used for the current attempt
+/// and the subsequent retry, if any.
+grpc_backoff_result grpc_backoff_step(grpc_exec_ctx* exec_ctx,
+ grpc_backoff* backoff);
+
/// Reset the backoff, so the next grpc_backoff_step will be a
-/// grpc_backoff_begin
-/// instead
-void grpc_backoff_reset(grpc_backoff *backoff);
+/// grpc_backoff_begin.
+void grpc_backoff_reset(grpc_backoff* backoff);
#ifdef __cplusplus
}