|
2 | 2 |
|
3 | 3 | ---
|
4 | 4 |
|
| 5 | +## v0.7.0 |
| 6 | + |
| 7 | +Released 2021-12-01. |
| 8 | + |
| 9 | +### Changes |
| 10 | + |
| 11 | +This is the first release that supports connecting multiple lunatic instances togethe :tada:. |
| 12 | +From the perspective of developers that are targeting lunatic there should be no difference |
| 13 | +between locally running processes or remote ones. Spawning and sending messages to them uses the |
| 14 | +same APIs. |
| 15 | + |
| 16 | +To turn your local lunatic instance into a distributed node you will need to provide an unique |
| 17 | +_name_ and _socket_ to bind to. Both of them can be set through the cli. |
| 18 | + |
| 19 | +#### CLI |
| 20 | + |
| 21 | +To start a distributed node you can run: |
| 22 | +``` |
| 23 | +lunatic --node 0.0.0.0:8333 --node-name foo --no-entry |
| 24 | +``` |
| 25 | +This starts a lunatic node with the name `foo` listening the specified port. The `--no-entry` flag |
| 26 | +means that this node doesn't have a start function, it will just block forever. |
| 27 | + |
| 28 | +If you want to connect to a node you can pass in the `--peer` flag: |
| 29 | +``` |
| 30 | +lunatic --node localhost:8334 --node-name bar --peer 0.0.0.0:8333 file.wasm |
| 31 | +``` |
| 32 | + |
| 33 | +Once you connect to one node all others known ones will be dynamically discovered. |
| 34 | + |
| 35 | +#### Usage from guest code (Rust) |
| 36 | + |
| 37 | +A great thing about lunatic is that much of the functionality provided by the runtime is directly |
| 38 | +exposed to the code running inside of it. This allows you to dynamically load WebAssembly code |
| 39 | +from already running WebAssembly code, or to create sandboxed environments to execute some code |
| 40 | +on the fly. |
| 41 | + |
| 42 | +The abstraction of an [`Environment`][18], that we used previously to sandbox and limit process |
| 43 | +resources, fits perfectly into the world of distributed lunatic. Every time you create a new |
| 44 | +`Environment` you need to explicitly add Wasm [`Modules`][19] to it, because we may need to JIT |
| 45 | +re-compile the module with the new limitations that have been set. Spawning a process from the same |
| 46 | +function in different `Environments` may use different machine generated code to be more efficient |
| 47 | +in regards to the provided sandbox. |
| 48 | + |
| 49 | +Now that a `Module` may be sent over the network to a computer running a different operating system |
| 50 | +or even using a different CPU architecture, no changes need to be done to this already existing |
| 51 | +pattern inside of lunatic. |
| 52 | + |
| 53 | +Here is an example of using the new API from Rust guest code: |
| 54 | +```rust |
| 55 | +use lunatic::{Config, Environment, Mailbox}; |
| 56 | + |
| 57 | +#[lunatic::main] |
| 58 | +fn main(_: Mailbox<()>) { |
| 59 | + // Give full access to the remote environment. |
| 60 | + let mut config = Config::new(0xA00000000, None); |
| 61 | + config.allow_namespace(""); |
| 62 | + // Create a new environment on the remote node with the name "foo" |
| 63 | + let mut env = Environment::new_remote("foo", config).unwrap(); |
| 64 | + // Add the currently running module to the environment. |
| 65 | + // This allows us to spawn a process from a closure, because the remote module will have the same |
| 66 | + // bytecode available. |
| 67 | + let module = env.add_this_module().unwrap(); |
| 68 | + |
| 69 | + // Spawn a process on a remote machine as you would do it locally. |
| 70 | + let _ = module.spawn(|_: Mailbox<()>| println!("Hello world")); |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +This will print out `Hello world` on the node labeled `foo`. Adding this to the rust library |
| 75 | +required only a few lines of code changes. The whole implementation complexity stays inside of the |
| 76 | +VM. From the developer's perspective it's trivial to just send a closure to be executed on a |
| 77 | +completely different machine that may use a different operating system or CPU architecture. |
| 78 | + |
| 79 | + |
| 80 | +#### Known issues |
| 81 | + |
| 82 | +- At the moment nodes send plain text messages between each other and each node connects to each |
| 83 | + other over TCP. |
| 84 | +- If a node disappears from the network linked processes will not be notified that the links broke. |
| 85 | + |
| 86 | +[18]: https://docs.rs/lunatic/0.7.1/lunatic/struct.Environment.html |
| 87 | +[19]: https://docs.rs/lunatic/0.7.1/lunatic/struct.Module.html |
| 88 | + |
5 | 89 | ## v0.6.0
|
6 | 90 |
|
7 | 91 | Released 2021-08-31.
|
|
0 commit comments