Simple implementation of Web Container

Overview

Labor

Implementation of Web Container

Run

$ cd demo
$ yarn build
$ yarn dev

Detail

code => js runtime => rust/go wasm API

举个例子

const res = await readFile('a.js')

这一句代码中的 readFile 最终是要执行到 rust/go 中的 API 的,但到底怎么将 go 的 API 注入进去的呢?

此时就需要 go 注入到全局一个 API

js.Global().Set("readFile", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
    readFile(args[0].String()) // 相当于 eval
    return nil
}))

我们在 js 侧,只需要直接调用,不需要发接口

new Function('readFile', `const res = await readFile('a.js')`)(readFile)

大功告成,就是如此简单,在 wasm 端实现 API,然后在 js 侧注入到字符串里即可

但还没完,那么问题来了,文件系统呢?http呢?

这就得看 go 对 WASI 的支持程度了,亲测 net/http 包大部分支持良好,但不能启端口,osutil 包内存 API 是支持的

demo 只是打个比方,这个项目我会用 go 写,因为 docker 也是用 go 写的

值得一提的是,为了获得更好的性能和大小,我们接下来会使用类似 tinygo 的编译器

但是 trip worker 我还是会用 rust 实现,理由和 deno 一样,所以本质上,同一套标准库,我得写两遍了,呜呜呜

You might also like...
Amazon Web Services (AWS) providerAmazon Web Services (AWS) provider

Amazon Web Services (AWS) provider The Amazon Web Services (AWS) resource provider for Pulumi lets you use AWS resources in your cloud programs. To us

Witty - An unsafe web server to export shell to web
Witty - An unsafe web server to export shell to web

WiTTY: Web-based interactive TTY This program allows you to use terminal in the

Production-Grade Container Scheduling and Management
Production-Grade Container Scheduling and Management

Kubernetes (K8s) Kubernetes, also known as K8s, is an open source system for managing containerized applications across multiple hosts. It provides ba

Vilicus is an open source tool that orchestrates security scans of container images(docker/oci) and centralizes all results into a database for further analysis and metrics.
Vilicus is an open source tool that orchestrates security scans of container images(docker/oci) and centralizes all results into a database for further analysis and metrics.

Vilicus Table of Contents Overview How does it work? Architecture Development Run deployment manually Usage Example of analysis Overview Vilicus is an

 KEDA is a Kubernetes-based Event Driven Autoscaling component. It provides event driven scale for any container running in Kubernetes
KEDA is a Kubernetes-based Event Driven Autoscaling component. It provides event driven scale for any container running in Kubernetes

Kubernetes-based Event Driven Autoscaling KEDA allows for fine-grained autoscaling (including to/from zero) for event driven Kubernetes workloads. KED

Enterprise-grade container platform tailored for multicloud and multi-cluster management
Enterprise-grade container platform tailored for multicloud and multi-cluster management

KubeSphere Container Platform What is KubeSphere English | 中文 KubeSphere is a distributed operating system providing cloud native stack with Kubernete

⎈ Multi pod and container log tailing for Kubernetes

stern Stern allows you to tail multiple pods on Kubernetes and multiple containers within the pod. Each result is color coded for quicker debugging. T

Testcontainers is a Golang library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.

When I was working on a Zipkin PR I discovered a nice Java library called Testcontainers. It provides an easy and clean API over the go docker sdk to

Owner
伊撒尔
Chinese && Student && He/him Creator of Fre and other tiny libraries
伊撒尔
Boxygen is a container as code framework that allows you to build container images from code

Boxygen is a container as code framework that allows you to build container images from code, allowing integration of container image builds into other tooling such as servers or CLI tooling.

nitric 5 Dec 13, 2021
Amazon ECS Container Agent: a component of Amazon Elastic Container Service

Amazon ECS Container Agent The Amazon ECS Container Agent is a component of Amazon Elastic Container Service (Amazon ECS) and is responsible for manag

null 0 Dec 28, 2021
The Container Storage Interface (CSI) Driver for Fortress Block Storage This driver allows you to use Fortress Block Storage with your container orchestrator

fortress-csi The Container Storage Interface (CSI) Driver for Fortress Block Storage This driver allows you to use Fortress Block Storage with your co

Fortress 0 Jan 23, 2022
A toolbox for debugging docker container and kubernetes with web UI.

A toolbox for debugging Docker container and Kubernetes with visual web UI. You can start the debugging journey on any docker container host! You can

CloudNativer 54 Oct 20, 2022
How to get a Go / Golang app using the Gin web framework running natively on Windows Azure App Service WITHOUT using a Docker container

Go on Azure App Service View the running app -> https://go-azure-appservice.azurewebsites.net ?? This is an example repo of how to get a Go / Golang a

Ed Andersen 9 Nov 28, 2022
Sample Driver that provides reference implementation for Container Object Storage Interface (COSI) API

cosi-driver-minio Sample Driver that provides reference implementation for Container Object Storage Interface (COSI) API Community, discussion, contri

Kubernetes SIGs 7 Oct 10, 2022
Provide task runtime implementation with pidfd and eBPF sched_process_exit tracepoint to manage deamonless container with low overhead.

embedshim The embedshim is the kind of task runtime implementation, which can be used as plugin in containerd. With current shim design, it is used to

Fu Wei 94 Dec 18, 2022
A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI

A Simple and Comprehensive Vulnerability Scanner for Containers and other Artifacts, Suitable for CI. Table of Contents Abstract Features Installation

Aqua Security 15.4k Jan 1, 2023
⚔️ Web Hacker's Weapons / A collection of cool tools used by Web hackers. Happy hacking , Happy bug-hunting

A collection of cool tools used by Web hackers. Happy hacking , Happy bug-hunting Family project Table of Contents WHW-Tools Weapons Awesome Bookmarkl

HAHWUL 2.6k Jan 5, 2023
Help developer to sync between local file and remote apollo portal web since portal web is so messy to use

apollo-synchronizer Help developer to sync between local file and remote apollo portal web since portal web is so messy to use Features download names

yeqown 4 Oct 27, 2022