You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: notes/0.2.0.markdown
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,13 @@
2
2
3
3
### retry.Policy
4
4
5
-
Retries are now defined in terms of a common and easier to work with interface, a `retry.Policy`, which is essentially the interface
5
+
Retries are now defined in terms of a common and easier to work with interface, a `retry.Policy`, which is in essence the type
6
6
7
7
() => Future[T] => Future[T]
8
8
9
-
with a few implicit parameters. One for an instance of `retry.Success[T]` and one for an ExecutionContext.
10
-
This makes retries easier to pass around as a general interface.
9
+
with a few implicit parameters: one for an instance of a `retry.Success[T]` and one for an `scala.concurrent.ExecutionContext`.
10
+
11
+
This makes the packaging of retry logic more portable as easier to swap implementations in an out.
11
12
12
13
trait Policy {
13
14
def apply[T](promise: () => Future[T])
@@ -19,7 +20,7 @@ The previous three categories of retry attempts, `retry.Directly`, `retry.Pause`
19
20
20
21
### retry forever
21
22
22
-
It was previously only possible to retry for a finite number of times. Sometimes you want to try, try, and try again until your future's value meets your definition of `retry.Success`. Each of the 3 retry modules now expose a `forever` method that will keep retrying until a successful result is produced using semantics tied to the type of retry.
23
+
It was previously only possible to retry for a finite number of times. Sometimes you want to try, try, and try again until your future arrives at a succesful conclusion. Each of the 3 retry modules now expose a `forever` method that will keep retrying until a successful result is produced using semantics tied to the type of retry.
23
24
24
25
// retry pausing 1 second forever until tryHarder tries hard enough
25
26
val forever = retry.Pause.forever(1.second)
@@ -56,14 +57,15 @@ A library for retrying operations has a heavy interest understanding what it mea
56
57
57
58
This interface defines a simple algebra for Ints. Your application most like defines Futures which return a more complex type. Experiment with this new interface to compose different definitions of success for your applications types to enrich your retry experience.
58
59
59
-
If you are feeling adventurous you consider `retry.Success.always` or `retry.Success.never` which will either infer success from any resulting value
60
+
If you are feeling adventurous, consider using`retry.Success.always` or `retry.Success.never` which will either infer success from any resulting value
60
61
or no resulting value respectively.
61
62
62
63
### re-determine how to retry When the right stars are in alignment
63
64
64
-
Sometimes things don't go according to plan. Sometimes you are working with "exceptional" code that expresses failure with fantastic runtime exceptions.
65
+
Sometimes things don't go according to plan. Sometimes you are forced to share the wheel with "exceptional" code that expresses failure with fantastic runtime exceptions.
66
+
65
67
Sometimes you are working with a rate-limited service that will respond with a suggested time to come back knocking at a later time.
66
-
For these cases retry exposes an adaptive interface called `retry.When` which return takes a PartialFunction of Any to Policy.
68
+
For these types of usecases, retry exposes an adaptive interface called `retry.When` which takes a PartialFunction of Any to retry.Policy which allows you to adapt to any kind of failure you throw at it.
67
69
68
70
val policy = retry.When {
69
71
case RetryAt(time) => retry.Pause(delay = time.seconds)
0 commit comments