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
, and may fail with an E
or succeed with an A
.
Requests that can be performed in parallel, as expressed by zipWithPar
and
combinators derived from it, will automatically be batched. Requests that
must be performed sequentially, as expressed by zipWith
and combinators
derived from it, will automatically be pipelined. This allows for aggressive
data source specific optimizations. Requests can also 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
Attributes
- Companion:
- object
- Graph
- Supertypes
- Self type
Members list
Value members
Concrete methods
A symbolic alias for zipParRight
.
A symbolic alias for zipParRight
.
Attributes
A symbolic alias for zipRight
.
A symbolic alias for zipRight
.
Attributes
A symbolic alias for zipParLeft
.
A symbolic alias for zipParLeft
.
Attributes
A symbolic alias for zipPar
.
A symbolic alias for zipPar
.
Attributes
A symbolic alias for zipLeft
.
A symbolic alias for zipLeft
.
Attributes
A symbolic alias for zip
.
A symbolic alias for zip
.
Attributes
Syntax for adding aspects.
Syntax for adding aspects.
Attributes
Returns a query which submerges the error case of Either
into the error
channel of the query
Returns a query which submerges the error case of Either
into the error
channel of the query
The inverse of ZQuery.either
Attributes
Maps the success value of this query to the specified constant value.
Maps the success value of this query to the specified constant value.
Attributes
Lifts the error channel into a Some
value for composition with other
optional queries
Lifts the error channel into a Some
value for composition with other
optional queries
Attributes
Enables caching for this query. Note that caching is enabled by default so this will only be effective to enable caching in part of a larger query in which caching has been disabled.
Enables caching for this query. Note that caching is enabled by default so this will only be effective to enable caching in part of a larger query in which caching has been disabled.
Attributes
Recovers from all errors.
Recovers from all errors.
Attributes
Recovers from all errors with provided Cause.
Recovers from all errors with provided Cause.
Attributes
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.
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.
Attributes
Ensures that if this query starts executing, the specified query will be executed immediately after this query completes execution, whether by success or failure.
Ensures that if this query starts executing, the specified query will be executed immediately after this query completes execution, whether by success or failure.
Attributes
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 pipelined, though deduplication and caching of
requests may still be applied.
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 pipelined, though deduplication and caching of
requests may still be applied.
Attributes
Returns a query that performs the outer query first, followed by the inner query, yielding the value of the inner query.
Returns a query that performs the outer query first, followed by the inner query, yielding the value of the inner query.
This method can be used to "flatten" nested queries.
Attributes
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
.
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
.
Attributes
A more powerful version of foldQuery
that allows recovering from any type
of failure except interruptions.
A more powerful version of foldQuery
that allows recovering from any type
of failure except interruptions.
Attributes
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.
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.
Attributes
"Zooms in" on the value in the Left
side of an Either
, moving the
possibility that the value is a Right
to the error channel.
"Zooms in" on the value in the Left
side of an Either
, moving the
possibility that the value is a Right
to the error channel.
Attributes
Maps the specified function over the successful result of this query.
Maps the specified function over the successful result of this query.
Attributes
Returns a query whose failure and success channels have been mapped by the
specified pair of functions, f
and g
.
Returns a query whose failure and success channels have been mapped by the
specified pair of functions, f
and g
.
Attributes
Transforms all data sources with the specified data source aspect.
Transforms all data sources with the specified data source aspect.
Attributes
Maps the specified function over the failed result of this query.
Maps the specified function over the failed result of this query.
Attributes
Returns a query with its full cause of failure mapped using the specified
function. This can be used to transform errors while preserving the
original structure of Cause
.
Returns a query with its full cause of failure mapped using the specified
function. This can be used to transform errors while preserving the
original structure of Cause
.
Attributes
Maps the specified effectual function over the result of this query.
Maps the specified effectual function over the result of this query.
Attributes
Converts this query to one that returns Some
if data sources return
results for all requests received and None
otherwise.
Converts this query to one that returns Some
if data sources return
results for all requests received and None
otherwise.
Attributes
Converts this query to one that dies if a query failure occurs.
Converts this query to one that dies if a query failure occurs.
Attributes
Converts this query to one that dies if a query failure occurs, using the
specified function to map the error to a Throwable
.
Converts this query to one that dies if a query failure occurs, using the
specified function to map the error to a Throwable
.
Attributes
Provides this query with its required environment.
Provides this query with its required environment.
Attributes
Provides a layer to this query, which translates it to another level.
Provides a layer to this query, which translates it to another level.
Attributes
Provides this query with part of its required environment.
Provides this query with part of its required environment.
Attributes
Splits the environment into two parts, providing one part using the
specified layer and leaving the remainder R0
.
Splits the environment into two parts, providing one part using the
specified layer and leaving the remainder R0
.
Attributes
Races this query with the specified query, returning the result of the first to complete successfully and safely interrupting the other.
Races this query with the specified query, returning the result of the first to complete successfully and safely interrupting the other.
Attributes
Keeps some of the errors, and terminates the query with the rest
Keeps some of the errors, and terminates the query with the rest
Attributes
Keeps some of the errors, and terminates the query with the rest, using the
specified function to convert the E
into a Throwable
.
Keeps some of the errors, and terminates the query with the rest, using the
specified function to convert the E
into a Throwable
.
Attributes
"Zooms in" on the value in the Right
side of an Either
, moving the
possibility that the value is a Left
to the error channel.
"Zooms in" on the value in the Right
side of an Either
, moving the
possibility that the value is a Left
to the error channel.
Attributes
Returns an effect that models executing this query.
Returns an effect that models executing this query.
Attributes
Returns an effect that models executing this query with the specified cache.
Returns an effect that models executing this query with the specified cache.
Attributes
Returns an effect that models executing this query, returning the query result along with the cache.
Returns an effect that models executing this query, returning the query result along with the cache.
Attributes
Expose the full cause of failure of this query
Expose the full cause of failure of this query
Attributes
Companion helper to sandbox
. Allows recovery, and partial recovery, from
errors and defects alike, as in:
Companion helper to sandbox
. Allows recovery, and partial recovery, from
errors and defects alike, as in:
Attributes
Extracts a Some value into the value channel while moving the None into the error channel for easier composition
Extracts a Some value into the value channel while moving the None into the error channel for easier composition
Inverse of ZQuery.unoption
Attributes
Extracts the optional value or succeeds with the given 'default' value.
Extracts the optional value or succeeds with the given 'default' value.
Attributes
Extracts the optional value or executes the given 'default' query.
Extracts the optional value or executes the given 'default' query.
Attributes
Extracts the optional value or fails with the given error e
.
Extracts the optional value or fails with the given error e
.
Attributes
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.
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.
Attributes
Returns a new query that executes this one and times the execution.
Returns a new query that executes this one and times the execution.
Attributes
Returns an effect that will timeout this query, returning None
if the
timeout elapses before the query was completed.
Returns an effect that will timeout this query, returning None
if the
timeout elapses before the query was completed.
Attributes
Returns a query that will timeout this query, returning either the default
value if the timeout elapses before the query has completed or the result
of applying the function f
to the successful result of the query.
Returns a query that will timeout this query, returning either the default
value if the timeout elapses before the query has completed or the result
of applying the function f
to the successful result of the query.
Attributes
Disables caching for this query.
Disables caching for this query.
Attributes
Converts a ZQuery[R, Either[E, B], A]
into a ZQuery[R, E, Either[A, B]]
. The inverse of left
.
Converts a ZQuery[R, Either[E, B], A]
into a ZQuery[R, E, Either[A, B]]
. The inverse of left
.
Attributes
Converts an option on errors into an option on values.
Converts an option on errors into an option on values.
Attributes
Takes some fiber failures and converts them into errors.
Takes some fiber failures and converts them into errors.
Attributes
Takes some fiber failures and converts them into errors.
Takes some fiber failures and converts them into errors.
Attributes
Takes some fiber failures and converts them into errors, using the
specified function to convert the E
into an E1
.
Takes some fiber failures and converts them into errors, using the
specified function to convert the E
into an E1
.
Attributes
Converts a ZQuery[R, Either[B, E], A]
into a ZQuery[R, E, Either[B, A]]
. The inverse of right
.
Converts a ZQuery[R, Either[B, E], A]
into a ZQuery[R, E, Either[B, A]]
. The inverse of right
.
Attributes
Sets the parallelism for this query to the specified maximum number of fibers.
Sets the parallelism for this query to the specified maximum number of fibers.
Attributes
Sets the parallelism for this query to the specified maximum number of fibers.
Sets the parallelism for this query to the specified maximum number of fibers.
Attributes
Returns a query that models the execution of this query and the specified query sequentially, combining their results into a tuple.
Returns a query that models the execution of this query and the specified query sequentially, combining their results into a tuple.
Attributes
Returns a query that models the execution of this query and the specified query, batching requests to data sources and combining their results into a tuple.
Returns a query that models the execution of this query and the specified query, batching requests to data sources and combining their results into a tuple.
Attributes
Returns a query that models the execution of this query and the specified query, batching requests to data sources and returning the result of this query.
Returns a query that models the execution of this query and the specified query, batching requests to data sources and returning the result of this query.
Attributes
Returns a query that models the execution of this query and the specified query, batching requests to data sources and returning the result of the specified query.
Returns a query that models the execution of this query and the specified query, batching requests to data sources and returning the result of the specified query.
Attributes
Returns a query that models the execution of this query and the specified query sequentially, returning the result of this query.
Returns a query that models the execution of this query and the specified query sequentially, returning the result of this query.
Attributes
Returns a query that models the execution of this query and the specified query in parallel, combining their results into a tuple.
Returns a query that models the execution of this query and the specified query in parallel, combining their results into a tuple.
Attributes
Returns a query that models the execution of this query and the specified query in parallel, returning the result of this query.
Returns a query that models the execution of this query and the specified query in parallel, returning the result of this query.
Attributes
Returns a query that models the execution of this query and the specified query in parallel, returning the result of the specified query.
Returns a query that models the execution of this query and the specified query in parallel, returning the result of the specified query.
Attributes
Returns a query that models the execution of this query and the specified query sequentially, returning the result of the specified query.
Returns a query that models the execution of this query and the specified query sequentially, returning the result of the specified query.
Attributes
Returns a query that models the execution of this query and the specified
query sequentially, combining their results with the specified function.
Requests composed with zipWith
or combinators derived from it will
automatically be pipelined.
Returns a query that models the execution of this query and the specified
query sequentially, combining their results with the specified function.
Requests composed with zipWith
or combinators derived from it will
automatically be pipelined.
Attributes
Returns a query that models the execution of this query and the specified query, batching requests to data sources.
Returns a query that models the execution of this query and the specified query, batching requests to data sources.
Attributes
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
automatically be batched.
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
automatically be batched.