专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像 官方专业版轩辕镜像 官方专业版官方专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题
其他
关于我们网站地图

官方QQ群: 1072982923

opengauss/wasmedge Docker 镜像 - 轩辕镜像 | Docker 镜像高效稳定拉取服务

热门搜索:openclaw🔥nginx🔥redis🔥mysqlopenjdkcursorweb2apimemgraphzabbixetcdubuntucorednsjdk
wasmedge
opengauss/wasmedge
opengauss
A complete and mature WebAssembly runtime for openGauss based on WasmEdge.
下载次数: 0状态:社区镜像维护者:opengauss仓库类型:镜像最近更新:2 年前
轩辕镜像,快一点,稳很多。点击查看
镜像简介版本下载
轩辕镜像,快一点,稳很多。点击查看

A complete and mature WebAssembly runtime for openGauss based on WasmEdge. It's an original way to extend your favorite database capabilities.

Note This project is inspired by wasmer-postgres

Features:

  • Easy to use: The wasmedge API mimics the standard WebAssembly API,
  • Fast: wasmedge executes the WebAssembly modules as fast as possible, close to native speed,
  • Safe: All calls to WebAssembly will be fast, but more importantly, completely safe and sandboxed.

Note: The project is still in heavy development. This is a 0.1.0 version. Some API are missing and are under implementation. But it's fun to play with it.

Installation

The project comes in two parts:

  1. A shared library, and
  2. A PL/pgSQL extension.

To compile the former, the wasmedge should have been installed. You can install the wasmedge as simple as

Refer to [***] for more details.

After that, run CREATE EXTENSION wasm_executor in a openGauss shell. One new function will appear: wasm_new_instance; It must be called with the absolute path to the shared library. It looks like this:

shell
$ # Build the shared library.
$ make

$ # Install the extension in the opengauss
$ make install

$ # Activate and initialize the extension.
$ gsql -d postgres -c 'CREATE EXTENSION wasm_executor'

And you are ready to go!

Usage & documentation

*** the examples/sum.rs program:

rust
#[no_mangle]
pub extern fn sum(x: i32, y: i32) -> i32 {
    x + y
}

For able to compile the rust code to wasm, the rust and wasm toolchain should be installed.

curl --proto '=https' --tlsv1.2 -sSf [***] | sh
rustup target add wasm32-unknown-unknown

And also install wasm-gc, which will be used to compress the .wasm file output

cargo install wasm-gc

Then create a project using cargo

cargo new hello --lib

The file Cargo.toml (aka "manifest") contains the project's configuration. Leave everything, but append a new block called [lib]. The result should look something this

[package]
name = "hello"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at [***]

[dependencies]

[lib]
crate-type = ["cdylib"]

Rust code lives in the src directory. Your new project contains the default file src/lib.rs. Replace its contents with the sum.rs. And then compile the project to Wasm and shrink the wasm output.

cargo build --target wasm32-unknown-unknown --release
wasm-gc target/wasm32-unknown-unknown/release/hello.wasm

Once compiled to WebAssembly, one obtains a similar WebAssembly binary to examples/sum.wasm. To use the sum exported function, first, create a new instance of the WebAssembly module, and second, call the sum function.

To instantiate a WebAssembly module, the wasm_new_instance function must be used. It has two arguments:

  1. The absolute path to the WebAssembly module, and
  2. A namespace used to prefix exported functions in SQL.

For instance, calling wasm_new_instance('/path/to/sum.wasm', 'wasm') will create the wasm_sum function that is a direct call to the sum exported function of the WebAssembly instance. Thus:

sql
-- New instance of the `sum.wasm` WebAssembly module.
SELECT wasm_new_instance('/absolute/path/to/sum.wasm', 'wasm');

-- Call a WebAssembly exported function!
SELECT wasm_sum(1, 2);

--  wasm_sum
-- --------
--       3
-- (1 row)

Isn't it awesome? Calling Rust from openGauss through WebAssembly!

Let's inspect a little bit further the wasm_sum function:

sql
\x
\df+ wasm_sum
Schema              | public
Name                | wasm_sum
Result data type    | integer
Argument data types | integer, integer
Type                | normal
Volatility          | volatile
Parallel            | unsafe
Owner               | ...
Language            | plpgsql
Source code         | ...
Description         |
fencedmode          | f
propackage          | f
prokind             | f

The openGauss wasm_sum signature is (integer, integer) -> integer, which maps the Rust sum signature (i32, i32) -> i32.

So far, only the WebAssembly types i32 and i64 are supported; they respectively map to integer and bigint in openGauss. Floats are partly implemented for the moment.

Quickstart

To get your hands on openGauss with wasm, we recommend using the Docker image. Download the docker image firstlly.

shell
docker pull opengauss/wasmedge:0.2.0

Then run it.

shell
docker run -it opengauss/wasmedge:0.2.0 bash

The rust and wasm toolchain have already installed in the docker image for quick use. So just go ahead and enjoy it.

Inspect a WebAssembly instance

The extension provides two ways to initilize a WebAssembly instance. As you can see from the functions name show above, one way is to use wasm_new_instance from .wasm file compiled from other languages.

And, the extension provides two tables, gathered together in the wasm foreign schema:

  • wasm.instances is a table with the id and wasm_file columns, respectively for the instance ID, and the path of the WebAssembly module,
  • wasm.exported_functions is a table with the instanceid, funcname, inputs and output columns, respectively for the instance ID of the exported function, its name, its input types (already formatted for openGauss), and its output types (already formatted for openGauss).

Let's see:

sql
-- Select all WebAssembly instances.
SELECT * FROM wasm.instances;

--      id        |          wasm_file
-- ---------------+-------------------------------
--  2785875771    | /absolute/path/to/sum.wasm
-- (1 row)

-- Select all exported functions for a specific instance.
SELECT
    funcname,
    inputs,
    outputs
FROM
    wasm.exported_functions
WHERE
    instanceid = 2785875771;

--   name  |     inputs      | outputs
-- --------+-----------------+---------
--  wasm_sum | integer,integer | integer
-- (1 row)

Benchmarks

Benchmarks are useless most of the time, but it shows that WebAssembly can be a credible alternative to procedural languages such as PL/pgSQL. Please, don't take those numbers for granted, it can change at any time, but it shows promising results:

BenchmarkRuntimeTime (ms)Ratio
Fibonacci (n = 50)openGauss-wasm-executor0.7651×
PL/pgSQL1.7142×
Fibonacci (n = 500)openGauss-wasm-executor0.7941×
PL/pgSQL9.74612×
Fibonacci (n = 5000)openGauss-wasm-executor0.8201×
PL/pgSQL92.720113×

License

The entire project is under the MulanPSL2 License. Please read the LICENSE file.

查看更多 wasmedge 相关镜像 →
wasmedge/wasmedge logo
wasmedge/wasmedge
wasmedge
提供WasmEdge的GitHub CI环境镜像,预安装编译依赖,基于master分支构建,支持多种操作系统、架构和工具链,部分镜像含插件构建依赖。
11 次收藏10万+ 次下载
3 天前更新
accupara/wasmedge logo
accupara/wasmedge
accupara
暂无描述
1万+ 次下载
6 个月前更新
labring/runwasi-wasmedge logo
labring/runwasi-wasmedge
labring
暂无描述
1万+ 次下载
2 年前更新

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

Docker 配置

登录仓库拉取

通过 Docker 登录认证访问私有仓库

专属域名拉取

无需登录使用专属域名

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

系统配置

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

MacOS OrbStack

MacOS OrbStack 容器配置

Docker Compose

Docker Compose 项目配置

NAS 设备

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

极空间

极空间 NAS 系统配置服务

网络设备

爱快路由

爱快 iKuai 路由系统配置

宝塔面板

在宝塔面板一键配置镜像

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

使用与功能问题

docker search 报错:专属域名下仅支持 Docker Hub 查询

docker search 报错问题

网页搜不到镜像:Docker Hub 有但轩辕镜像搜索无结果

镜像搜索不到

离线传输镜像:无法直连时用 docker save/load 迁移

离线传输镜像

Docker 插件安装错误:application/vnd.docker.plugin.v1+json

Docker 插件安装错误

WSL 下 Docker 拉取慢:网络与挂载目录影响及优化

WSL 拉取镜像慢

轩辕镜像是否安全?镜像完整性校验(digest)说明

镜像安全性

如何用轩辕镜像拉取镜像?登录方式与专属域名配置

如何拉取镜像

错误码与失败问题

manifest unknown 错误:镜像不存在或标签错误

manifest unknown 错误

TLS/SSL 证书验证失败:Docker pull 时 HTTPS 证书错误

TLS 证书验证失败

DNS 解析超时:无法解析镜像仓库地址或连接超时

DNS 解析超时

410 Gone 错误:Docker 版本过低导致协议不兼容

410 错误:版本过低

402 Payment Required 错误:流量耗尽错误提示

402 错误:流量耗尽

401 UNAUTHORIZED 错误:身份认证失败或登录信息错误

身份认证失败错误

429 Too Many Requests 错误:请求频率超出专业版限制

429 限流错误

Docker login 凭证保存错误:Cannot autolaunch D-Bus(不影响登录)

凭证保存错误

账号 / 计费 / 权限

免费版与专业版区别:功能、限额与使用场景对比

免费版与专业版区别

支持的镜像仓库:Docker Hub、GCR、GHCR、K8s 等列表

轩辕镜像支持的镜像仓库

拉取失败是否扣流量?计费规则说明

拉取失败流量计费

KYSEC 权限不够:麒麟 V10/统信 UOS 下脚本执行被拦截

KYSEC 权限错误

如何申请开具发票?(增值税普票/专票)

开具发票

如何修改网站与仓库登录密码?

修改网站和仓库密码

配置与原理类

registry-mirrors 未生效:仍访问官方仓库或报错的原因

registry-mirrors 未生效

如何去掉镜像名称中的轩辕域名前缀?(docker tag)

去掉域名前缀

如何拉取指定架构镜像?(ARM64/AMD64 等多架构)

拉取指定架构镜像

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
opengauss/wasmedge
博客公告Docker 镜像公告与技术博客
热门镜像查看热门 Docker 镜像推荐
一键安装一键安装 Docker 并配置镜像源
镜像拉取问题咨询请 提交工单,官方技术交流群:1072982923。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
镜像拉取问题咨询请提交工单,官方技术交流群:。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
官方邮箱:点击复制邮箱
©2024-2026 源码跳动
官方邮箱:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.