File tree Expand file tree Collapse file tree 5 files changed +17
-15
lines changed
main/scala/com/evolution/resourcepool
test/scala/com/evolution/resourcepool Expand file tree Collapse file tree 5 files changed +17
-15
lines changed Original file line number Diff line number Diff line change 15
15
matrix :
16
16
scala :
17
17
- 2.13.14
18
+ - 3.3.3
18
19
19
20
steps :
20
21
- uses : actions/checkout@v4
Original file line number Diff line number Diff line change @@ -8,22 +8,23 @@ organizationHomepage := Some(url("https://evolution.com"))
8
8
homepage := Some (url(" https://github.com/evolution-gaming/resource-pool" ))
9
9
startYear := Some (2023 )
10
10
11
- crossScalaVersions := Seq (" 2.13.14" )
11
+ crossScalaVersions := Seq (" 2.13.14" , " 3.3.3 " )
12
12
scalaVersion := crossScalaVersions.value.head
13
+ releaseCrossBuild := true
13
14
scalacOptions := Seq (
14
15
" -release:17" ,
15
16
" -Xsource:3" ,
16
- " -deprecation" ,
17
+ " -deprecation"
17
18
)
18
19
autoAPIMappings := true
19
20
versionScheme := Some (" early-semver" )
20
21
publishTo := Some (Resolver .evolutionReleases) // sbt-release
21
22
versionPolicyIntention := Compatibility .BinaryCompatible // sbt-version-policy
22
23
23
- libraryDependencies += compilerPlugin(`kind-projector` cross CrossVersion .full)
24
+
24
25
libraryDependencies ++= Seq (
25
26
`cats-effect`,
26
- scalatest,
27
+ scalatest
27
28
)
28
29
29
30
licenses := Seq ((" MIT" , url(" https://opensource.org/licenses/MIT" )))
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ object ResourcePool {
83
83
discardTasksOnRelease : Boolean ,
84
84
resource : Id => Resource [F , A ]
85
85
): Resource [F , ResourcePool [F , A ]] = {
86
-
86
+ type ResourceF [ + AA ] = Resource [ F , AA ]
87
87
def apply (maxSize : Int , partitions : Int ) = {
88
88
89
89
def of (maxSize : Int )(resource : Id => Resource [F , A ]) = {
@@ -99,13 +99,13 @@ object ResourcePool {
99
99
} else {
100
100
for {
101
101
ref <- Ref [F ].of(0 ).toResource
102
- values <- maxSize
102
+ values1 <- maxSize
103
103
.divide(partitions)
104
104
.zipWithIndex
105
105
.parTraverse { case (maxSize, idx) => of(maxSize) { id => resource(s " $idx- $id" ) } }
106
- values <- values
106
+ values <- values1
107
107
.toVector
108
- .pure[Resource [ F , * ] ]
108
+ .pure[ResourceF ]
109
109
length = values.length
110
110
} yield {
111
111
new ResourcePool [F , A ] {
Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ import scala.concurrent.duration.*
13
13
import scala .util .control .NoStackTrace
14
14
15
15
class ResourcePoolTest extends AsyncFunSuite with Matchers {
16
-
16
+ type IOResource [ + A ] = Resource [ IO , A ]
17
17
test(" handle invalid `maxSize`" ) {
18
18
()
19
- .pure[Resource [ IO , * ] ]
19
+ .pure[IOResource ]
20
20
.toResourcePool(
21
21
maxSize = 1 ,
22
22
expireAfter = 1 .day,
@@ -114,7 +114,7 @@ class ResourcePoolTest extends AsyncFunSuite with Matchers {
114
114
test(" fail after being released" ) {
115
115
val result = for {
116
116
result <- ()
117
- .pure[Resource [ IO , * ] ]
117
+ .pure[IOResource ]
118
118
.toResourcePool(
119
119
maxSize = 2 ,
120
120
expireAfter = 1 .day)
@@ -433,7 +433,7 @@ class ResourcePoolTest extends AsyncFunSuite with Matchers {
433
433
val result = for {
434
434
deferred0 <- Deferred [IO , Unit ].toResource
435
435
pool <- ()
436
- .pure[Resource [ IO , * ] ]
436
+ .pure[IOResource ]
437
437
.toResourcePool(
438
438
maxSize = 1 ,
439
439
expireAfter = 1 .day)
@@ -469,7 +469,7 @@ class ResourcePoolTest extends AsyncFunSuite with Matchers {
469
469
val result = for {
470
470
deferred0 <- Deferred [IO , Unit ].toResource
471
471
pool <- ()
472
- .pure[Resource [ IO , * ] ]
472
+ .pure[IOResource ]
473
473
.toResourcePool(
474
474
maxSize = 1 ,
475
475
expireAfter = 1 .day)
@@ -633,7 +633,7 @@ class ResourcePoolTest extends AsyncFunSuite with Matchers {
633
633
test(" discard tasks on release" ) {
634
634
val result = for {
635
635
result <- ()
636
- .pure[Resource [ IO , * ] ]
636
+ .pure[IOResource ]
637
637
.toResourcePool(
638
638
maxSize = 1 ,
639
639
expireAfter = 1 .day,
Original file line number Diff line number Diff line change 1
- ThisBuild / version := " 1 .0.5-SNAPSHOT "
1
+ ThisBuild / version := " 2 .0.0 "
You can’t perform that action at this time.
0 commit comments