]> git.basschouten.com Git - openhab-addons.git/blob
ce5a16f5590c6436412f36b258486114a69e6f97
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.mielecloud.internal.webservice.sse;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * A strategy computing the wait time between multiple connection attempts.
19  *
20  * @author Björn Lange - Initial contribution
21  */
22 @NonNullByDefault
23 interface BackoffStrategy {
24     /**
25      * Gets the minimal number of seconds to wait until retrying an operation. This is the lower bound of the value
26      * returned by {@link #getSecondsUntilRetry(int)}.
27      *
28      * @return The minimal number of seconds to wait until retrying an operation. Always larger or equal to zero, always
29      *         smaller than {@link #getMaximumSecondsUntilRetry()}.
30      */
31     long getMinimumSecondsUntilRetry();
32
33     /**
34      * Gets the maximal number of seconds to wait until retrying an operation. This is the upper bound of the value
35      * returned by {@link #getSecondsUntilRetry(int)}.
36      *
37      * @return The maximal number of seconds to wait until retrying an operation. Always larger or equal to zero, always
38      *         larger than {@link #getMinimumSecondsUntilRetry()}.
39      */
40     long getMaximumSecondsUntilRetry();
41
42     /**
43      * Gets the number of seconds until a retryable operation is performed. The value returned by this method is within
44      * the interval defined by {@link #getMinimumSecondsUntilRetry()} and {@link #getMaximumSecondsUntilRetry()}.
45      *
46      * @param failedConnectionAttempts The number of failed attempts.
47      * @return The number of seconds to wait before making the next attempt.
48      */
49     long getSecondsUntilRetry(int failedAttempts);
50 }