NyanCAD / Mosaic

A modern schematic entry and simulation program
https://nyancad.github.io/Mosaic/
Mozilla Public License 2.0
68 stars 5 forks source link

Support localhost CouchDB #23

Closed pepijndevos closed 2 years ago

pepijndevos commented 2 years ago

Currently Mosaic uses PouchDB for in-browser storage, with syncs to an external DB.

When deployed as a Jupyter extension or desktop app, it is preferable to use a local CouchDB/PouchDB-server because Python can access it, unlike the in-browser database. These two cases are the primary ones. Running pure client-side creates a very low barrier to try it out, but does not support simulation. Therefore the default should be an external database.

It would be possible to make the cloud the primary database for the client-side case, but this is likely to cause latency in the UI. Worth trying though.

The UI already takes a db and sync parameter. I think the main change would be that the library manager has a name, local url, and remote url, and uses different defaults.

On the Jupyter side, it could instantiate the library manager preconfigured to use the same database Jupyter uses.

pepijndevos commented 2 years ago

This actually "works" but a browser only supports 6 connections per domain. Since each PouchDB Atom registers a changes handler, once you open enough connections, the browser refuses to make any more connections to the database.

One thing that should be done to alleviate the pain is to implement code splitting so that libman and editor don't create needless PouchDB atoms. Workaround needed: https://clojure.atlassian.net/browse/CLJS-3207

thheller 3 months ago so basically use spec assert once in a namespace that ends up in :common

Probably revert b1f484942e89509246c88b3ad12ad53c445088da

But really I need to make Hipflask more friendly with _changes feeds. Maybe some PouchDB atoms don't need live updates at all. Maybe let the request time out as a safety net. Maybe share the feed between multiple atoms on the same database where possible.

Bottom line is, each tab should really only hold one changes feed where possible.

pepijndevos commented 2 years ago

Ok really fixed now I believe