Commit Graph

113 Commits

Author SHA1 Message Date
Benjamin Eckel
92ff5f0040 chore: bump to version v0.0.1-rc.5 (#31) v0.0.1-rc.5 2022-10-19 15:23:21 -06:00
Benjamin Eckel
460e2a0d73 Implement Host SDK for Elixir (#18)
This implements the a basic Elixir / Erlang host SDK. I still have some
work to do on it this weekend.

## Testing

* Pull down this branch
* In a different folder create a new elixir project:
  `mix new extism_elixir_host && cd extism_elixir_host`
* Link to the local dependency by updating the `deps` in `mix.exs`:
```elixir
  defp deps do
    [
      {:extism, path: "/Users/ben/Code/extism/elixir"}
    ]
  end
```
* Run `mix deps.get`
* Run `mix deps.compile`, this should trigger the rust compilation in
the elixir lib depdency
* Run `iex -S mix` to start a REPL.
* Test happy path:
```elixir
iex(1)> manifest = %{ wasm: [ %{ path: "/Users/ben/code/extism/wasm/code.wasm" } ]}
%{wasm: [%{path: "/Users/ben/code/extism/wasm/code.wasm"}]}
iex(2)> {:ok, plugin} = Extism.Plugin.new(manifest)
{:ok,
 %Extism.Plugin{
   resource: 0,
   reference: #Reference<0.1101693245.999030787.163527>
 }}
iex(3)> {:ok, result} = Extism.Plugin.call(plugin, "count_vowels", "this is a test")
{:ok, "{\"count\": 4}"}
```
* Test the sad path:
```elixir
iex(1)> manifest = %{ wasm: [ %{ path: "/Users/ben/code/extism/wasm/code.wasmz" } ]}
%{wasm: [%{path: "/Users/ben/code/extism/wasm/code.wasmz"}]}
iex(2)> Extism.Plugin.new(manifest) 
{:error, "Could not load plugin"}
iex(3)> manifest = %{ wasm: [ %{ pathe: "/Users/ben/code/extism/wasm/code.wasm" } ]}
%{wasm: [%{pathe: "/Users/ben/code/extism/wasm/code.wasm"}]}
iex(4)> Extism.Plugin.new(manifest)                                                 
{:error, "Could not parse manifest"}
```
* Some other functions you can use:
```elixir
iex(8)> Extism.Plugin.set_log_file(plugin, "/tmp/mylog.log", "debug")  
:ok
iex(9)> Extism.Plugin.update(plugin, %{wasm: [%{path: "/Users/ben/Code/extism/wasm/code.wasm"}]}, true)
{:ok, true}
iex(10)> Extism.Plugin.has_function(plugin, "unknown")
false
iex(11)> Extism.Plugin.has_function(plugin, "count_vowels")
true
```

## Running unit tests

```
cd elixir/
mix do deps.get, deps.compile
mix test
```
2022-10-19 14:46:12 -05:00
Benjamin Eckel
1024bb6d12 Implement Elixir / Erlang Host SDK 2022-10-19 14:12:56 -05:00
Benjamin Eckel
6e97f62793 Add extism_version to Host SDK and all clients (#30)
Adds a new Host SDK call `extism_version` which returns the version
string.
2022-10-17 14:15:54 -05:00
Benjamin Eckel
0816e15a42 fix docstring comment 2022-10-17 13:46:59 -05:00
Benjamin Eckel
14e3c10b0a fix compile error 2022-10-17 13:38:19 -05:00
Benjamin Eckel
6c692cc5f4 fix haskell type 2022-10-17 13:25:22 -05:00
Benjamin Eckel
bffef2e7a7 fix haskell type 2022-10-17 12:48:45 -05:00
Benjamin Eckel
217c61373d print version 2022-10-17 12:39:36 -05:00
Benjamin Eckel
d27f430184 Change pointer type for go 2022-10-17 12:37:35 -05:00
Benjamin Eckel
b89745c519 Change header definition 2022-10-17 12:22:04 -05:00
Benjamin Eckel
d53e4aedf7 Haskell 2022-10-17 12:10:23 -05:00
Benjamin Eckel
b17659b218 cleanup whitespace 2022-10-17 09:28:31 -05:00
Benjamin Eckel
85b3aece6f Add version to Host SDK and all clients 2022-10-17 09:25:22 -05:00
Steve Manuel
e7c564a90a Update README.md 2022-10-12 11:23:42 -06:00
zach
880617c066 Add nn feature to enable wasi-nn for plugins that enable WASI (#29)
Also avoids instantiating a wasi context for plugins where wasi is
disabled.
2022-10-11 12:32:25 -07:00
zach
f10ace7c03 ci: run tests using --all-features 2022-10-11 12:01:43 -07:00
zach
09cf4451d3 cleanup: group wasi contexts 2022-10-10 20:48:33 -07:00
zach
51e6eb38c4 feat: link wasi-nn when wasi is enabled 2022-10-10 19:17:47 -07:00
Steve Manuel
b8d2f2d6b3 chore: bump versions for v0.0.1-rc.4 (#24) v0.0.1-rc.4 2022-09-29 15:52:10 -07:00
zach
fe5f9eeb8b feat: add allowed_hosts configuration option (#23)
- Adds `allowed_hosts` to the manifest
- If there are any `allowed_hosts` then `extism_http_request` checks to
make sure a URL's host is listed before performing the reques
2022-09-28 16:40:09 -07:00
zach
64d9358ea9 Don't panic on invalid plugin id (#22) 2022-09-26 09:23:56 -07:00
zach
355d4cdc4f cleanup: rename get! macro to args! 2022-09-25 19:44:05 -07:00
zach
1897276ee8 cleanup(runtime): get rid of more unwraps/panics 2022-09-24 11:17:14 -07:00
zach
a23e4a8b88 cleanup(runtime): improve pdk memory access 2022-09-24 10:46:05 -07:00
zach
631eb14cca fix: more helpful error message for manifests 2022-09-24 10:43:50 -07:00
zach
460b477b87 fix: don't panic on invalid plugin id 2022-09-24 10:43:50 -07:00
zach
15cd047569 fix: invalid length in config_get, vars_get 2022-09-23 16:15:05 -07:00
zach
52200c90ad fix(python): missing argument 2022-09-23 15:36:57 -07:00
zach
6bad1c43eb fix(python): missing argument 2022-09-22 16:11:34 -07:00
zach
958e56ba6d fix: compilation error when building without http_request support 2022-09-22 15:44:06 -07:00
zach
a4921e2d73 cleanup(runtime): better handling of reclaimed IDs 2022-09-21 10:57:18 -07:00
Steve Manuel
cdc614b04b fix: broken link in readme to extism overview 2022-09-21 09:50:41 -06:00
Steve Manuel
d3248119f7 chore: add links to pdks in readme 2022-09-21 01:10:27 -06:00
Steve Manuel
02f15985e2 docs: update readme to current sdk support graphic 2022-09-21 01:08:42 -06:00
zach
77964c7724 Update to wasmtime 1.0 (#21) 2022-09-20 14:47:54 -07:00
zach
15b7d0fa1f chore: update wasmtime to 1.0 2022-09-20 14:05:02 -07:00
zach
87be73570d Add ExtismContext to SDK + better errors for failed register/update (#19)
- 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>
2022-09-20 14:53:15 -06:00
Steve Manuel
e12efbeadb docs: add discord badge to readme 2022-09-17 01:01:11 -06:00
zach
5f096161da fix: use correct search path 2022-09-16 06:04:37 -07:00
zach
f0490058f1 cleanup: remove duplicate file 2022-09-16 06:04:06 -07:00
Jhaines1988
b7d52a1320 feat: update node sdk to use async call (#17) 2022-09-15 22:00:39 -06:00
Steve Manuel
c298208e04 ci: finish pypi release step 2022-09-14 11:37:01 -06:00
Steve Manuel
4c8a6b0ecb Merge branch 'main' of github.com:extism/extism 2022-09-14 11:26:05 -06:00
zach
f473be9044 meta: add scripts directory with SDK coverage script (#16)
Adds a script to check which runtime API functions are not used in each host SDK. Provides a coverage report with percent of functions called in each SDK. 

Co-authored-by: Steve Manuel <steve@dylib.so>
2022-09-14 11:12:05 -06:00
Steve Manuel
6883a5b6ba ci: add delay in release workflow to wait for crates.io 2022-09-14 09:21:06 -06:00
Steve Manuel
f9e9ff28d9 chore: bump versions for release, minimize c sdk imports (#15)
Co-authored-by: zach <zachshipko@gmail.com>
v0.0.1-rc.3
2022-09-13 13:27:58 -06:00
Steve Manuel
c9ded15dd2 Merge branch 'main' of github.com:extism/extism 2022-09-13 11:18:16 -06:00
Steve Manuel
e39901be68 ci: add no-verify to runtime release, bump rust sdk version 2022-09-13 11:17:59 -06:00
zach
4a49408045 fix: handle large allocations (missing commits) (#14) 2022-09-13 00:17:05 -06:00