GithubHelp home page GithubHelp logo

faas-wasi-runtime-example's Introduction

FaaS WASI Runtime Image example

The idea here is to enable WebAssembly modules, possibly using the WebAssembly System Interface (WASI), to be executed as OpenShift Cloud Function. An end user would have a WASM module they would like to expose as a function. This WASM module could either be a module written and bundled with the users project, or could be a WASM module in the Web Assembly Package Manager (wapm) or in any other package manager, for example Node.js Package Manager (npm).

Building

To build the image, run the following command:

$ docker build -t <username>/faas-wasi-example .

WASM test module

The .wasm module used is located in module/add.wasm, and looks like this:

$ wasm2wat add.wasm
(module
  (type (;0;) (func (param i32 i32) (result i32)))
  (func (;0;) (type 0) (param i32 i32) (result i32)
    get_local 0
    get_local 1
    i32.add)
  (export "add" (func 0)))

Running locally

$ FUNCTION_NAME=add PORT=8080 MODULE_PATH=./module/add.wasm cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/faas-wasm-runtime-image`
WASI Runtime started. Port: 8080, Module path: ./module/add.wasm

And then from a second terminal you can call the service:

$ curl 'http://localhost:8080/data?nr1=10&nr2=23'
module: ./module/add.wasm, function: add, returned 33: i32

faas-wasi-runtime-example's People

Contributors

danbev avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.