Skip to content

A PostgreSQL extension to serve your API by running WebAssembly in bgworkers, also the runtime for the Rustica language.

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE.Apache-2.0
Unknown
LICENSE.MulanPSL-2.0
Notifications You must be signed in to change notification settings

rustica-lang/rustica-engine

Repository files navigation

Rustica Engine - Postgres as an API Server!

中文 license license

Rustica Engine is a PostgreSQL extension that allows you to run WebAssembly modules in the database securely, turning your database into an API server.

This project is a work in progress and not ready for production use.

Features

  • Fast: AoT-compiled WASM (by WAMR/LLVM) and prepared queries
  • Secure: strictly sandboxed in bgworker processes
  • Native: PostgreSQL types/Datums directly in the guest
  • Zero-Copy: operate on network buffers and database pages

Rustica Engine does not use WASI or Component Model, but defines a custom set of FFIs at a finer granularity, providing optimized bindings for various PostgreSQL data types and functions.

Currently, the following programming languages can generate WebAssembly modules suitable for the Rustica Engine:

  • Rustica (using MoonGRES backend)
  • MoonBit (via MoonGRES extension)

Rustica Engine is also packaged as a standalone command-line application, statically linked with PostgreSQL backend code, which can run the same WebAssembly programs without starting a database server. This is particularly useful for debugging and testing.

Development

This project is configured with a modified Meson, built by uv, and uses Ninja as the build system. The Makefile provides some convenient command wrappers.

  • Install system dependencies (Arch Linux)

    $ sudo pacman -S make gcc ninja uv llvm18 bison flex
    
  • Build extension and run the dev Postgres:

    $ make
    $ make run
    

Testing

  1. Install MoonGRES:

    $ curl ...TBD... | sh
    
  2. Replace the rustica-engine bundled with MoonGRES with the one freshly built:

    $ ln -sf $(pwd)/install/bin/rustica-engine ~/.moon/bin/rustica-engine
    
  3. Run MoonBit core test suite:

    $ cd ~/.moon/lib/core && moon test --target moongres
    

License

This project is dual-licensed under:

  • Apache License, Version 2.0
  • Mulan Permissive Software License, Version 2

You may choose either license to use this project freely, provided that you comply with the terms of the chosen license.

SPDX-License-Identifier: Apache-2.0 OR MulanPSL-2.0

About

A PostgreSQL extension to serve your API by running WebAssembly in bgworkers, also the runtime for the Rustica language.

Topics

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE.Apache-2.0
Unknown
LICENSE.MulanPSL-2.0

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •