|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Stream 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 | + * https://github.com/GetStream/stream-core-android/blob/main/LICENSE |
| 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 | +package io.getstream.android.core.api.model.retry |
| 18 | + |
| 19 | +import io.getstream.android.core.annotations.StreamInternalApi |
| 20 | + |
| 21 | +/** |
| 22 | + * Snapshot describing the state of the current retry loop iteration. |
| 23 | + * |
| 24 | + * Instances are delivered to the `block` passed into |
| 25 | + * [StreamRetryProcessor.retry][io.getstream.android.core.api.processing.StreamRetryProcessor.retry] |
| 26 | + * before each attempt so callers can log, alter metrics, or branch based on the retry count. |
| 27 | + * |
| 28 | + * @property attempt 1-based attempt index. `1` represents the first invocation after the initial |
| 29 | + * failure. |
| 30 | + * @property currentDelay Delay (in milliseconds) that was applied before this attempt. Equals the |
| 31 | + * policy's `initialDelayMillis` for the first retry. |
| 32 | + * @property previousAttemptError The error thrown by the previous attempt, if any. `null` for the |
| 33 | + * first attempt. |
| 34 | + * @property policy The retry policy governing this run; useful if callers need to inspect limits |
| 35 | + * (max retries, back-off window, etc.). |
| 36 | + */ |
| 37 | +@StreamInternalApi |
| 38 | +public data class StreamRetryAttemptInfo( |
| 39 | + val attempt: Int, |
| 40 | + val currentDelay: Long, |
| 41 | + val previousAttemptError: Throwable? = null, |
| 42 | + val policy: StreamRetryPolicy, |
| 43 | +) |
0 commit comments