Skip to content
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

Convert the Worker API to use Flow instead of using its own Emitter type. #435

Merged
merged 1 commit into from
Jul 2, 2019

Conversation

zach-klippenstein
Copy link
Collaborator

The old Worker API was just an over-simplified copy of the Flow API.
Now that most core Flow APIs have graduated to "experimental" status, it
doesn't make sense to copy them. Using Flow directly has a few benefits:

  • One less reactive streams contract to keep in your head (while the Worker
    API was similar to Flow, it was less strict and likely to diverge more
    over time).
  • We get access to all the built-in Flow operators.
  • Out-of-the-box integration with various reactive streams libraries.
  • Since Workers are always consumed as channels, we get lots of optimizations
    when the source is also a channel, or knows how to make one. Flow
    also does operator fusion for buffering and context-switching operators.
  • The Kotlin Worker API now matches the Swift one almost exactly - the
    only difference is that the streams used by the Swift library don't
    have backpressure.

@zach-klippenstein zach-klippenstein marked this pull request as ready for review June 29, 2019 19:20
@zach-klippenstein zach-klippenstein added this to In progress in Workflow (Kotlin) via automation Jun 29, 2019
@zach-klippenstein zach-klippenstein added this to the kotlin v0.18.0 milestone Jun 29, 2019
@zach-klippenstein zach-klippenstein changed the base branch from zachklipp/flow-host to master July 2, 2019 16:12
…ype.

The old `Worker` API was just an over-simplified copy of the `Flow` API.
Now that most core Flow APIs have graduated to "experimental" status, it
doesn't make sense to copy them. Using Flow directly has a few benefits:

 - One less reactive streams contract to keep in your head (while the Worker
   API was _similar_ to Flow, it was less strict and likely to diverge more
   over time).
 - We get access to all the built-in Flow operators.
 - Out-of-the-box integration with various reactive streams libraries.
 - Since Workers are always consumed as channels, we get lots of optimizations
   when the source is also a channel, or knows how to make one. Flow
   also does operator fusion for buffering and context-switching operators.
 - The Kotlin Worker API now matches the Swift one almost exactly - the
   only difference is that the streams used by the Swift library don't
   have backpressure.
@zach-klippenstein zach-klippenstein merged commit a601bc4 into master Jul 2, 2019
Workflow (Kotlin) automation moved this from In progress to Done Jul 2, 2019
@zach-klippenstein zach-klippenstein deleted the zachklipp/flow-workers branch July 2, 2019 17:31
zach-klippenstein added a commit that referenced this pull request Jul 6, 2019
When Workers were converted to flow in 045e5be (#435), buffering
was introduced. `produceIn` will, by default, use the `BUFFERED` value to configure its channel's
capacity, which resolves to the "default" buffer size. This value is more than zero, which means
buffering was accidentally introduced into workers where it shouldn't be.
@zach-klippenstein
Copy link
Collaborator Author

This closed #298 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kotlin Affects the Kotlin library.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants