Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The goal of this PR is to rework WebIO's messaging system to be a little bit more simple and more extensible.
What this PR does/will do:
High Level (Architectural) Changes
Val{...}
-based dispatch)Minor Changes
evaljs
either a request or a command; this needs to be fleshed out, it could either be a kwarg likesync=true
which is type-unstable (but then again so is pretty much everything here) or a new function.To Be Determined
If we reduce the guarantees for sending commands, we need some other ways to do guaranteed delivery. One option is request/response (which we currently do, but is not well defined wrt multiple connections).
One option (that would be pretty close to how we do today) would be something like this.
We could also expose some hooks to do request/response with individual connections (#353 was an attempt at this). If we do request/response with scopes, the response would have to be a set of responses (corresponding to responses for all of the active connections for a scope).
Glossary
This might not be our final terminology, but my current mental model is this.
_webIOScope
, which we might give a better name).onimport
/onmount
handlers run.Why IJulia Makes Things Hard
Fundamentally, WebIO uses a one-to-many communication model (one Julia process and zero or more frontends). We basically make the guarantee that every message sent by the frontend(s) is received by Julia unless the connection is severed (in which case, you're just plain out of luck). Things get interesting in the other direction, especially when you have zero frontends. This complicates the kinds of guarantees (the contract, if you will) we make about messaging.
The canonical examples of commands are
setup_scope
(only sent from frontend to Julia when a scope mounts and it sets up observable updates) andupdate_observable
. We don't need to worry aboutsetup_scope
because it is frontend-to-Julia which has strong guarantees. I'm worried aboutupdate_observable
's behavior though.What happens when you send
update_observable
for a scope that has no active connections? The way that we currently do it (pre-next) is to use an outbox that makes sure that every message is sent to at least one connection. This leads to issues (#330, #343).@shashi proposed synchronous updates by default (#367) which I'm... mostly... in favor of. The issue with that approach is that it's incompatible with at-least-one-connection delivery when used with IJulia. The reason for this is that we don't handle the
setup_scope
message until after the request that outputs the scope is done. We get deadlock. This means that essentially, we have the following chain of events.