sealed trait ZQuery[-R, +E, +A] extends AnyRef

A ZQuery[R, E, A] is a purely functional description of an effectual query that may contain requests from one or more data sources, requires an environment R, may fail with an E, and may succeed with an A. All requests that do not need to be performed sequentially, as expressed by flatMap or combinators derived from it, will automatically be batched, allowing for aggressive data source specific optimizations. Requests will also automatically be deduplicated and cached.

This allows for writing queries in a high level, compositional style, with confidence that they will automatically be optimized. For example, consider the following query from a user service.

val getAllUserIds: ZQuery[Any, Nothing, List[Int]] = ???
def getUserNameById(id: Int): ZQuery[Any, Nothing, String] = ???

for {
  userIds   <- getAllUserIds
  userNames <- ZQuery.foreachPar(userIds)(getUserNameById)
} yield userNames

This would normally require N + 1 queries, one for getAllUserIds and one for each call to getUserNameById. In contrast, ZQuery will automatically optimize this to two queries, one for userIds and one for userNames, assuming an implementation of the user service that supports batching.

Based on "There is no Fork: an Abstraction for Efficient, Concurrent, and Concise Data Access" by Simon Marlow, Louis Brandy, Jonathan Coens, and Jon Purdy. http://simonmar.github.io/bib/papers/haxl-icfp14.pdf

Self Type
ZQuery[R, E, A]
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ZQuery
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def step(cache: Cache): ZIO[R, Nothing, Result[R, E, A]]

    Executes one step of this query.

    Executes one step of this query.

    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def &>[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, B]

    A symbolic alias for zipParRight.

  4. final def *>[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, B]

    A symbolic alias for zipRight.

  5. final def <&[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, A]

    A symbolic alias for zipParLeft.

  6. final def <&>[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, (A, B)]

    A symbolic alias for zipPar.

  7. final def <*[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, A]

    A symbolic alias for zipLeft.

  8. final def <*>[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, (A, B)]

    A symbolic alias for zip.

  9. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. final def >>=[R1 <: R, E1 >: E, B](f: (A) => ZQuery[R1, E1, B]): ZQuery[R1, E1, B]

    A symbolic alias for flatMap.

  11. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  12. final def bimap[E1, B](f: (E) => E1, g: (A) => B)(implicit ev: CanFail[E]): ZQuery[R, E1, B]

    Returns a query whose failure and success channels have been mapped by the specified pair of functions, f and g.

  13. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  14. final def either(implicit ev: CanFail[E]): ZQuery[R, Nothing, Either[E, A]]

    Returns a query whose failure and success have been lifted into an Either.

    Returns a query whose failure and success have been lifted into an Either. The resulting query cannot fail, because the failure case has been exposed as part of the Either success case.

  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  17. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  18. final def flatMap[R1 <: R, E1 >: E, B](f: (A) => ZQuery[R1, E1, B]): ZQuery[R1, E1, B]

    Returns a query that models execution of this query, followed by passing its result to the specified function that returns a query.

    Returns a query that models execution of this query, followed by passing its result to the specified function that returns a query. Requests composed with flatMap or combinators derived from it will be executed sequentially and will not be batched, though deduplication and caching of requests will still be applied.

  19. final def fold[B](failure: (E) => B, success: (A) => B)(implicit ev: CanFail[E]): ZQuery[R, Nothing, B]

    Folds over the failed or successful result of this query to yield a query that does not fail, but succeeds with the value returned by the left or right function passed to fold.

  20. final def foldM[R1 <: R, E1, B](failure: (E) => ZQuery[R1, E1, B], success: (A) => ZQuery[R1, E1, B])(implicit ev: CanFail[E]): ZQuery[R1, E1, B]

    Recovers from errors by accepting one query to execute for the case of an error, and one query to execute for the case of success.

  21. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  22. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  23. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  24. final def map[B](f: (A) => B): ZQuery[R, E, B]

    Maps the specified function over the successful result of this query.

  25. final def mapError[E1](f: (E) => E1)(implicit ev: CanFail[E]): ZQuery[R, E1, A]

    Maps the specified function over the failed result of this query.

  26. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  27. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  28. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  29. final def provide(r: Described[R])(implicit ev: NeedsEnv[R]): ZQuery[Any, E, A]

    Provides this query with its required environment.

  30. final def provideSome[R0](f: Described[(R0) => R])(implicit ev: NeedsEnv[R]): ZQuery[R0, E, A]

    Provides this query with part of its required environment.

  31. final val run: ZIO[R, E, A]

    Returns an effect that models executing this query.

  32. final def runCache(cache: Cache): ZIO[R, E, A]

    Returns an effect that models executing this query with the specified cache.

    Returns an effect that models executing this query with the specified cache. This can be useful for deterministically "replaying" a query without executing any new requests.

  33. final def runLog: ZIO[R, E, (Cache, A)]

    Returns an effect that models executing this query, returning the query result along with the cache containing a complete log of all requests executed and their results.

    Returns an effect that models executing this query, returning the query result along with the cache containing a complete log of all requests executed and their results. This can be useful for logging or analysis of query execution.

  34. final def summarized[R1 <: R, E1 >: E, B, C](f: (B, B) => C)(summary: ZIO[R1, E1, B]): ZQuery[R1, E1, (C, A)]

    Summarizes a query by computing some value before and after execution, and then combining the values to produce a summary, together with the result of execution.

  35. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  36. final def timed: ZQuery[R with Clock, E, (Duration, A)]

    Returns a new query that executes this one and times the execution.

  37. def toString(): String
    Definition Classes
    AnyRef → Any
  38. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  39. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  40. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  41. final def zip[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, (A, B)]

    Returns a query that models the execution of this query and the specified query sequentially, combining their results into a tuple.

  42. final def zipLeft[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, A]

    Returns a query that models the execution of this query and the specified query sequentially, returning the result of this query.

  43. final def zipPar[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, (A, B)]

    Returns a query that models the execution of this query and the specified query in parallel, combining their results into a tuple.

  44. final def zipParLeft[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, A]

    Returns a query that models the execution of this query and the specified query in parallel, returning the result of this query.

  45. final def zipParRight[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, B]

    Returns a query that models the execution of this query and the specified query in parallel, returning the result of the specified query.

  46. final def zipRight[R1 <: R, E1 >: E, B](that: ZQuery[R1, E1, B]): ZQuery[R1, E1, B]

    Returns a query that models the execution of this query and the specified query sequentially, returning the result of the specified query.

  47. final def zipWith[R1 <: R, E1 >: E, B, C](that: ZQuery[R1, E1, B])(f: (A, B) => C): ZQuery[R1, E1, C]

    Returns a query that models the execution of this query and the specified query sequentially, combining their results with the specified function.

  48. final def zipWithPar[R1 <: R, E1 >: E, B, C](that: ZQuery[R1, E1, B])(f: (A, B) => C): ZQuery[R1, E1, C]

    Returns a query that models the execution of this query and the specified query in parallel, combining their results with the specified function.

    Returns a query that models the execution of this query and the specified query in parallel, combining their results with the specified function. Requests composed with zipWithPar or combinators derived from it will be batched and deduplication and caching of requests will be applied.

Inherited from AnyRef

Inherited from Any

Ungrouped