Open michaelbironneau opened 9 years ago
Do you have a more specific example of what your trying to do Michael?
The idea is to persist an object created by user Javascript in Otto to a file or database and then recreate this object later on (possibly under a different context, or even a different machine). We want to do this to save the state of an stream processing application that runs user code (Javascript) inside Otto so that if the application crashes, we can resume processing from an earlier state. Specifically:
state
object and possibly invoking some Go functions.state
and save it to a db. At the moment this is done by calling JSON.stringify
on state
and saving the resulting string. It's not impractical, just wondering if there's a more natural way to do it.It would be even better if we could serialize the whole context, as the user Javascript wouldn't be restricted to using this state
object, but that's probably more difficult.
Hope that makes more sense?
Would be happy to see this functionality also.
At the moment I'm using
Call
to invokeJSON.stringify
on an object to serialize it - is that the best way to do it? Ideally I'd like to use something likegob
but at the moment that won't work (Value doesn't export any fields). Am I missing something obvious?Great package by the way, really nice work :).