-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify module structure and introduce alleycats-retry (#132)
* Simplify module structure and introduce alleycats-retry * Move retrying to alleycats-retry * Fix oversights
- Loading branch information
Showing
14 changed files
with
111 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 3 additions & 11 deletions
14
...core/jvm/src/main/scala/retry/Sleep.scala → ...ain/scala/retry/alleycats/instances.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...ala/retry/PackageObjectLazinessSpec.scala → ...alleycats/PackageObjectLazinessSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
modules/alleycats/shared/src/main/scala/retry/alleycats/syntax.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package retry | ||
package alleycats | ||
|
||
import cats.{Id, Monad} | ||
|
||
object syntax { | ||
def retrying[A]( | ||
policy: RetryPolicy[Id], | ||
wasSuccessful: A => Boolean, | ||
onFailure: (A, RetryDetails) => Unit | ||
)( | ||
action: => A | ||
)( | ||
implicit | ||
M: Monad[Id], | ||
S: Sleep[Id] | ||
): A = | ||
retryingM[A][Id](policy, wasSuccessful, onFailure)(action) | ||
} |
This file was deleted.
Oops, something went wrong.
11 changes: 7 additions & 4 deletions
11
...red/src/main/scala/retry/CatsEffect.scala → ...e/shared/src/main/scala/retry/Sleep.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
package retry | ||
|
||
import cats.effect.Timer | ||
import scala.concurrent.duration.FiniteDuration | ||
|
||
import cats.effect.Timer | ||
trait Sleep[M[_]] { | ||
def sleep(delay: FiniteDuration): M[Unit] | ||
} | ||
|
||
object Sleep { | ||
def apply[M[_]](implicit sleep: Sleep[M]): Sleep[M] = sleep | ||
|
||
trait CatsEffect { | ||
implicit def sleepUsingTimer[F[_]](implicit timer: Timer[F]): Sleep[F] = | ||
new Sleep[F] { | ||
def sleep(delay: FiniteDuration): F[Unit] = timer.sleep(delay) | ||
} | ||
} | ||
|
||
object CatsEffect extends CatsEffect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.