Closed alaric-dotmesh closed 5 years ago
Here's my proposal for an architecture, please comment:
DotmeshRPC.SubscribeForCommits(url, username, password, subject)
and DotmeshRPC.UnsubscribeForCommits(url, username, subject)
. They subscribe and unsubscribe, respectively, a given NATS connection for Dotmesh commits. Only the admin user may invoke them.updateSnapshotsFromKnownState
), we publish a NATS message to every subject in the commit subscriptions list.This approach:
If a user tries to use those endpoints without having NATS running, what happens? Since this is in dotmesh I'm thinking of the implications of someone trying to use this locally. I can't see why they would unless they were building their own ui on top, but that's always a possibility
In light of our decision to focus Dotmesh on being a component for Dotscience rather than continuing to develop it as a general tool, paving the way for other async notification types in future and worrying about different Dotmesh users having different subscriptions becomes a moot point...
@rusenask suggested just configuring Dotmesh with env variables at startup pointing to a NATS server/subject to send all commit notifications to.
Now, I've already implemented the above proposal so I'll finish writing tests for it so that https://github.com/dotmesh-io/frontend-ng/issues/187 can proceed on that basis, but when we come to scaling Dotscience to multiple nodes, it'll be a lot easier to do that with Karolis' simpler mechanism - so let's replace mine with that when we get to that point!
(For multiple nodes, we need to distribute the NATS connection details to every node - how to do that without needing to put NATS passwords in etcd under the generic thing is an issue I was still mulling - and make the master node for each fsmachine responsible for publishing commit notifications for that filesystem so we don't get duplicates)
Ok, a single-node-safe implementation of this is in place. See https://github.com/dotmesh-io/dotmesh/commit/10bbd10489657e2f9bc5b04e29adca698112762c#diff-d96a15e06e1ae7e43cb2b1d48e38c457R222 for a sample of how to use it.
The dotscience frontend would like to be notified asynchronously when there's a new commit to a workspace or data dot, so that the state can be updated.
We currently poll for this kind of thing, which is really inefficient.
Therefore, we could reduce server load significantly by having a way for Dotmesh RPC clients to subscribe to notifications (through websockets?) whenever commits happen to subscribed dots.
We could then use that in the frontend to refresh the pages that currently poll.