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

Reconsider requirements for WebSocketConnection.incomingFrames #247

Open
joffrey-bion opened this issue Jun 25, 2022 · 0 comments
Open

Reconsider requirements for WebSocketConnection.incomingFrames #247

joffrey-bion opened this issue Jun 25, 2022 · 0 comments
Labels
breaking A breaking change enhancement New feature or request

Comments

@joffrey-bion
Copy link
Owner

The interface currently guarantees that it's ok to collect multiple times the incomingFrames, as the frames that arrive in the meantime are buffered and not lost. However, this means that this flow always has to be hot. Any custom implementation of WebSocketConnection has to provide a hot flow based on a channel fed by a coroutine in order to honor that (this includes the wrapper that handles reconnections). Otherwise, calls to first() and other terminal operators can cancel the flow, and prevent further collections, which may be a problem depending on the implementation.

This behaviour is heavily relied upon by tests, which use incomingFrames.first() extensively.

We should consider what to do with this abstraction. Its current state would be better expressed with a Channel to be frank (which was the initial design). The goal behind moving to Flow was to provide a more fluent API and allow to wrap WebSocketConnection in a cold way. If we still have to launch coroutines and keep things hot, we should express that requirement with a Channel API.

The best would probably be to remove the requirement from the interface, but that could break some code.

@joffrey-bion joffrey-bion added enhancement New feature or request breaking A breaking change labels Jun 25, 2022
@joffrey-bion joffrey-bion changed the title Leaking implementation details for WebSocketConnection.incomingFrames Reconsider requirements for WebSocketConnection.incomingFrames Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking A breaking change enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant