Zum Inhalt springen

Host-Funktionen

WASM-Module greifen ueber Host-Funktions-Imports auf Runtime-Faehigkeiten zu. Jeder Import wird explizit pro Eintrag in der imports-Liste deklariert.

ImportBeschreibung
wasi:cliUmgebung, Exit, stdin/stdout/stderr, Terminal
wasi:ioStreams, Fehlerbehandlung, Polling
wasi:clocksWall Clock und Monotonic Clock
wasi:filesystemDateisystemzugriff ueber gemountete Verzeichnisse
wasi:randomKryptografisch sichere Zufallszahlen
wasi:socketsTCP/UDP-Netzwerk und DNS-Aufloesung
wasi:httpAusgehende HTTP-Client-Anfragen

Aktivieren Sie Imports in Ihrer Entry-Konfiguration:

- name: my_function
kind: function.wasm
fs: myns:assets
path: /module.wasm
hash: sha256:...
method: run
imports:
- wasi:cli
- wasi:io
- wasi:clocks
- wasi:filesystem
pool:
type: inline

Deklarieren Sie nur die Imports, die Ihr Modul tatsaechlich benoetigt.

Jeder wasi:*-Import aktiviert eine Gruppe verwandter WASI Preview 2 Schnittstellen.

Interfaces: wasi:clocks/wall-clock, wasi:clocks/monotonic-clock

Wall Clock und Monotonic Clock fuer Zeitoperationen. Die Monotonic Clock integriert sich in den Wippy-Dispatcher fuer asynchrones Sleep.

Interfaces: wasi:io/error, wasi:io/streams, wasi:io/poll

Stream-Lese-/Schreiboperationen und asynchrones Polling. Die Poll-Schnittstelle ermoeglicht kooperatives Yielding ueber den Dispatcher.

Interfaces: wasi:cli/environment, wasi:cli/exit, wasi:cli/stdin, wasi:cli/stdout, wasi:cli/stderr

Zugriff auf Umgebungsvariablen, Prozess-Exit-Codes und Standard-I/O-Streams. Umgebungsvariablen werden ueber die WASI-Konfiguration aus der Wippy-Umgebungs-Registry abgebildet.

Interfaces: wasi:filesystem/types, wasi:filesystem/preopens

Dateisystemzugriff ueber gemountete Verzeichnisse. Mounts werden pro Eintrag konfiguriert und bilden Wippy-Dateisystem-Eintraege auf Guest-Pfade ab.

wasi:
mounts:
- fs: myns:data
guest: /data
read_only: true

Interfaces: wasi:random/random, wasi:random/insecure, wasi:random/insecure-seed

Kryptografisch sichere und unsichere Zufallszahlengenerierung.

Interfaces: wasi:sockets/network, wasi:sockets/instance-network, wasi:sockets/ip-name-lookup, wasi:sockets/tcp, wasi:sockets/tcp-create-socket, wasi:sockets/udp

TCP- und UDP-Netzwerk mit DNS-Aufloesung. Socket-Operationen integrieren sich in den Dispatcher fuer asynchrone I/O.

Interfaces: wasi:http/types, wasi:http/outgoing-handler

Ausgehende HTTP-Client-Anfragen aus WASM-Modulen. Unterstuetzt Request/Response-Typen, die durch die WASI-HTTP-Spezifikation definiert sind.