Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement retry for FnMut() -> impl Future<Output=Option<Result<T, E>>> #144

Open
Xuanwo opened this issue Sep 4, 2024 · 0 comments

Comments

@Xuanwo
Copy link
Owner

Xuanwo commented Sep 4, 2024

Future<Output=Option<Result<T, E>>> is widely used in streams that return Result<T, E>. If retry can support this, we can implement a retryable stream as simply as:

stream::unfold(s, move |mut state| {
    async move {
        match { || state.next() }
	        .retry(backoff)
	        .await
        {
            Some(v) => Some((v, state)),
            None => None,
        }
    }
})
Repository owner deleted a comment Sep 4, 2024
@Xuanwo Xuanwo changed the title feat: Implement retry for Option<Result<T, E>> feat: Implement retry for FnMut() -> impl Future<Output=Option<Result<T, E>>> Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant