@@ -39,31 +39,31 @@ defmodule DBConnection.Backoff do
39
39
end
40
40
41
41
def backoff ( % Backoff { type: :exp , min: min , state: nil } = s ) do
42
- { min , % Backoff { s | state: min } }
42
+ { min , % { s | state: min } }
43
43
end
44
44
45
45
def backoff ( % Backoff { type: :exp , max: max , state: prev } = s ) do
46
46
require Bitwise
47
47
next = min ( Bitwise . <<< ( prev , 1 ) , max )
48
- { next , % Backoff { s | state: next } }
48
+ { next , % { s | state: next } }
49
49
end
50
50
51
51
def backoff ( % Backoff { type: :rand_exp , max: max , state: state } = s ) do
52
52
{ prev , lower } = state
53
53
next_min = min ( prev , lower )
54
54
next_max = min ( prev * 3 , max )
55
55
next = rand ( next_min , next_max )
56
- { next , % Backoff { s | state: { next , lower } } }
56
+ { next , % { s | state: { next , lower } } }
57
57
end
58
58
59
59
@ spec reset ( t ) :: t
60
60
def reset ( backoff )
61
61
62
62
def reset ( % Backoff { type: :rand } = s ) , do: s
63
- def reset ( % Backoff { type: :exp } = s ) , do: % Backoff { s | state: nil }
63
+ def reset ( % Backoff { type: :exp } = s ) , do: % { s | state: nil }
64
64
65
65
def reset ( % Backoff { type: :rand_exp , min: min , state: { _ , lower } } = s ) do
66
- % Backoff { s | state: { min , lower } }
66
+ % { s | state: { min , lower } }
67
67
end
68
68
69
69
## Internal
0 commit comments