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.