Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82c6845

Browse files
zshipkozachbhelx
authored
feat!: add ability to create plugins without an existingContext (#335)
EIP:extism/proposals#8This PR makes minor breaking changes to several SDKs, but not to runtimeC API. The threadsafety updates in the Rust SDK are kind of specific toRust, I'm not sure if it makes sense to add the locks to all the otherSDKs at this point. For the most part the `Context` and `Plugin` typesin the SDKs should be safe to use protected by a mutex but they aren'tinherently threadsafe. That kind of locking should probably be done bythe user.- Runtime - improve thread safety - reinstantiates less- fixes a potential resource exhaustion bug from re-instantiating usingthe 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 withthe lock held - adds testing sharing an `Arc<Mutex<Plugin>>` between threads- adds `Plugin::create` and `Plugin::create_from_manifest` to create aplugin without a `Context`- Python - BREAKING- changes `Plugin` constructor to take `context` as an optional namedargument, to update use `Plugin(data, context=context)` instead - Ruby - BREAKING- changes `Plugin` constructor to take `context` as an optional namedargument, 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 namedargument, to update use `new Plugin(data, wasi, config, host, context)`instead of `new Plugin(context, data, wasi, functions, config)` (mostpeople are probably using `context.plugin` instead of the Pluginconstructor anyway) - OCaml - BREAKING- changes `Plugin.create` and `Plugin.of_manifest` to take `context` asan 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 lastargument, 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 pluginsin their own context.---------Co-authored-by: zach <zach@dylib.so>Co-authored-by: Benjamin Eckel <bhelx@simst.im>
1 parent39faff0 commit82c6845

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎java/src/main/java/org/extism/sdk/Plugin.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ public Plugin(Context context, Manifest manifest, boolean withWASI, HostFunction
6262
this(context,serialize(manifest),withWASI,functions);
6363
}
6464

65+
66+
publicPlugin(byte[]manifestBytes,booleanwithWASI,HostFunction[]functions) {
67+
this(newContext(),manifestBytes,withWASI,functions);
68+
}
69+
70+
71+
publicPlugin(Manifestmanifest,booleanwithWASI,HostFunction[]functions) {
72+
this(newContext(),serialize(manifest),withWASI,functions);
73+
}
74+
6575
privatestaticbyte[]serialize(Manifestmanifest) {
6676
Objects.requireNonNull(manifest,"manifest");
6777
returnJsonSerde.toJson(manifest).getBytes(StandardCharsets.UTF_8);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp