Embroidery: local development

Embroidery is Mozilla's image service, a Rust service in apps/embroidery. It replaces the Navigational Suggestions job: it stores entities, fetches their favicons and logos, and serves them to Firefox.

Prerequisites

  • rustup. From the repository root, install the toolchain pinned in rust-toolchain.toml once, before running moon tasks, which start several Cargo commands in parallel:

    rustup toolchain install
    
  • Moon, as described in Working in the monorepo.

Run the service

cd apps/embroidery
cargo run -- serve
curl -i localhost:8000/__heartbeat__

EMBROIDERY_ENV defaults to development, which binds 127.0.0.1:8000 and logs human-readable lines. To see the MozLog JSON that deployments emit:

EMBROIDERY_LOGGING__FORMAT=mozlog cargo run -- serve

Configuration

Later sources override earlier ones:

SourceExample
configs/default.toml, embedded in the binary[server] port = 8000
configs/${EMBROIDERY_ENV}.toml, embeddeddevelopment.toml, production.toml
configs/${EMBROIDERY_ENV}.local.toml, optional, gitignoredyour overrides
EMBROIDERY_SECTION__KEY environment variablesEMBROIDERY_SERVER__PORT=9000

EMBROIDERY_ENV accepts development, testing, stage and production. The service fails at startup with the offending key when a value is invalid or a section contains an unknown key. configs/default.toml documents every setting.

Endpoints

RouteResponse
GET /__lbheartbeat__200, empty. Liveness, checks no backend.
GET /__heartbeat__200 with {"status":"ok","checks":{}}. Readiness.
GET /__version__The contents of version_file, or 500 if it's missing.

Checks

From the repository root:

moon run embroidery:format-check embroidery:lint embroidery:test

moon run :lint and moon run :test include Embroidery alongside the Python projects.

Tests

The tests run with cargo-nextest. Moon installs it and cargo-llvm-cov the first time it runs a Rust task, so Docker, rustup and moon are the only prerequisites.

SuiteLocationNeeds
Unit#[cfg(test)] modules in src/nothing
Integrationtests/*.rsDocker, for PostgreSQL 18 and fake-gcs-server containers
moon run embroidery:test          # runs both suites
moon run embroidery:unit-test     # no Docker needed
moon run embroidery:coverage      # writes workspace/test-results/moon/embroidery/coverage.json

Every integration test starts its own containers with testcontainers: TestDb::start() for PostgreSQL and TestBucket::create() for fake-gcs-server, both in tests/common. Each waits until its server accepts requests and removes the container when the test ends, so tests run in parallel without sharing state, on random host ports that don't clash with a local PostgreSQL or dev/docker-compose.yaml.

A single integration test runs without moon or extra setup:

cd apps/embroidery
cargo nextest run --test test_services bucket_reads_back_written_object