@@ -10,12 +10,14 @@ final class SnCookieJarBuilder[F[_]: Async] private (
10
10
private val supervisorO : Option [Supervisor [F ]],
11
11
private val persistenceO : Option [Resource [F , SnCookiePersistence [F ]]],
12
12
private val isPublicSuffixO : Option [Resource [F , String => Boolean ]],
13
- ){ self =>
13
+ private val synchronousPersistence : Boolean ,
14
+ ){ self =>
14
15
def copy (
15
16
supervisorO : Option [Supervisor [F ]] = self.supervisorO,
16
17
persistenceO : Option [Resource [F , SnCookiePersistence [F ]]] = self.persistenceO,
17
- isPublicSuffixO : Option [Resource [F , String => Boolean ]] = self.isPublicSuffixO
18
- ): SnCookieJarBuilder [F ] = new SnCookieJarBuilder [F ](supervisorO, persistenceO, isPublicSuffixO)
18
+ isPublicSuffixO : Option [Resource [F , String => Boolean ]] = self.isPublicSuffixO,
19
+ synchronousPersistence : Boolean = self.synchronousPersistence
20
+ ): SnCookieJarBuilder [F ] = new SnCookieJarBuilder [F ](supervisorO, persistenceO, isPublicSuffixO, synchronousPersistence)
19
21
20
22
def withSupervisor (s : Supervisor [F ]) = copy(supervisorO = s.some)
21
23
@@ -24,6 +26,9 @@ final class SnCookieJarBuilder[F[_]: Async] private (
24
26
def withPersistence (c : SnCookiePersistence [F ]) =
25
27
copy(persistenceO = c.pure[Resource [F , * ]].some)
26
28
29
+ def withSynchronousPersistence = copy(synchronousPersistence = true )
30
+ def withAsynchronousPersistence = copy(synchronousPersistence = false )
31
+
27
32
def withoutPersistence = copy(persistenceO = None )
28
33
29
34
def withIsPublicSuffix (f : String => Boolean ) = copy(isPublicSuffixO = f.pure[Resource [F , * ]].some)
@@ -44,7 +49,7 @@ final class SnCookieJarBuilder[F[_]: Async] private (
44
49
)
45
50
)
46
51
isPublicSuffix <- isPublicSuffixO.getOrElse({(_ : String ) => false }.pure[Resource [F , * ]])
47
- out = tO.fold[CookieJar [F ]](new SnCookieJar .Http4sMemoryCookieJarImpl [F ](state, isPublicSuffix)){ case (cp, s) => new SnCookieJar .Http4sPersistenceCookieJarImpl [F ](cp, s, state, isPublicSuffix)}
52
+ out = tO.fold[CookieJar [F ]](new SnCookieJar .Http4sMemoryCookieJarImpl [F ](state, isPublicSuffix)){ case (cp, s) => new SnCookieJar .Http4sPersistenceCookieJarImpl [F ](cp, s, synchronousPersistence, state, isPublicSuffix)}
48
53
_ <- Resource .eval(out.evictExpired)
49
54
} yield out
50
55
@@ -66,16 +71,17 @@ final class SnCookieJarBuilder[F[_]: Async] private (
66
71
)
67
72
)
68
73
isPublicSuffix <- isPublicSuffixO.getOrElse({(_ : String ) => false }.pure[Resource [F , * ]])
69
- cj = tO.fold[CookieJar [F ]](new SnCookieJar .Http4sMemoryCookieJarImpl [F ](state, isPublicSuffix)){ case (cp, s) => new SnCookieJar .Http4sPersistenceCookieJarImpl [F ](cp, s, state, isPublicSuffix)}
74
+ cj = tO.fold[CookieJar [F ]](new SnCookieJar .Http4sMemoryCookieJarImpl [F ](state, isPublicSuffix)){ case (cp, s) => new SnCookieJar .Http4sPersistenceCookieJarImpl [F ](cp, s, synchronousPersistence, state, isPublicSuffix)}
70
75
_ <- Resource .eval(cj.evictExpired)
71
76
} yield (cj, state)
72
77
}
73
78
}
74
79
75
80
object SnCookieJarBuilder {
76
- def default [F [_]: Async ]: SnCookieJarBuilder [F ] = new SnCookieJarBuilder [F ](None , None , Defaults .isPublicSuffix)
81
+ def default [F [_]: Async ]: SnCookieJarBuilder [F ] = new SnCookieJarBuilder [F ](None , None , Defaults .isPublicSuffix, Defaults .synchronousPersistence )
77
82
78
83
private object Defaults extends SnCookieJarBuilderDefaultsPlaftom {
84
+ val synchronousPersistence = true
79
85
80
86
}
81
87
}
0 commit comments