Replies: 5 comments
-
Hello @Simonl9l, let me see if I understand you correctly, you want to write an http server in C#/F# and compile it to wasm, and then run it in host potentially written in a different language (Rust, Go, JS, Java, etc...), something like this: https://github.com/dotnet/dotnet-wasi-sdk/tree/main/samples/AspNetCoreOnNativeWasi If that's the case, I don't think you'll need Extism. As Extism is about providing an easy to use ABI for exporting functions. You can use it for your scenario, but with a different approach. You can export all of your endpoints as functions that accept a request and return a response, and then your host can handle the sockets and routing of the requests. So in a way, it would be similar to a Serverless Functions platform. In this way, your plugins can be written in any language supported by Extism. @nilslice and others might be able to offer more context |
Beta Was this translation helpful? Give feedback.
-
Extism has SDKs (runtimes) for most of the popular languages: https://extism.org/docs/quickstart/plugin-quickstart, and yes they are available for Windows (x64), macOS (both ARM64 and x64), and Linux (ARM64 and x64). For example, these are the architectures supported by the .NET SDK: If you need a different architecture that's not covered, please let us know |
Beta Was this translation helpful? Give feedback.
-
Hi @Simonl9l - As @mhmd-azeez alluded to, you're best off wrapping plugin calls inside .NET HTTP handlers. in pseudo-code,
Then, you can use the Extism HTTP Request functionality from the PDKs to make HTTP calls from these plugins. In .NET PDK: // create an HTTP Request (withuot relying on WASI), set headers as needed
var request = new HttpRequest("https://jsonplaceholder.typicode.com/todos/1")
{
Method = HttpMethod.GET,
};
request.Headers.Add("some-name", "some-value");
request.Headers.Add("another", "again");
var response = Pdk.SendRequest(request); Note: when using the Extism HTTP request library calls from PDK code, your Host (SDK) must allow the network call to be made to the particular URL host. This is done using the Manifest, or maybe some builder-pattern functions to configure the Plugin when it's instantiated. |
Beta Was this translation helpful? Give feedback.
-
We've be busy ourselves so apologies for not reply back sooner. Great 1.0 is out! From an "input" plugin perspective, the plan was to be able to run a full .net Minimal API server inside the plugin, such that it can consume customer specific web hooks that would be unknown form the host side of things. Related, I also mean to make this issue a discussion - not an bug!. |
Beta Was this translation helpful? Give feedback.
-
@Simonl9l Extism is mostly about allowing the Host and the Plugin to communicate with each other via functions. We use different runtimes for different host languages (wasmtime for Rust, C#, PHP, etc) and Wazero for Go, and the builtin runtime for JS. If you want to give direct socket access to the plugins, you probably will need to follow this example and I am not sure if Extism would be very helpful in that case. As @nilslice mentioned, the Extism way is to have the Host listen to the HTTP requests and delegate the requests to the plugin and then respond to the http request. So for example in your host ASP.NET Core controller action you would do something like:
|
Beta Was this translation helpful? Give feedback.
-
Totally new to all this and WASM/WASI in general.
given some initial poking around it seems that the WASI API is not (yet) networking aware?
it does seem however that wasmtime is?
for our use case (using the dotnet PDK) it would be great, as one of many similar use cases, to be able to host a dotnet server in a plugin such that one can receive HTTP/s requests, or HTTP clients that can make HTTP/s requests on other systems etc.
Is this possible?
As I understand it one needs to use
Microsoft.NET.Sdk
or other SDK project types supported - for above case one would needMicrosoft.NET.Sdk.Web
also to confirm the dotnet PDK and host is functional with runtime support on MacOS/Windows/Linux systems with ARM or x64 architectures.
Beta Was this translation helpful? Give feedback.
All reactions