Skip to content

gojinn-io/gojinn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

56 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

🧞 Gojinn

Go Reference CI Status Build Status Wasm Engine Sponsor

A Sovereign, In-Process Serverless Runtime for Caddy
Execute untrusted code securely with WebAssembly β€” no containers, no orchestration, no control plane.

Gojinn is a high-performance WebAssembly runtime embedded directly into the Caddy web server.
It allows you to run isolated, deterministic functions inside the HTTP request lifecycle β€” safely and with near-native performance.


πŸ”‘ What Gojinn Is (and Is Not)

βœ… Gojinn is

  • A WASM-based serverless runtime
  • Single-binary, self-hosted, and auditable
  • Deterministic, sandboxed, and capability-based
  • Designed for sovereign infrastructure and edge environments

❌ Gojinn is NOT

  • A container orchestrator
  • A Kubernetes replacement
  • A managed cloud service
  • A general-purpose VM or process supervisor

Gojinn executes code and events β€” not infrastructure.


πŸš€ Why Gojinn?

Modern serverless stacks suffer from:

  • cold starts
  • idle resource waste
  • infrastructure sprawl
  • opaque control planes
  • vendor lock-in

Gojinn takes a different approach:

  • In-process execution β†’ no network hops, no sidecars
  • Zero idle cost β†’ no requests, no memory usage
  • Strong isolation β†’ every request runs in a fresh WASM sandbox
  • Opinionated design β†’ fewer knobs, more correctness
  • Open & Sovereign β†’ Apache-2.0, self-hosted, auditable

⚑ Performance at a Glance

Metric Docker (Alpine/Go) Gojinn (WASM)
Artifact Size ~20 MB image ~3 MB binary
Execution Model Persistent daemon Ephemeral sandbox
Idle Resource Usage Always-on Zero
Cold Start ~1500ms <1ms

Gojinn prioritizes predictable latency and isolation over long-lived processes.

Detailed benchmarks: docs/benchmark.md


🧠 Core Design Invariant

All user code executes inside a deterministic, isolated, ephemeral WASM sandbox and is never trusted by default.

This invariant is non-negotiable and enforced by governance.
Any feature or contribution that violates it will be rejected.

See: GOVERNANCE.md


πŸ— High-Level Architecture

Gojinn runs inside Caddy, not behind it.

sequenceDiagram
    Client->>Caddy: HTTP Request
    Caddy->>Gojinn: Intercept + Context Injection
    Gojinn->>Wazero: Create Sandbox (CPU / Memory limits)
    Wazero->>WASM: JSON via stdin
    WASM->>Wazero: JSON via stdout
    Wazero->>Gojinn: Response
    Gojinn->>Caddy: Stream Response
    Gojinn->>Wazero: Destroy Sandbox
Loading

Architecture details: docs/concepts/architecture.md

πŸ›  Installation

Gojinn is distributed as a Caddy plugin.

Using xcaddy (recommended)

xcaddy build \
  --with github.com/pauloappbr/gojinn

βš™οΈ Configuration (Caddyfile)

{
    order gojinn last
    admin :2019
}

:8080 {
    handle /api/* {
        gojinn ./functions/processor.wasm {
            timeout 2s
            memory_limit 128MB

            env DB_HOST "localhost"
            env API_KEY {env.SECRET_KEY}
        }
    }
}

Full reference: docs/reference/caddyfile.md

🧩 Writing Functions (The Contract)

Gojinn uses a strict JSON protocol over stdin/stdout.

  • stdin β†’ request context (JSON)
  • stdout β†’ response (JSON)
  • stderr β†’ logs only

Language support is polyglot via WASM:

  • Go
  • Rust
  • Zig
  • C / C++
  • Swift (experimental)

Contract definition: docs/concepts/contract.md

πŸ“Š Observability

Built-in, no sidecars required:

  • Metrics β†’ Prometheus
  • Tracing β†’ OpenTelemetry
  • Logs β†’ Structured, via Caddy

Metrics endpoint:

http://localhost:2019/metrics

πŸ“š Documentation

  • Getting Started
  • Guides
  • Concepts
  • Use Cases

🧭 Project Direction

  • Roadmap
  • Manifesto
  • Governance

Gojinn is built with long-term correctness, not short-term convenience.

🀝 Community & Support

  • Contributions
  • Support policy
  • Security issues

πŸ“„ License

Apache License 2.0
See LICENSE

About

In-Process Serverless Runtime for Caddy. Run Go, Rust & Zig functions via WebAssembly with ~1ms cold starts. Features: Host-Managed DB Pool (Postgres/MySQL/SQLite), In-Memory KV Store & Secure Sandboxing.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors