mirror of
https://github.com/extism/extism.git
synced 2026-04-23 03:00:11 -04:00
- Adds `ExtismContext` instead of global `PLUGINS` registry - Adds `extism_context_new`, `extism_context_free` and `extism_context_reset` - Requires updating nearly every SDK function to add context parameter - Renames some SDK functions to follow better naming conventions - `extism_plugin_register` -> `extism_plugin_new` - `extism_output_get` -> `extism_plugin_output_data` - `extism_output_length` -> `extism_plugin_output_length` - `extism_call` -> `extism_plugin_call` - Updates `extism_error` to return the context error when -1 issued for the plug-in ID - Adds `extism_plugin_free` to remove an existing plugin - Updates SDKs to include these functions - Updates SDK examples and comments Co-authored-by: Steve Manuel <steve@dylib.so>
17 lines
454 B
Ruby
17 lines
454 B
Ruby
require './lib/extism'
|
|
require 'json'
|
|
|
|
# a Context provides a scope for plugins to be managed within. creating multiple contexts
|
|
# is expected and groups plugins based on source/tenant/lifetime etc.
|
|
ctx = Extism::Context.new
|
|
Extism::with_context {|ctx|
|
|
manifest = {
|
|
:wasm => [{:path => "../wasm/code.wasm"}]
|
|
}
|
|
|
|
plugin = ctx.plugin(manifest)
|
|
res = JSON.parse(plugin.call("count_vowels", ARGV[0] || "this is a test"))
|
|
|
|
puts res['count']
|
|
}
|