Packages

  • package root
    Definition Classes
    root
  • package skunk

    Skunk is a functional data access layer for Postgres.

    Skunk is a functional data access layer for Postgres.

    Design principles:

    • Skunk doesn't use JDBC. It speaks the Postgres wire protocol. It will not work with any other database back end.
    • Skunk is asynchronous all the way down, via cats-effect, fs2, and ultimately nio. The high-level network layers (Protocol and Session) are safe to use concurrently.
    • Serialization to and from schema types is not typeclass-based, so there are no implicit derivations. Codecs are explicit, like parser combinators.
    • I'm not sweating arity abstraction that much. Pass a ~ b ~ c for three args and Void if there are no args. This may change in the future but it's fine for now.
    • Skunk uses Resource for lifetime-managed objects, which means it takes some discipline to avoid leaks, especially when working concurrently. May or may not end up being problematic.
    • I'm trying to write good Scaladoc this time.

    A minimal example follows. We construct a Resource that yields a Session, then use it.

    package example
    
    import cats.effect._
    import skunk._
    import skunk.implicits._
    import skunk.codec.numeric._
    
    object Minimal extends IOApp {
    
      val session: Resource[IO, Session[IO]] =
        Session.single(
          host     = "localhost",
          port     = 5432,
          user     = "postgres",
          database = "world",
        )
    
      def run(args: List[String]): IO[ExitCode] =
        session.use { s =>
          for {
            n <- s.unique(sql"select 42".query(int4))
            _ <- IO(println(s"The answer is $n."))
          } yield ExitCode.Success
        }
    
    }

    Continue reading for an overview of the library. It's pretty small.

    Definition Classes
    root
  • package codec
    Definition Classes
    skunk
  • package data
    Definition Classes
    skunk
  • package exception
    Definition Classes
    skunk
  • package net

    Skunk network stack, starting with BitVectorSocket at the bottom and ending with Protocol at the top (Session delegates all its work to Protocol).

    Skunk network stack, starting with BitVectorSocket at the bottom and ending with Protocol at the top (Session delegates all its work to Protocol). Everything is non-blocking.

    Definition Classes
    skunk
  • package syntax
    Definition Classes
    skunk
  • package util
    Definition Classes
    skunk
  • AppliedFragment
  • Channel
  • Codec
  • Command
  • Cursor
  • Decoder
  • Encoder
  • Fragment
  • PreparedCommand
  • PreparedQuery
  • Query
  • SSL
  • Session
  • SqlState
  • Statement
  • Transaction
  • Void
  • implicits
  • ~

object Session

Source
Session.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. Session
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. implicit class SessionSyntax[F[_]] extends AnyRef
  2. implicit class SignalOps[F[_], A] extends AnyRef

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. def fromProtocol[F[_]](proto: Protocol[F], namer: Namer[F], strategy: util.Typer.Strategy)(implicit arg0: Sync[F]): F[Session[F]]

    Construct a Session by wrapping an existing Protocol, which we assume has already been started up.

  10. def fromSocketGroup[F[_]](socketGroup: SocketGroup, host: String, port: Int = 5432, user: String, database: String, password: Option[String] = none, debug: Boolean = false, readTimeout: FiniteDuration = Int.MaxValue.seconds, writeTimeout: FiniteDuration = 5.seconds, strategy: util.Typer.Strategy = Typer.Strategy.BuiltinsOnly, sslOptions: Option[Options[F]])(implicit arg0: Concurrent[F], arg1: ContextShift[F], arg2: Trace[F]): Resource[F, Session[F]]
  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. def pooled[F[_]](host: String, port: Int = 5432, user: String, database: String, password: Option[String] = none, max: Int, debug: Boolean = false, readTimeout: FiniteDuration = Int.MaxValue.seconds, writeTimeout: FiniteDuration = 5.seconds, strategy: util.Typer.Strategy = Typer.Strategy.BuiltinsOnly, ssl: SSL = SSL.None)(implicit arg0: Concurrent[F], arg1: ContextShift[F], arg2: Trace[F]): Resource[F, Resource[F, Session[F]]]

    Resource yielding a SessionPool managing up to max concurrent Sessions.

    Resource yielding a SessionPool managing up to max concurrent Sessions. Typically you will use this resource once on application startup and pass the resulting Resource[F, Session[F]] to the rest of your program.

    Note that calling .flatten on the nested Resource returned by this method may seem reasonable, but it will result in a resource that allocates a new pool for each session, which is probably not what you want.

    host

    Postgres server host

    port

    Postgres port, default 5432

    user

    Postgres user

    database

    Postgres database

    max

    Maximum concurrent sessions

  18. def single[F[_]](host: String, port: Int = 5432, user: String, database: String, password: Option[String] = none, debug: Boolean = false, readTimeout: FiniteDuration = Int.MaxValue.seconds, writeTimeout: FiniteDuration = 5.seconds, strategy: util.Typer.Strategy = Typer.Strategy.BuiltinsOnly, ssl: SSL = SSL.None)(implicit arg0: Concurrent[F], arg1: ContextShift[F], arg2: Trace[F]): Resource[F, Session[F]]

    Resource yielding logically unpooled sessions.

    Resource yielding logically unpooled sessions. This can be convenient for demonstrations and programs that only need a single session. In reality each session is managed by its own single-session pool. This method is shorthand for Session.pooled(..., max = 1, ...).flatten.

    See also

    pooled

  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  24. object Recyclers

Inherited from AnyRef

Inherited from Any

Constructors

Ungrouped