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 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.

    Definition Classes
    net
    See also

    Frontend/Backend Protocol

    Message Formats

  • package protocol
    Definition Classes
    net
  • AbstractMessageSocket
  • BitVectorSocket
  • BufferedMessageSocket
  • MessageSocket
  • Protocol
  • SSLNegotiation

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

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.

Source
BufferedMessageSocket.scala
Linear Supertypes
MessageSocket[F], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BufferedMessageSocket
  2. MessageSocket
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def backendKeyData: Deferred[F, BackendKeyData]
  2. abstract def expect[B](f: PartialFunction[BackendMessage, B])(implicit or: Origin): F[B]
    Definition Classes
    MessageSocket
  3. abstract def flatExpect[B](f: PartialFunction[BackendMessage, F[B]])(implicit or: Origin): F[B]
    Definition Classes
    MessageSocket
  4. abstract def history(max: Int): F[List[Either[Any, Any]]]

    Destructively read the last n messages from the circular buffer.

    Destructively read the last n messages from the circular buffer.

    Definition Classes
    MessageSocket
  5. abstract def notifications(maxQueued: Int): Stream[F, Notification[String]]

    Stream of all channel notifications that this Session is subscribed to.

    Stream of all channel notifications that this Session is subscribed to. Note that once such a stream is started it is important to consume all notifications as quickly as possible to avoid blocking message processing for other operations on the Session (although typically a dedicated Session will receive channel notifications so this won't be an issue).

    maxQueued

    the maximum number of notifications to hold in a queue before [semantically] blocking message exchange on the controlling Session.

    See also

    LISTEN

  6. abstract def parameters: Signal[F, Map[String, String]]

    Signal representing the current state of all Postgres configuration variables announced to this session.

    Signal representing the current state of all Postgres configuration variables announced to this session. These are sent after authentication and are updated asynchronously if the runtime environment changes. The current keys are as follows (with example values), but these may change with future releases so you should be prepared to handle unexpected ones.

    Map(
      "application_name"            -> "",
      "client_encoding"             -> "UTF8",
      "DateStyle"                   -> "ISO, MDY",
      "integer_datetimes"           -> "on",       // cannot change after startup
      "IntervalStyle"               -> "postgres",
      "is_superuser"                -> "on",
      "server_encoding"             -> "UTF8",     // cannot change after startup
      "server_version"              -> "9.5.3",    // cannot change after startup
      "session_authorization"       -> "postgres",
      "standard_conforming_strings" -> "on",
      "TimeZone"                    -> "US/Pacific",
    )
  7. abstract def receive: F[BackendMessage]

    Receive the next BackendMessage, or raise an exception if EOF is reached before a complete message arrives.

    Receive the next BackendMessage, or raise an exception if EOF is reached before a complete message arrives.

    Definition Classes
    MessageSocket
  8. abstract def send(message: FrontendMessage): F[Unit]

    Send the specified message.

    Send the specified message.

    Definition Classes
    MessageSocket
  9. abstract def terminate: F[Unit]
    Attributes
    protected
  10. abstract def transactionStatus: Signal[F, TransactionStatus]

    Signal broadcasting the current TransactionStatus which is reported after each completed message exchange.

    Signal broadcasting the current TransactionStatus which is reported after each completed message exchange. Note that this value may be stale in the case of a raised exception, which should prompt the front end to send a Sync message but currently does not.

Concrete 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. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  16. def toString(): String
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from MessageSocket[F]

Inherited from AnyRef

Inherited from Any

Ungrouped