Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/monetize

crates/lake-product/src/lib.rs

//! **The Lake** (monetize v2.0 P1, 2026-10-24; it grew out of lane A17's echo product): the
//! prototype product for TESTING monetize. Fake inside, real in its contract: the buyer's
//! numbers are the estate's shape and price (the guest, `guests/lake`), the estate is PULLED
//! (its boxes report and pull their orders; the ONE box dials none of them), its roles are its
//! own (`front`, `ingestor`, `be`, `fe`, `graph`) and it has no twin.
//!
//! | integration point | where the Lake has it | the real ones |
//! |---|---|---|
//! | the monetize product guest (wasm) | `guests/lake` (`monetize-guest-lake`) | `gunnar-monetize-guest`, `holger-monetize-guest` |
//! | the buy site (`monetize_site_buy::BuySite`) | [`site::LakeSite`] | gunnar-ui `GunnarSite`, holger-estate-front `buy.rs` |
//! | the pairing door (the installer feeds each box) | [`lake_box`] `POST /pair` | gunnar-server `installer_listener`, holger `paired.rs` |
//! | the front door (the sale check reads it) | [`lake_box`] `GET /login`, `GET /first-login` | gunnar-front, holger-estate-front |
//! | the fleet door (each box reports and pulls orders) | [`lake_box::LakeBox::report`], [`lake_box::LakeBox::orders`] | gunnar-repair `fleet.rs`, holger-fleet `puller.rs` |
//! | the live update door | [`lake_box`] `GET /live/running`, `POST /live/stage` | korp live over nordisk-pairing `live` |
//! | the keep update door | [`lake_box`] `POST /keep` | the keep medium (`install_then=poweroff`) |
//! | reports and metering | the `product` part of each box's Fleet report (`ingested_bytes`) | gunnar's and holger's reports |
//! | the installer seam (`monetize_server::estate_order::Installer`) | [`installer::LakeInstaller`] (the bench's double) | monetize-shop-pairing `ShopPairing` |
//!
//! Every call any of them gets is PRINTED as one plain line by [`say`]:
//! `lake: EstateOrder.Start from bench company=acme`. `cargo xtask bench lake` ([`bench`]) lays
//! it on the ONE box's real code, against the mock cloud and the test vendor, and writes a
//! receipt.

pub mod bench;
pub mod http;
pub mod installer;
pub mod lake_box;
pub mod signed;
pub mod site;

use std::sync::{Mutex, OnceLock};

fn book() -> &'static Mutex<Vec<String>> {
    static BOOK: OnceLock<Mutex<Vec<String>>> = OnceLock::new();
    BOOK.get_or_init(|| Mutex::new(Vec::new()))
}

/// **One plain line per call**: `lake: <door>.<call> from <who> <what>`, printed and kept for
/// the receipt.
pub fn say(door: &str, call: &str, from: &str, what: &str) {
    let line = format!("lake: {door}.{call} from {from} {what}")
        .trim_end()
        .to_string();
    said(&line);
}

/// A line already in the Lake form (the guest's own lines, as the host logs them).
pub fn said(line: &str) {
    println!("{line}");
    book().lock().unwrap().push(line.to_string());
}

/// Every line said so far.
pub fn lines() -> Vec<String> {
    book().lock().unwrap().clone()
}