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 message

    Definitions of Postgres messages, with binary encoders and decoders.

    Definitions of Postgres messages, with binary encoders and decoders. Doc for this package isn't very good yet, but the message formats are well documented at the linked pages below. It's a straightforward mapping.

    It's probably useful to point out that Codec, Encoder, and Decoder in this package are from scodec. They're not the data types of the same name and same general design that are defined above in the skunk package. I realize this is confusing, but it shouldn't be a concern for anyone other than people working on the wire protocol, which never changes (heh-heh) so it shouldn't be a big deal.

    See also

    Frontend/Backend Protocol

    Message Formats

  • package protocol
  • AbstractMessageSocket
  • BitVectorSocket
  • BufferedMessageSocket
  • MessageSocket
  • Protocol
  • SSLNegotiation
  • package syntax
    Definition Classes
    skunk
  • package util
    Definition Classes
    skunk
p

skunk

net

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). Everything is non-blocking.

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

Type Members

  1. abstract class AbstractMessageSocket[F[_]] extends MessageSocket[F]
  2. trait BitVectorSocket[F[_]] extends AnyRef

    A higher-level Socket interface defined in terms of BitVector.

  3. trait BufferedMessageSocket[F[_]] extends MessageSocket[F]

    A MessageSocket that buffers incoming messages, removing and handling asynchronous back-end messages.

    A MessageSocket that buffers incoming messages, removing and handling asynchronous back-end messages. This splits the protocol into a [logically] synchronous message exchange plus a set of out-of-band broadcast channels that can be observed or ignored at the user's discretion.

  4. trait MessageSocket[F[_]] extends AnyRef

    A higher-level BitVectorSocket that speaks in terms of Message.

  5. trait Protocol[F[_]] extends AnyRef

    Interface for a Postgres database, expressed through high-level operations that rely on exchange of multiple messages.

    Interface for a Postgres database, expressed through high-level operations that rely on exchange of multiple messages. Operations here can be executed concurrently and are non-cancelable. The structures returned here expose internals (safely) that are important for error reporting but are not generally useful for end users.

Inherited from AnyRef

Inherited from Any

Ungrouped