Context (#335)
EIP: https://github.com/extism/proposals/pull/8 This PR makes minor breaking changes to several SDKs, but not to runtime C API. The threadsafety updates in the Rust SDK are kind of specific to Rust, I'm not sure if it makes sense to add the locks to all the other SDKs at this point. For the most part the `Context` and `Plugin` types in the SDKs should be safe to use protected by a mutex but they aren't inherently threadsafe. That kind of locking should probably be done by the user. - Runtime - improve thread safety - reinstantiates less - fixes a potential resource exhaustion bug from re-instantiating using the same store too many times - Rust SDK - adds `Send` and `Sync` implementations for `Context` - adds test sharing a context between threads - adds `Plugin::call_map` to call a plugin and handle the output with the lock held - adds testing sharing an `Arc<Mutex<Plugin>>` between threads - adds `Plugin::create` and `Plugin::create_from_manifest` to create a plugin without a `Context` - Python - BREAKING - changes `Plugin` constructor to take `context` as an optional named argument, to update use `Plugin(data, context=context)` instead - Ruby - BREAKING - changes `Plugin` constructor to take `context` as an optional named argument, to update use `Plugin.new(data, context=context)` instead - Go - adds `NewPlugin` and `NewPluginFromManifest` functions - Node - BREAKING - changes `Plugin` constructor to take `context` as an optional named argument, to update use `new Plugin(data, wasi, config, host, context)` instead of `new Plugin(context, data, wasi, functions, config)` (most people are probably using `context.plugin` instead of the Plugin constructor anyway) - OCaml - BREAKING - changes `Plugin.create` and `Plugin.of_manifest` to take `context` as an optional named argument, to update `Plugin.create ~context data` and `Plugin.of_manifest ~context data` instead - Haskell - adds `createPlugin` and `createPluginFromManifest` functions - Elixir - adds `Plugin.new` to make a plugin without going through `Context.new_plugin` - Java - adds new `Plugin` constructors without a `Context` argument - C++ - BREAKING - Updates `Plugin` constructor to take an optional context as the last argument, instead of requiring it to be the first argument - Use `Plugin(wasm, wasi, functions, ctx)` instead of `Plugin(ctx, wasm, wasi, functions)` - Zig - Adds `Plugin.create` and `Plugin.createWithManifest` to create plugins in their own context. --------- Co-authored-by: zach <zach@dylib.so> Co-authored-by: Benjamin Eckel <bhelx@simst.im>
Welcome!
Please note: This project still under active development and APIs may change until we hit v1.0.
If you're interested in working on or building with Extism, please join our Discord and let us know - we are happy to help get you started.
Extism
The universal plug-in system. Run WebAssembly extensions inside your app. Use idiomatic Host SDKs for Go, Ruby, Python, Node, Rust, C, C++, OCaml, Haskell, PHP, Elixir/Erlang, .NET, Java, Zig & more (others coming soon).
Plug-in development kits (PDK) for plug-in authors supported in Rust, AssemblyScript, Go, C/C++, Haskell, and Zig.
Add a flexible, secure, and bLaZiNg FaSt plug-in system to your project. Server, desktop, mobile, web, database -- you name it. Enable users to write and execute safe extensions to your software in 3 easy steps:
1. Import
Import an Extism Host SDK into your code as a library dependency.
2. Integrate
Identify the place(s) in your code where some arbitrary logic should run (the plug-in!), returning your code some results.
3. Execute
Load WebAssembly modules at any time in your app's lifetime and Extism will execute them in a secure sandbox, fully isolated from your program's memory.
Usage
Head to the project website for more information and docs. Also, consider reading an overview of Extism and its goals & approach.
Contribution
Thank you for considering a contribution to Extism, we are happy to help you make a PR or find something to work on!
The easiest way to start would be to join the Discord or open an issue on the extism/proposals issue tracker, which can eventually become an Extism Improvement Proposal (EIP).
Who's behind this?
Extism is an open-source product from the team at:
Reach out and tell us what you're building! We'd love to help.
