Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: replace connection pool #559

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
checkpoint
  • Loading branch information
tpolecat committed Oct 4, 2021
commit 2b696c57db0bf26804cb0895a926173400e4bc11
25 changes: 13 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 1,8 @@


// Our Scala versions.
lazy val `scala-2.12` = "2.12.13"
lazy val `scala-2.13` = "2.13.6"
lazy val `scala-3.0` = "3.0.2"
lazy val `scala-3` = "3.0.2"

// This is used in a couple places
lazy val fs2Version = "3.1.1"
Expand Down Expand Up @@ -46,7 45,7 @@ lazy val commonSettings = Seq(

// Compilation
scalaVersion := `scala-2.13`,
crossScalaVersions := Seq(`scala-2.12`, `scala-2.13`, `scala-3.0`),
crossScalaVersions := Seq(`scala-2.13`, `scala-3`),
scalacOptions -= "-language:experimental.macros", // doesn't work cross-version
Compile / doc / scalacOptions --= Seq("-Xfatal-warnings"),
Compile / doc / scalacOptions = Seq(
Expand Down Expand Up @@ -107,15 106,17 @@ lazy val core = crossProject(JVMPlatform, JSPlatform)
description := "Tagless, non-blocking data access library for Postgres.",
resolvers = "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
libraryDependencies = Seq(
"org.typelevel" %%% "cats-core" % "2.6.1",
"org.typelevel" %%% "cats-effect" % "3.1.1",
"co.fs2" %%% "fs2-core" % fs2Version,
"co.fs2" %%% "fs2-io" % fs2Version,
"org.scodec" %%% "scodec-core" % (if (scalaVersion.value.startsWith("3.")) "2.0.0" else "1.11.8"),
"org.scodec" %%% "scodec-cats" % "1.1.0",
"org.tpolecat" %%% "natchez-core" % natchezVersion,
"org.tpolecat" %%% "sourcepos" % "1.0.1",
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.4.4",
"org.typelevel" %% "cats-core" % "2.6.1",
"org.typelevel" %% "cats-effect" % "3.1.1",
"co.fs2" %% "fs2-core" % fs2Version,
"co.fs2" %% "fs2-io" % fs2Version,
"org.scodec" %% "scodec-core" % (if (scalaVersion.value.startsWith("3.")) "2.0.0" else "1.11.8"),
"org.scodec" %% "scodec-cats" % "1.1.0",
"org.tpolecat" %% "natchez-core" % natchezVersion,
"org.tpolecat" %% "sourcepos" % "1.0.1",
"org.tpolecat" %% "pool-party" % "0.0.3 0-ccfdf461 20210708-1136-SNAPSHOT",
"com.ongres.scram" % "client" % "2.1",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.4.4",
) Seq(
"com.beachape" %%% "enumeratum" % "1.6.1",
).filterNot(_ => scalaVersion.value.startsWith("3."))
Expand Down
7 changes: 4 additions & 3 deletions modules/core/shared/src/main/scala/Session.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 13,7 @@ import fs2.io.net.{ Network, SocketGroup }
import fs2.Pipe
import fs2.Stream
import natchez.Trace
import org.tpolecat.poolparty.PooledResourceBuilder
import skunk.codec.all.bool
import skunk.data._
import skunk.net.Protocol
Expand Down Expand Up @@ -259,7 260,7 @@ object Session {
* @param queryCache Size of the cache for query checking
* @group Constructors
*/
def pooled[F[_]: Concurrent: Trace: Network: Console](
def pooled[F[_]: Temporal: Trace: Network: Console](
host: String,
port: Int = 5432,
user: String,
Expand All @@ -282,7 283,7 @@ object Session {
for {
dc <- Resource.eval(Describe.Cache.empty[F](commandCache, queryCache))
sslOp <- Resource.eval(ssl.toSSLNegotiationOptions(if (debug) logger.some else none))
pool <- Pool.of(session(Network[F], sslOp, dc), max)(Recyclers.full)
pool <- PooledResourceBuilder.of(session(Network[F], sslOp, dc), max).withHealthCheck(Recyclers.full[F].run).withReporter(e => Console[F].println(s"pool> $e")).build
} yield pool

}
Expand All @@ -293,7 294,7 @@ object Session {
* single-session pool. This method is shorthand for `Session.pooled(..., max = 1, ...).flatten`.
* @see pooled
*/
def single[F[_]: Concurrent: Trace: Network: Console](
def single[F[_]: Temporal: Trace: Network: Console](
host: String,
port: Int = 5432,
user: String,
Expand Down