Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

In provideSomeLayerShared we need to create one effect that models execution of all tests in the spec to provide the layer to. This PR updates the implementation to use the execution strategy for each suite in the composed effect.

* Applies the function `f` to each element of the `Iterable[A]` and returns
* the result in a new `List[B]` using the specified execution strategy.
*/
private def foreachExec[R, E, A, B](
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be worth upstreaming to ZIO Core. It provides a nice way of abstracting over execution strategies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I like it.

@adamgfraser adamgfraser requested a review from jdegoes April 1, 2020 23:04
jdegoes
jdegoes previously approved these changes Apr 1, 2020
@adamgfraser adamgfraser requested a review from jdegoes April 2, 2020 04:48
@jdegoes
Copy link
Member

jdegoes commented Apr 3, 2020

@adamgfraser I like this as-is. But it does strike me there's an alternate API we should consider:

sealed trait ExecutionStrategy[+A]
...
foreachExec(Parallel(List(1, 2, 3, 4))) { element =>
  ...
}

@adamgfraser
Copy link
Contributor Author

@jdegoes Yes. I think that might not work as well when used with combinators that are methods on a trait versus a companion object. For example in Spec#foreachExec it seems like we would need to move that from the Spec trait to the companion object so we could take ExecutionStrategy[Spec[R, E, T]] as an argument, which would be a little less than ideal.

Conceptually it seems like it might also be valuable sometimes to be able to talk about an execution strategy separate from any concrete collection (e.g. tell an application whether it is supposed to do whatever it does sequentially or in parallel). This could be handled by doing ExecutionStrategy[Unit] but still seems like there are separate ideas here.

@jdegoes
Copy link
Member

jdegoes commented Apr 4, 2020

@adamgfraser Sounds good to me!

@jdegoes jdegoes merged commit a9082ed into zio:master Apr 4, 2020
@adamgfraser adamgfraser deleted the providelayershared branch April 4, 2020 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants