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

Add an alternate mode for qlkit parsing that doesn't clobber global state #4

Open
drcode opened this issue Jan 31, 2018 · 2 comments
Open

Comments

@drcode
Copy link
Contributor

drcode commented Jan 31, 2018

When we call code such as:

(ql/mount {:parsers {:read   pa/read
                                  :mutate pa/mutate}})

It sets a global singleton- This is fine in most use cases, but it would be great to have an alternate mount command that looks something like: (but hopefully something less wordy)

(ql/mount {:parsers {:read   pa/read
                                  :mutate pa/mutate}
                  :preserve-global-environment true})

If this version of the command is used, the parser functions and (optional) state atom are passed using the environmental variable, and need to be referenced by parsers by pulling them out of the environmental variable. Parsing functions may become a bit more complex to write, which is the tradeoff. Also, the environment variable is no longer printable, as it now isn't merely an EDN data structure.

The potential benefits of this feature are:

  • You could mount multiple qlkit nodes in the browser (for "devcards" type stuff, perhaps)
  • You can run unit tests in parallel on the server (because they won't step on each other's toes by overwriting the singleton parser information)
  • Repl actions can be performed without clobbering app state
  • Independent qlkit endpoints can exist in a single server process
@djwhitt
Copy link

djwhitt commented Nov 1, 2018

How bad an idea would it be to just make 'mount-info' dynamic? That wouldn't do anything for the CLJS side, but it would at least make it possible to rebind in different contexts on the server.

@djwhitt
Copy link

djwhitt commented Nov 1, 2018

I'm also interested in the mode that removes global clobbering altogether so we can use devcards, but it honestly sounds kind of gross in terms of it's impact on parsing functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants