1- package pgsql_test
1+ package backoff_test
22
33import (
44 "testing"
55 "time"
66
7- "github.com/acoshift/pgsql"
7+ "github.com/acoshift/pgsql/backoff "
88)
99
1010func TestExponentialBackoff (t * testing.T ) {
1111 t .Parallel ()
1212
13- config := pgsql .ExponentialBackoffConfig {
14- BackoffConfig : pgsql .BackoffConfig {
13+ config := backoff .ExponentialBackoffConfig {
14+ BackoffConfig : backoff .BackoffConfig {
1515 BaseDelay : 10 * time .Millisecond ,
1616 MaxDelay : 1 * time .Second ,
1717 },
1818 Multiplier : 2.0 ,
1919 }
20- backoff := pgsql .NewExponentialBackoff (config )
20+ backoff := backoff .NewExponentialBackoff (config )
2121
2222 // Test exponential growth
2323 delays := []time.Duration {}
@@ -45,15 +45,15 @@ func TestExponentialBackoff(t *testing.T) {
4545func TestExponentialBackoffWithFullJitter (t * testing.T ) {
4646 t .Parallel ()
4747
48- config := pgsql .ExponentialBackoffConfig {
49- BackoffConfig : pgsql .BackoffConfig {
48+ config := backoff .ExponentialBackoffConfig {
49+ BackoffConfig : backoff .BackoffConfig {
5050 BaseDelay : 100 * time .Millisecond ,
5151 MaxDelay : 1 * time .Second ,
5252 },
5353 Multiplier : 2.0 ,
54- JitterType : pgsql .FullJitter ,
54+ JitterType : backoff .FullJitter ,
5555 }
56- backoff := pgsql .NewExponentialBackoff (config )
56+ backoff := backoff .NewExponentialBackoff (config )
5757
5858 // Test that jitter introduces randomness
5959 var delays []time.Duration
@@ -86,15 +86,15 @@ func TestExponentialBackoffWithFullJitter(t *testing.T) {
8686func TestExponentialBackoffWithEqualJitter (t * testing.T ) {
8787 t .Parallel ()
8888
89- config := pgsql .ExponentialBackoffConfig {
90- BackoffConfig : pgsql .BackoffConfig {
89+ config := backoff .ExponentialBackoffConfig {
90+ BackoffConfig : backoff .BackoffConfig {
9191 BaseDelay : 100 * time .Millisecond ,
9292 MaxDelay : 1 * time .Second ,
9393 },
9494 Multiplier : 2.0 ,
95- JitterType : pgsql .EqualJitter ,
95+ JitterType : backoff .EqualJitter ,
9696 }
97- backoff := pgsql .NewExponentialBackoff (config )
97+ backoff := backoff .NewExponentialBackoff (config )
9898
9999 delay := backoff (2 )
100100
@@ -116,14 +116,14 @@ func TestExponentialBackoffWithEqualJitter(t *testing.T) {
116116func TestLinearBackoff (t * testing.T ) {
117117 t .Parallel ()
118118
119- config := pgsql .LinearBackoffConfig {
120- BackoffConfig : pgsql .BackoffConfig {
119+ config := backoff .LinearBackoffConfig {
120+ BackoffConfig : backoff .BackoffConfig {
121121 BaseDelay : 100 * time .Millisecond ,
122122 MaxDelay : 1 * time .Second ,
123123 },
124124 Increment : 100 * time .Millisecond ,
125125 }
126- backoff := pgsql .NewLinearBackoff (config )
126+ backoff := backoff .NewLinearBackoff (config )
127127
128128 // Test linear growth
129129 delays := []time.Duration {}
0 commit comments