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

feat!: add ability to create plugins without an existing Context #335

Merged
merged 23 commits into from
May 17, 2023

Conversation

zshipko
Copy link
Contributor

@zshipko zshipko commented May 4, 2023

EIP: extism/proposals#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.

@zshipko zshipko marked this pull request as ready for review May 5, 2023 17:54
@zshipko zshipko merged commit 0f8954c into main May 17, 2023
32 checks passed
@zshipko zshipko deleted the context-cleanup branch May 17, 2023 18:35
bhelx added a commit that referenced this pull request May 19, 2023
## Breaking Changes

* #315

HTTP calls will be disallowed by default now. If you want to enable HTTP
you need to specify the hosts that the plug-in is allowed to communicate
with. If you want to allow all hosts you can set it to `{allowed_hosts:
["*"]}` in the manifest. However, this isn't recommended unless you have
some trust in the plug-in or are controlling the networking by some
other means.

* #335

In this PR we are creating an implicit context so people don't need to
know about it if they don't care. In some languages function signatures
have changed to make context an optional argument when creating a
plug-in.
mhmd-azeez pushed a commit to extism/dotnet-sdk that referenced this pull request Sep 14, 2023
## Breaking Changes

* extism/extism#315

HTTP calls will be disallowed by default now. If you want to enable HTTP
you need to specify the hosts that the plug-in is allowed to communicate
with. If you want to allow all hosts you can set it to `{allowed_hosts:
["*"]}` in the manifest. However, this isn't recommended unless you have
some trust in the plug-in or are controlling the networking by some
other means.

* extism/extism#335

In this PR we are creating an implicit context so people don't need to
know about it if they don't care. In some languages function signatures
have changed to make context an optional argument when creating a
plug-in.
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

Successfully merging this pull request may close these issues.

None yet

2 participants