-
-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to ZQuery #160
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About your question about DataSource, I personally prefer not to use ZIO Environment for that and pass it explicitly (like I did in OptimizedTest
), so I support the simplification. We could also make fromRequestWith
be just fromRequest
. I'll point to your PR in discord to see if others have an opinion on it.
* `Either`. The resulting query cannot fail, because the failure case has | ||
* been exposed as part of the `Either` success case. | ||
*/ | ||
final def either(implicit ev: CanFail[E]): ZQuery[R, Nothing, Either[E, A]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! It can be used in Executor
line 145
Agreed on not using environment for ZIO Config used environment for its "ConfigSource" for a while, but changing that to values made everything much more natural and compositional, as well as more obvious for users. |
Updated to not use the environment for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Various improvements to
ZQuery
including:fromFunctionBatchedWith
andfromFunctionBatchedWithM
that make it easier to construct batched data sources that don't return results in the same order as requests by providing a function to associate results with requests as suggested by @fokot.partitionM
andpartitionMPar
methods onZQuery
that allow for performing a collection of queries and getting back a collection of all successes along with a collection of all failuresDescribed
data type to clean up and clarify the contract around needing to provide names for certain combinators such asprovide
andprovideSome
.CanFail
andNeedsEnv
to appropriate combinators and removing unnecessaryfinal
modifiers.One thing I would appreciate feedback on is how much users are working with data sources in the environment. I am thinking we could simplify
DataSource
somewhat by not using the module pattern and just having all the methods onDataSource
versusDataSource.Service
. That would mean that users could still put theDataSource
in the environment but it would not come "baked in" like it is today. The nice thing would be this would mean you wouldn't have to writeDataSource.Service
everywhere but if people are using it as an environmental effect then we should leave as is.