Skip to content

feat: add Rust environment#453

Merged
sanketsudake merged 4 commits into
masterfrom
rust-environment
Jun 7, 2026
Merged

feat: add Rust environment#453
sanketsudake merged 4 commits into
masterfrom
rust-environment

Conversation

@sanketsudake

Copy link
Copy Markdown
Member

What

Adds a new Rust language environment (rust-env / rust-builder), closing #81.

Design

The builder compiles each function into a complete native HTTP server binary (axum 0.8 / tokio).
The runtime image runs a small Rust supervisor that implements the env contract on :8888, spawns the function binary once at specialize, and reverse-proxies all requests to it over a pooled keep-alive connection — no per-request fork, no dynamic library loading (the FFI approach attempted in #81 is unsound because Rust has no stable ABI).

┌─ rust-env pod ───────────────────────────────┐
│  supervisor :8888                            │
│   ├ GET  /healthz                            │
│   ├ POST /specialize, /v2/specialize         │
│   └ /*  ── streaming reverse proxy ──▶ child │
│  function binary 127.0.0.1:8889              │
└──────────────────────────────────────────────┘

Function authoring

  • Single-file mode (--src hello.rs): one .rs file with pub async fn handler (any axum handler signature); extra sibling module files supported. The builder wraps it in a pre-compiled template crate, so builds only recompile the handler.
  • Cargo project mode (--src project.zip): any binary crate serving HTTP on $FISSION_RUNTIME_PORT — bring your own framework (axum/actix/rocket/warp). Multi-[[bin]] projects deploy all binaries and --entrypoint selects one at specialize.
  • fission-rust SDK crate (in-repo, vendored into the builder): fission_rust::serve(handler).

Contract notes

  • v1 /specialize loads from /userfunc/user; v2 handles file or directory filepath + functionName, with empty-filepath fallback like the binary env.
  • Bad deploy packages return 400 (parity with binary/server.go); pre-specialize requests return 500 "Container not specialized".
  • If the function process exits, the supervisor exits so Fission replaces the pod.
  • Builds inside one builder pod are serialized with flock; DEPLOY_PKG is created up front (the exact failure from Rust environment support #81).

Testing

  • cargo test — 12 unit tests (binary resolution, specialize contract, port resolution)
  • rust/test/local_test.sh — cluster-free contract test (specialize + proxy, both modes)
  • rust/tests/test_rust_env.sh — kind e2e: single-file (poolmgr + newdeploy) and Cargo project (POST echo)
  • Verified locally: both images build; builder runs in all three modes (single-file, multi-module, project); runtime specializes and proxies each artifact

Release

envconfig.json starts at 1.0.0; first merge publishes rust-env/rust-builder via the GHCR gate. The fission.io site needs a sync for the new environment after merge.

🤖 Generated with Claude Code

sanketsudake and others added 4 commits June 7, 2026 22:05
Cargo workspace for the new Rust environment:
- supervisor: implements the env contract on :8888 (healthz,
  specialize v1/v2), spawns the function binary once, reverse-proxies
  requests to it with a pooled streaming hyper client, and exits if
  the function process dies so fission replaces the pod.
- fission-rust: SDK crate; serve(handler)/serve_router(Router) on
  FISSION_RUNTIME_PORT with panic-catching middleware.
- template: crate the builder wraps around single-file functions.

Part of #81

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Runtime: multi-stage rust:1.96-bookworm -> debian:bookworm-slim with
  the supervisor as entrypoint.
- Builder: vendors the workspace and pre-compiles the template's
  dependency tree, so single-file builds only recompile the handler;
  builds are serialized with flock; deploy dir is created up front
  (the failure mode reported in #81).
- Examples: single-file hello.rs (SDK) and a Cargo project echo
  function using plain axum against the FISSION_RUNTIME_PORT contract.
- test/local_test.sh: cluster-free contract test covering both modes.

Verified: docker builds, builder runs for both modes, runtime
specializes and proxies both artifacts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- e2e kind test covering single-file (poolmgr + newdeploy) and Cargo
  project (POST echo) functions
- rust CI job with cargo test + cluster-free local test pre-step
- skaffold rust profile, root Makefile targets, CI path filters
- envconfig.json at 1.0.0 (regenerated environments.json) and README

Closes #81

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- supervisor: lock-free ready flag on the proxy hot path (specialize
  keeps its own mutex); 400 instead of 500 for bad deploy packages to
  match the binary env; empty v2 filepath falls back to /userfunc/user;
  strip hop-by-hop headers both ways; env-var overrides for function
  port and v1 code path; drop unused url field and unused deps.
- build.sh: binary paths now come from cargo --message-format=json
  instead of guessing target-dir layout; generated main.rs declares a
  module per user file so multi-module single-file packages actually
  compile; loud warning when the offline build falls back to network;
  multi-binary builds list --entrypoint choices in the build log.
- fission-rust: FISSION_RUNTIME_HOST overrides the bind address for
  running function binaries standalone.
- tests: local_test only kills processes that look like ours; e2e
  asserts the echoed JSON shape, not a substring of the request.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sanketsudake sanketsudake merged commit 0250b82 into master Jun 7, 2026
16 checks passed
sanketsudake added a commit to fission/fission.io that referenced this pull request Jun 8, 2026
* Add Rust environment to the catalog and docs

- environments catalog: rust-env + rust-builder card (generated)
- tools/environments.py: map rust-env -> Rust
- new language guide content/en/docs/usage/languages/rust.md
- supported-languages table + homepage language mentions
- optimized rust logo

Follows the merge of fission/environments#453 (rust-env + rust-builder
images live on GHCR multi-arch).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(rust): clarify how to depend on the fission-rust SDK (pin git rev)

Recommend pinning the fission-rust git dependency to a commit with rev
for reproducible builds, and note the builder fetches it over the network
at build time (builder egress required).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant