deislabs / wagi

Write HTTP handlers in WebAssembly with a minimal amount of work
Apache License 2.0
890 stars 44 forks source link

Allow sharing memory across modules #22

Open technosophos opened 3 years ago

technosophos commented 3 years ago

Since we don't have networking, our best way to share information between two modules would be to share virtual files across multiple modules. That might require a new top-level object in the Wagi config.

technosophos commented 3 years ago

To take another crack at explaining this, @bacongobbler and I were trying to figure out how to easily share data between multiple modules in the cases where they need to share data. Since WASI networking is not yet a thing, and since we're still a bit out from all of the nanoprocess-enabling features, a quick and dirty way of doing this is CSP-style via a pseudo-filesystem that is backed (potentially) by memory.

bacongobbler commented 3 years ago

To demonstrate a concrete use case: I am writing a retail application. There are two modules:

  1. /shop - a module that displays the current catalog to the user
  2. /cart - a module that displays every catalog item the user has added to their cart

I'd like to demonstrate how someone can add items to their shopping cart in one module and display the contents of their cart in another.

Another case might be a read/write scenario. One (or many) module(s) passively writes data, while another module reads from that data and presents it to the user. An aggregate syslogd accepting log streams from multiple modules would be one example (think logstash/graylog).