Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content

added retry with exponential backoff

Hasib Prince requested to merge 1679-retry_exp_backoff into main

Description

This MR implements retrying refreshing token by maintaining an exponential backoff algorithm if any error is faced.

Screenshots

Technical details

Exponential backoff is implemented this way (5 secs.., 10 secs..., 15 secs.....). If the delay crosses 300 seconds, it won't retry further.

suspend fun <T> retryWithBackoff(operation: suspend () -> T, retryDelayInSecond: Int = -1): T?

A method (retryWithBackoff) is implemented that takes a method (operation) as a parameter which will be retried and returns a generic type of Object. If the retry requested function (operation) returns ResultSupreme, then error is determined by checking ResultSupreme.isSuccess() and checking the exception is available in ResultSupreme. If the retry requested function (operation) returns another type of object, then error is determined by handling the exception.

Tests

Issues

backlog/-/issues/1679

10 commandments of code reviews

👪 https://gitlab.e.foundation/internal/wiki/-/wikis/mobile-team/guidelines/Code-review

Merge request reports

Loading