File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
src/main/scala/util/retry/blocking Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,11 @@ name := "scala-retry"
22
33organization := " com.github.hipjim"
44
5- crossScalaVersions := Seq (" 2.10.6" , " 2.11.10" , " 2.12.7 " )
5+ crossScalaVersions := Seq (" 2.10.6" , " 2.11.10" , " 2.12.8 " )
66
7- version := " 0.2.4 "
7+ version := " 0.3.0 "
88
9- scalaVersion := " 2.12.7 "
9+ scalaVersion := " 2.12.8 "
1010
1111// Force building with Java 8
1212initialize := {
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package util.retry.blocking
22
33import util .retry .blocking .RetryStrategy .RetryStrategyProducer
44
5- import scala .concurrent .{ExecutionContext , Future }
65import scala .util .Try
76import scala .util .control .NonFatal
87
@@ -107,18 +106,20 @@ final case class Failure[+T](exception: Throwable) extends Retry[T] {
107106 override def transform [X ](f : T => X ): X = throw exception
108107 override def flatMap [S ](f : T => Retry [S ]): Retry [S ] = Failure (exception)
109108 override def map [S ](f : T => S )(
110- implicit strategy : () => RetryStrategy ): Retry [S ] = Failure (exception)
109+ implicit strategy : RetryStrategyProducer ): Retry [S ] = Failure (exception)
111110}
112111
113112object Retry {
114- def apply [T ](fn : => T )(implicit strategy : () => RetryStrategy ): Retry [T ] = {
113+ def apply [T ](fn : => T )(implicit strategy : RetryStrategyProducer ): Retry [T ] = {
115114 def go (fn : => T )(strategy : RetryStrategy ): Retry [T ] = {
116115 Try (fn) match {
117116 case x : scala.util.Success [T ] =>
118117 Success (x.value)
119118 case _ if strategy.shouldRetry() =>
119+ println(" retrying" )
120120 go(fn)(strategy.update())
121121 case f : scala.util.Failure [T ] =>
122+ println(" giving up" )
122123 Failure (f.exception)
123124 }
124125 }
You can’t perform that action at this time.
0 commit comments