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

Skip to content

Conversation

@gkfabs
Copy link
Contributor

@gkfabs gkfabs commented Jan 18, 2025

/closes #9430
/claim #9430

This PR fixes Issue #9430 by

  • Removing scope from bounded hub and using queue with shutdown just like broadcast function
  • adding tests

The fix looks too easy to me, I'm afraid of missing out something, but the test pass.

@gkfabs gkfabs force-pushed the gkfabs/series/2.x branch 2 times, most recently from 5e7e2aa to 0bc11bf Compare January 18, 2025 19:22
@gkfabs
Copy link
Contributor Author

gkfabs commented Jan 18, 2025

/claim #9430

)(implicit trace: Trace): ZIO[R with Scope, Nothing, Hub[Take[E1, A1]]] =
for {
hub <- ZIO.acquireRelease(Hub.bounded[Take[E1, A1]](capacity))(_.shutdown)
hub <- Hub.bounded[Take[E1, A1]](capacity)
Copy link
Member

Choose a reason for hiding this comment

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

So we never close the Hub? 🤔 Or is it closed by the runIntoHubScoped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me the Hub is closed by the fromQueueWithShutdown function line 346

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just rollback this line, because as you mention the Hub may not be closed.

@gkfabs gkfabs force-pushed the gkfabs/series/2.x branch 2 times, most recently from e80e705 to ed28f8f Compare January 21, 2025 14:43
@algora-pbc
Copy link

algora-pbc bot commented Feb 3, 2025

💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe.

@kyri-petrou
Copy link
Contributor

kyri-petrou commented Feb 3, 2025

@gkfabs just FYI the /claim command needs to go in the description of the PR. I edited it for you but you need to configure your account now to receive payments via Algora. Let me know once you've done that

Copy link
Contributor

@kyri-petrou kyri-petrou left a comment

Choose a reason for hiding this comment

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

I think this kind of escapes the context of this PR, but looking at broadcastDynamic I feel like the description is not quite aligned with the implementation, and that's partially due to the return type:

ZIO[R & Scope, Nothing, ZStream[Any, E, A]]

Unless I'm missing something, broadcastDynamic is currently more or less the equivalent of doing the following:

stream.broadcast(1, 2).map(_.head)

If we wanted for it to behave the way it's supposed to (at least according to the description) the return type should have been the following, where the outer effect fans out the stream and the inner effect creates a new stream dynamically.

ZIO[R & Scope, Nothing, URIO[Scope, ZStream[Any, E, A]]]

What are your thoughts on this? I'm a bit confused at what's the actual use-case for broadcastDynamic given its current behaviour

@gkfabs gkfabs force-pushed the gkfabs/series/2.x branch from 29147f2 to 2107689 Compare February 3, 2025 13:24
@gkfabs
Copy link
Contributor Author

gkfabs commented Feb 3, 2025

It makes sense to me to change the return type of broadcastDynamic based on its description to

ZIO[R & Scope, Nothing, URIO[Scope, ZStream[Any, E, A]]]

The current implementation doesn't produce a dynamic number of streams. It just produce one stream.

@gkfabs gkfabs force-pushed the gkfabs/series/2.x branch from 2107689 to 408f9c9 Compare February 3, 2025 14:39
Copy link
Contributor

@kyri-petrou kyri-petrou left a comment

Choose a reason for hiding this comment

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

Happy to approve this, and we can explore deprecating the method and changing it in the future

@kyri-petrou kyri-petrou merged commit dc20cd5 into zio:series/2.x Feb 4, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZStream#broadcastDynamic hangs

3 participants