Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm

Compare changes

Choose any two refs to compare.

+21
.github/workflows/build.yml
···
···
+
name: Build
+
+
on:
+
push:
+
tags:
+
- "reflector-v*.*.*"
+
+
jobs:
+
build:
+
runs-on: ubuntu-latest
+
permissions:
+
contents: write
+
+
steps:
+
- uses: actions/checkout@v4
+
- name: build reflector
+
run: cargo build --bin reflector --release && mv target/release/reflector target/release/reflector_amd64
+
- name: release
+
uses: softprops/action-gh-release@v2
+
with:
+
files: target/release/reflector_amd64
+1 -1
.github/workflows/checks.yml
···
- name: get nightly toolchain for jetstream fmt
run: rustup toolchain install nightly --allow-downgrade -c rustfmt
- name: fmt
-
run: cargo fmt --package links --package constellation --package ufos --package spacedust --package who-am-i --package slingshot -- --check
- name: fmt jetstream (nightly)
run: cargo +nightly fmt --package jetstream -- --check
- name: clippy
···
- name: get nightly toolchain for jetstream fmt
run: rustup toolchain install nightly --allow-downgrade -c rustfmt
- name: fmt
+
run: cargo fmt --package links --package constellation --package ufos --package spacedust --package who-am-i --package slingshot --package pocket -- --check
- name: fmt jetstream (nightly)
run: cargo +nightly fmt --package jetstream -- --check
- name: clippy
+833 -259
Cargo.lock
···
[[package]]
name = "anyhow"
-
version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
[[package]]
name = "arbitrary"
···
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
[[package]]
name = "arrayvec"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"proc-macro2",
"quote",
"serde",
-
"syn 2.0.103",
]
[[package]]
···
"nom",
"num-traits",
"rusticata-macros",
-
"thiserror 2.0.12",
"time",
]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
"synstructure",
]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46355d3245edc7b3160b2a45fe55d09a6963ebd3eee0252feb6b72fb0eb71463"
dependencies = [
-
"atrium-common",
-
"atrium-xrpc",
"chrono",
"http",
"ipld-core",
···
]
[[package]]
name = "atrium-identity"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9e2d42bb4dbea038f4f5f45e3af2a89d61a9894a75f06aa550b74a60d2be380"
dependencies = [
-
"atrium-api",
-
"atrium-common",
-
"atrium-xrpc",
"serde",
"serde_html_form",
"serde_json",
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca22dc4eaf77fd9bf050b21192ac58cd654a437d28e000ec114ebd93a51d36f5"
dependencies = [
-
"atrium-api",
-
"atrium-common",
-
"atrium-identity",
-
"atrium-xrpc",
"base64 0.22.1",
"chrono",
"dashmap",
···
]
[[package]]
name = "auto_enums"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"derive_utils",
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
"axum-core",
"bytes",
"cookie",
"futures-util",
"headers",
"http",
···
"pin-project-lite",
"rustversion",
"serde",
"tower",
"tower-layer",
"tower-service",
···
"axum",
"handlebars",
"serde",
-
"thiserror 2.0.12",
]
[[package]]
···
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"regex",
"rustc-hash 1.1.0",
"shlex",
-
"syn 2.0.103",
"which",
]
···
"regex",
"rustc-hash 1.1.0",
"shlex",
-
"syn 2.0.103",
]
[[package]]
···
"regex",
"rustc-hash 2.1.1",
"shlex",
-
"syn 2.0.103",
]
[[package]]
···
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "6236364b88b9b6d0bc181ba374cf1ab55ba3ef97a1cb6f8cddad48a273767fb5"
[[package]]
name = "bzip2-sys"
version = "0.1.13+1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "camino"
-
version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3"
dependencies = [
-
"serde",
]
[[package]]
···
]
[[package]]
name = "cc"
version = "1.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
]
[[package]]
name = "cid"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"multihash",
"serde",
"serde_bytes",
-
"unsigned-varint",
]
[[package]]
···
[[package]]
name = "clap"
-
version = "4.5.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9"
dependencies = [
"clap_builder",
"clap_derive",
···
[[package]]
name = "clap_builder"
-
version = "4.5.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d"
dependencies = [
"anstream",
"anstyle",
···
[[package]]
name = "clap_derive"
-
version = "4.5.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491"
dependencies = [
"heck",
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
[[package]]
name = "constellation"
version = "0.1.0"
dependencies = [
···
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crypto-bigint"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"proc-macro2",
"quote",
"strsim 0.11.1",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"darling_core 0.20.11",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
]
[[package]]
name = "data-encoding"
-
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010"
[[package]]
name = "data-encoding-macro"
-
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "9f9724adfcf41f45bf652b3995837669d73c4d49a1b5ac1ff82905ac7d9b5558"
dependencies = [
"data-encoding",
"data-encoding-macro-internal",
···
[[package]]
name = "data-encoding-macro-internal"
-
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "18e4fdb82bd54a12e42fb58a800dcae6b9e13982238ce2296dc3570b92148e1f"
dependencies = [
"data-encoding",
-
"syn 2.0.103",
]
[[package]]
···
"darling 0.20.11",
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c"
dependencies = [
"derive_builder_core",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
"unicode-xid",
]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
[[package]]
name = "dropshot"
-
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "50e8fed669e35e757646ad10f97c4d26dd22cce3da689b307954f7000d2719d0"
dependencies = [
"async-stream",
"async-trait",
···
"http-body-util",
"hyper",
"hyper-util",
-
"indexmap 2.9.0",
"multer",
"openapiv3",
"paste",
···
"slog-bunyan",
"slog-json",
"slog-term",
-
"thiserror 2.0.12",
"tokio",
"tokio-rustls 0.25.0",
-
"toml",
"uuid",
"version_check",
"waitgroup",
···
[[package]]
name = "dropshot_endpoint"
-
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "acebb687581abdeaa2c89fa448818a5f803b0e68e5d7e7a1cf585a8f3c5c57ac"
dependencies = [
"heck",
"proc-macro2",
···
"semver",
"serde",
"serde_tokenstream",
-
"syn 2.0.103",
]
[[package]]
···
"heck",
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
"once_cell",
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
]
[[package]]
name = "fastrand"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "fjall"
-
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "26b2ced3483989a62b3533c9f99054d73b527c6c0045cf22b00fe87956f1a46f"
dependencies = [
"byteorder",
-
"byteview",
"dashmap",
"log",
-
"lsm-tree",
"path-absolutize",
"std-semaphore",
"tempfile",
···
]
[[package]]
name = "flate2"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"mixtrics",
"pin-project",
"serde",
-
"thiserror 2.0.12",
"tokio",
"tracing",
]
···
"parking_lot",
"pin-project",
"serde",
-
"thiserror 2.0.12",
"tokio",
"twox-hash",
]
···
"parking_lot",
"pin-project",
"serde",
-
"thiserror 2.0.12",
"tokio",
"tracing",
]
···
"pin-project",
"rand 0.9.1",
"serde",
-
"thiserror 2.0.12",
"tokio",
"tracing",
"twox-hash",
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
"futures-core",
"futures-sink",
"http",
-
"indexmap 2.9.0",
"slab",
"tokio",
"tokio-util",
···
]
[[package]]
name = "handlebars"
version = "6.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"pest_derive",
"serde",
"serde_json",
-
"thiserror 2.0.12",
"walkdir",
]
···
]
[[package]]
name = "headers"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "hickory-proto"
version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"once_cell",
"rand 0.9.1",
"ring",
-
"thiserror 2.0.12",
"tinyvec",
"tokio",
"tracing",
···
"rand 0.9.1",
"resolv-conf",
"smallvec",
-
"thiserror 2.0.12",
"tokio",
"tracing",
]
···
"js-sys",
"log",
"wasm-bindgen",
-
"windows-core 0.61.0",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
[[package]]
name = "indexmap"
-
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e"
dependencies = [
"equivalent",
"hashbrown 0.15.2",
"serde",
]
[[package]]
···
]
[[package]]
name = "is-terminal"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
dependencies = [
"anyhow",
"async-trait",
-
"atrium-api",
"chrono",
"clap",
"futures-util",
···
"metrics",
"serde",
"serde_json",
-
"thiserror 2.0.12",
"tokio",
"tokio-tungstenite 0.26.2",
"url",
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
]
[[package]]
name = "langtag"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
]
[[package]]
name = "libz-sys"
version = "1.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
version = "0.1.0"
dependencies = [
"anyhow",
"fluent-uri",
"nom",
-
"thiserror 2.0.12",
"tinyjson",
]
···
[[package]]
name = "log"
-
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "loom"
···
[[package]]
name = "lsm-tree"
-
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "d0a63a5e98a38b51765274137d8aedfbd848da5f4d016867e186b673fcc06a8c"
dependencies = [
"byteorder",
"crossbeam-skiplist",
···
]
[[package]]
name = "lz4"
version = "1.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "lz4_flex"
-
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5"
[[package]]
name = "mach2"
···
"spin",
"tokio",
"tokio-util",
-
"toml",
"tracing",
"tracing-subscriber",
]
···
]
[[package]]
name = "match_cfg"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "matchers"
-
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
-
"regex-automata 0.1.10",
]
[[package]]
···
"http-body-util",
"hyper",
"hyper-util",
-
"indexmap 2.9.0",
"ipnet",
"metrics",
"metrics-util 0.19.0",
···
"hyper",
"hyper-rustls",
"hyper-util",
-
"indexmap 2.9.0",
"ipnet",
"metrics",
"metrics-util 0.20.0",
"quanta",
-
"thiserror 2.0.12",
"tokio",
"tracing",
]
···
[[package]]
name = "multibase"
-
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404"
dependencies = [
"base-x",
"data-encoding",
"data-encoding-macro",
]
···
dependencies = [
"core2",
"serde",
-
"unsigned-varint",
]
[[package]]
···
[[package]]
name = "nu-ansi-term"
-
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
-
"overload",
-
"winapi",
]
[[package]]
···
[[package]]
name = "openapiv3"
-
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "cc02deea53ffe807708244e5914f6b099ad7015a207ee24317c22112e17d9c5c"
dependencies = [
-
"indexmap 2.9.0",
"serde",
"serde_json",
]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
]
[[package]]
-
name = "overload"
-
version = "0.1.1"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
-
-
[[package]]
name = "p256"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323"
dependencies = [
"memchr",
-
"thiserror 2.0.12",
"ucd-trie",
]
···
"pest_meta",
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
[[package]]
name = "poem"
version = "3.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"headers",
"http",
"http-body-util",
"hyper",
"hyper-util",
"mime",
"multer",
"nix",
"parking_lot",
···
"smallvec",
"sync_wrapper",
"tempfile",
-
"thiserror 2.0.12",
"tokio",
"tokio-rustls 0.26.2",
"tokio-stream",
···
"proc-macro-crate",
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
"bytes",
"derive_more",
"futures-util",
-
"indexmap 2.9.0",
"itertools 0.14.0",
"mime",
"num-traits",
···
"serde_json",
"serde_urlencoded",
"serde_yaml",
-
"thiserror 2.0.12",
"tokio",
]
···
dependencies = [
"darling 0.20.11",
"http",
-
"indexmap 2.9.0",
"mime",
"proc-macro-crate",
"proc-macro2",
"quote",
"regex",
-
"syn 2.0.103",
-
"thiserror 2.0.12",
]
[[package]]
···
checksum = "6837b9e10d61f45f987d50808f83d1ee3d206c66acf650c3e4ae2e1f6ddedf55"
dependencies = [
"proc-macro2",
-
"syn 2.0.103",
]
[[package]]
···
]
[[package]]
name = "quick-xml"
version = "0.36.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "quick_cache"
-
version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "8f8ed0655cbaf18a26966142ad23b95d8ab47221c50c4f73a1db7d0d2d6e3da8"
dependencies = [
"equivalent",
"hashbrown 0.15.2",
···
"rustc-hash 2.1.1",
"rustls 0.23.31",
"socket2 0.5.9",
-
"thiserror 2.0.12",
"tokio",
"tracing",
"web-time",
···
"rustls 0.23.31",
"rustls-pki-types",
"slab",
-
"thiserror 2.0.12",
"tinyvec",
"tracing",
"web-time",
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"aho-corasick",
"memchr",
-
"regex-automata 0.4.9",
-
"regex-syntax 0.8.5",
-
]
-
-
[[package]]
-
name = "regex-automata"
-
version = "0.1.10"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
-
dependencies = [
-
"regex-syntax 0.6.29",
]
[[package]]
···
dependencies = [
"aho-corasick",
"memchr",
-
"regex-syntax 0.8.5",
]
[[package]]
name = "regex-syntax"
-
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
-
name = "regex-syntax"
-
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "reqwest"
-
version = "0.12.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531"
dependencies = [
"async-compression",
"base64 0.22.1",
···
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
]
···
"spki",
"subtle",
"zeroize",
]
[[package]]
···
"proc-macro2",
"quote",
"serde_derive_internals",
-
"syn 2.0.103",
]
[[package]]
···
]
[[package]]
name = "security-framework"
version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "self_cell"
-
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "c2fdfc24bc566f839a2da4c4295b82db7d25a24253867d5c64355abb5799bdbe"
[[package]]
name = "semver"
···
[[package]]
name = "serde"
-
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_bytes"
-
version = "0.11.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96"
dependencies = [
"serde",
]
[[package]]
name = "serde_derive"
-
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
checksum = "9d2de91cf02bbc07cde38891769ccd5d4f073d22a40683aa4bc7a95781aaa2c4"
dependencies = [
"form_urlencoded",
-
"indexmap 2.9.0",
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_json"
-
version = "1.0.141"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]
[[package]]
···
"percent-encoding",
"ryu",
"serde",
-
"thiserror 2.0.12",
]
[[package]]
···
]
[[package]]
name = "serde_tokenstream"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"proc-macro2",
"quote",
"serde",
-
"syn 2.0.103",
]
[[package]]
···
"chrono",
"hex",
"indexmap 1.9.3",
-
"indexmap 2.9.0",
"serde",
"serde_derive",
"serde_json",
···
"darling 0.20.11",
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
-
"indexmap 2.9.0",
"itoa",
"ryu",
"serde",
"unsafe-libyaml",
]
[[package]]
···
dependencies = [
"num-bigint",
"num-traits",
-
"thiserror 2.0.12",
"time",
]
···
name = "slingshot"
version = "0.1.0"
dependencies = [
-
"atrium-api",
-
"atrium-common",
-
"atrium-identity",
-
"atrium-oauth",
"clap",
"ctrlc",
"foyer",
"hickory-resolver",
"jetstream",
"log",
"metrics",
"metrics-exporter-prometheus 0.17.2",
···
"rustls 0.23.31",
"serde",
"serde_json",
-
"thiserror 2.0.12",
"time",
"tokio",
"tokio-util",
···
name = "spacedust"
version = "0.1.0"
dependencies = [
"async-trait",
"clap",
"ctrlc",
"dropshot",
"env_logger",
"futures",
"http",
"jetstream",
"links",
"log",
"metrics",
"metrics-exporter-prometheus 0.17.2",
"rand 0.9.1",
"schemars",
"semver",
"serde",
"serde_json",
"serde_qs",
-
"thiserror 2.0.12",
"tinyjson",
"tokio",
"tokio-tungstenite 0.27.0",
···
[[package]]
name = "syn"
-
version = "2.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "e4307e30089d6fd6aff212f2da3a1f9e32f3223b1f010fb09b7c95f90f3ca1e8"
dependencies = [
"proc-macro2",
"quote",
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
[[package]]
name = "tempfile"
-
version = "3.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf"
dependencies = [
"fastrand",
"getrandom 0.3.3",
···
[[package]]
name = "thiserror"
-
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
dependencies = [
-
"thiserror-impl 2.0.12",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
name = "thiserror-impl"
-
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
[[package]]
name = "tokio"
-
version = "1.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35"
dependencies = [
"backtrace",
"bytes",
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
dependencies = [
"serde",
-
"serde_spanned",
-
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
]
[[package]]
name = "toml_edit"
version = "0.22.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
-
"indexmap 2.9.0",
"serde",
-
"serde_spanned",
-
"toml_datetime",
"toml_write",
"winnow",
]
[[package]]
name = "toml_write"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
[[package]]
name = "tower"
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
[[package]]
name = "tracing-subscriber"
-
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
-
"regex",
"sharded-slab",
"smallvec",
"thread_local",
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
"native-tls",
"rand 0.9.1",
"sha1",
-
"thiserror 2.0.12",
"url",
"utf-8",
]
···
"log",
"rand 0.9.1",
"sha1",
-
"thiserror 2.0.12",
"utf-8",
]
···
"clap",
"dropshot",
"env_logger",
-
"fjall",
"getrandom 0.3.3",
"http",
"jetstream",
"log",
-
"lsm-tree",
"metrics",
"metrics-exporter-prometheus 0.17.2",
"schemars",
···
"serde_qs",
"sha2",
"tempfile",
-
"thiserror 2.0.12",
"tikv-jemallocator",
"tokio",
"tokio-util",
···
[[package]]
name = "unsigned-varint"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06"
···
[[package]]
name = "uuid"
-
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9"
dependencies = [
"getrandom 0.3.3",
"serde",
]
[[package]]
···
[[package]]
name = "value-log"
-
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "fd29b17c041f94e0885179637289815cd038f0c9fc19c4549d5a97017404fb7d"
dependencies = [
"byteorder",
-
"byteview",
"interval-heap",
"log",
"path-absolutize",
···
"log",
"proc-macro2",
"quote",
-
"syn 2.0.103",
"wasm-bindgen-shared",
]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
···
]
[[package]]
name = "web-sys"
version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
name = "who-am-i"
version = "0.1.0"
dependencies = [
-
"atrium-api",
-
"atrium-common",
-
"atrium-identity",
-
"atrium-oauth",
"axum",
"axum-extra",
"axum-template",
···
"reqwest",
"serde",
"serde_json",
-
"thiserror 2.0.12",
"tokio",
"tokio-util",
"url",
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
dependencies = [
-
"windows-core 0.58.0",
"windows-targets 0.52.6",
]
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
dependencies = [
-
"windows-implement 0.58.0",
-
"windows-interface 0.58.0",
"windows-result 0.2.0",
"windows-strings 0.1.0",
"windows-targets 0.52.6",
]
[[package]]
-
name = "windows-core"
-
version = "0.61.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980"
-
dependencies = [
-
"windows-implement 0.60.0",
-
"windows-interface 0.59.1",
-
"windows-link",
-
"windows-result 0.3.4",
-
"windows-strings 0.4.2",
-
]
-
-
[[package]]
name = "windows-implement"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
-
]
-
-
[[package]]
-
name = "windows-implement"
-
version = "0.60.0"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836"
-
dependencies = [
-
"proc-macro2",
-
"quote",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
-
]
-
-
[[package]]
-
name = "windows-interface"
-
version = "0.59.1"
-
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"
-
dependencies = [
-
"proc-macro2",
-
"quote",
-
"syn 2.0.103",
]
[[package]]
···
[[package]]
name = "winnow"
-
version = "0.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
checksum = "74c7b26e3480b707944fc872477815d29a8e429d2f93a1ce000f5fa84a15cbcd"
dependencies = [
"memchr",
]
···
"nom",
"oid-registry",
"rusticata-macros",
-
"thiserror 2.0.12",
"time",
]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
"synstructure",
]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
"synstructure",
]
···
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
dependencies = [
"serde",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
-
"syn 2.0.103",
]
[[package]]
···
[[package]]
name = "anyhow"
+
version = "1.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
[[package]]
name = "arbitrary"
···
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
[[package]]
+
name = "arrayref"
+
version = "0.3.9"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
+
+
[[package]]
name = "arrayvec"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"proc-macro2",
"quote",
"serde",
+
"syn 2.0.106",
]
[[package]]
···
"nom",
"num-traits",
"rusticata-macros",
+
"thiserror 2.0.17",
"time",
]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
"synstructure",
]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46355d3245edc7b3160b2a45fe55d09a6963ebd3eee0252feb6b72fb0eb71463"
dependencies = [
+
"atrium-common 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+
"atrium-xrpc 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
+
"chrono",
+
"http",
+
"ipld-core",
+
"langtag",
+
"regex",
+
"serde",
+
"serde_bytes",
+
"serde_json",
+
"thiserror 1.0.69",
+
"tokio",
+
"trait-variant",
+
]
+
+
[[package]]
+
name = "atrium-api"
+
version = "0.25.4"
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
+
dependencies = [
+
"atrium-common 0.1.2 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
+
"atrium-xrpc 0.12.3 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
"chrono",
"http",
"ipld-core",
···
]
[[package]]
+
name = "atrium-common"
+
version = "0.1.2"
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
+
dependencies = [
+
"dashmap",
+
"lru",
+
"moka",
+
"thiserror 1.0.69",
+
"tokio",
+
"trait-variant",
+
"web-time",
+
]
+
+
[[package]]
+
name = "atrium-crypto"
+
version = "0.1.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "73a3da430c71dd9006d61072c20771f264e5c498420a49c32305ceab8bd71955"
+
dependencies = [
+
"ecdsa",
+
"k256",
+
"multibase",
+
"p256",
+
"thiserror 1.0.69",
+
]
+
+
[[package]]
name = "atrium-identity"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9e2d42bb4dbea038f4f5f45e3af2a89d61a9894a75f06aa550b74a60d2be380"
dependencies = [
+
"atrium-api 0.25.4 (registry+https://github.com/rust-lang/crates.io-index)",
+
"atrium-common 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+
"atrium-xrpc 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
+
"serde",
+
"serde_html_form",
+
"serde_json",
+
"thiserror 1.0.69",
+
"trait-variant",
+
]
+
+
[[package]]
+
name = "atrium-identity"
+
version = "0.1.5"
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
+
dependencies = [
+
"atrium-api 0.25.4 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
+
"atrium-common 0.1.2 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
+
"atrium-xrpc 0.12.3 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
"serde",
"serde_html_form",
"serde_json",
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca22dc4eaf77fd9bf050b21192ac58cd654a437d28e000ec114ebd93a51d36f5"
dependencies = [
+
"atrium-api 0.25.4 (registry+https://github.com/rust-lang/crates.io-index)",
+
"atrium-common 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+
"atrium-identity 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+
"atrium-xrpc 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
+
"base64 0.22.1",
+
"chrono",
+
"dashmap",
+
"ecdsa",
+
"elliptic-curve",
+
"jose-jwa",
+
"jose-jwk",
+
"p256",
+
"rand 0.8.5",
+
"reqwest",
+
"serde",
+
"serde_html_form",
+
"serde_json",
+
"sha2",
+
"thiserror 1.0.69",
+
"tokio",
+
"trait-variant",
+
]
+
+
[[package]]
+
name = "atrium-oauth"
+
version = "0.1.3"
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
+
dependencies = [
+
"atrium-api 0.25.4 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
+
"atrium-common 0.1.2 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
+
"atrium-identity 0.1.5 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
+
"atrium-xrpc 0.12.3 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
"base64 0.22.1",
"chrono",
"dashmap",
···
]
[[package]]
+
name = "atrium-xrpc"
+
version = "0.12.3"
+
source = "git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace#80a355991ac9b48ba3f559d12aac74f071fc638c"
+
dependencies = [
+
"http",
+
"serde",
+
"serde_html_form",
+
"serde_json",
+
"thiserror 1.0.69",
+
"trait-variant",
+
]
+
+
[[package]]
name = "auto_enums"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"derive_utils",
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
"axum-core",
"bytes",
"cookie",
+
"form_urlencoded",
"futures-util",
"headers",
"http",
···
"pin-project-lite",
"rustversion",
"serde",
+
"serde_html_form",
+
"serde_path_to_error",
"tower",
"tower-layer",
"tower-service",
···
"axum",
"handlebars",
"serde",
+
"thiserror 2.0.17",
]
[[package]]
···
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
[[package]]
+
name = "base256emoji"
+
version = "1.0.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b5e9430d9a245a77c92176e649af6e275f20839a48389859d1661e9a128d077c"
+
dependencies = [
+
"const-str",
+
"match-lookup",
+
]
+
+
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"regex",
"rustc-hash 1.1.0",
"shlex",
+
"syn 2.0.106",
"which",
]
···
"regex",
"rustc-hash 1.1.0",
"shlex",
+
"syn 2.0.106",
]
[[package]]
···
"regex",
"rustc-hash 2.1.1",
"shlex",
+
"syn 2.0.106",
+
]
+
+
[[package]]
+
name = "bitcoin-io"
+
version = "0.1.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf"
+
+
[[package]]
+
name = "bitcoin_hashes"
+
version = "0.14.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
+
dependencies = [
+
"bitcoin-io",
+
"hex-conservative",
]
[[package]]
···
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]]
+
name = "blake3"
+
version = "1.8.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0"
+
dependencies = [
+
"arrayref",
+
"arrayvec",
+
"cc",
+
"cfg-if",
+
"constant_time_eq",
+
]
+
+
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
+
name = "byteorder-lite"
+
version = "0.1.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
+
+
[[package]]
name = "bytes"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "6236364b88b9b6d0bc181ba374cf1ab55ba3ef97a1cb6f8cddad48a273767fb5"
[[package]]
+
name = "byteview"
+
version = "0.8.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "1e6b0e42e210b794e14b152c6fe1a55831e30ef4a0f5dc39d73d714fb5f1906c"
+
+
[[package]]
name = "bzip2-sys"
version = "0.1.13+1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "camino"
+
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609"
dependencies = [
+
"serde_core",
]
[[package]]
···
]
[[package]]
+
name = "cbor4ii"
+
version = "0.2.14"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b544cf8c89359205f4f990d0e6f3828db42df85b5dac95d09157a250eb0749c4"
+
dependencies = [
+
"serde",
+
]
+
+
[[package]]
+
name = "cbor4ii"
+
version = "1.2.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b28d2802395e3bccd95cc4ae984bff7444b6c1f5981da46a41360c42a2c7e2d9"
+
+
[[package]]
name = "cc"
version = "1.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
]
[[package]]
+
name = "ciborium"
+
version = "0.2.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
+
dependencies = [
+
"ciborium-io",
+
"ciborium-ll",
+
"serde",
+
]
+
+
[[package]]
+
name = "ciborium-io"
+
version = "0.2.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
+
+
[[package]]
+
name = "ciborium-ll"
+
version = "0.2.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
+
dependencies = [
+
"ciborium-io",
+
"half",
+
]
+
+
[[package]]
name = "cid"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"multihash",
"serde",
"serde_bytes",
+
"unsigned-varint 0.8.0",
]
[[package]]
···
[[package]]
name = "clap"
+
version = "4.5.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "e2134bb3ea021b78629caa971416385309e0131b351b25e01dc16fb54e1b5fae"
dependencies = [
"clap_builder",
"clap_derive",
···
[[package]]
name = "clap_builder"
+
version = "4.5.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "c2ba64afa3c0a6df7fa517765e31314e983f51dda798ffba27b988194fb65dc9"
dependencies = [
"anstream",
"anstyle",
···
[[package]]
name = "clap_derive"
+
version = "4.5.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "bbfd7eae0b0f1a6e63d4b13c9c478de77c2eb546fba158ad50b4203dc24b9f9c"
dependencies = [
"heck",
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
[[package]]
+
name = "const-str"
+
version = "0.4.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2f421161cb492475f1661ddc9815a745a1c894592070661180fdec3d4872e9c3"
+
+
[[package]]
+
name = "constant_time_eq"
+
version = "0.3.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
+
+
[[package]]
name = "constellation"
version = "0.1.0"
dependencies = [
···
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
+
name = "crunchy"
+
version = "0.2.4"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
+
+
[[package]]
name = "crypto-bigint"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"proc-macro2",
"quote",
"strsim 0.11.1",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"darling_core 0.20.11",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
]
[[package]]
+
name = "dasl"
+
version = "0.2.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b59666035a4386b0fd272bd78da4cbc3ccb558941e97579ab00f0eb4639f2a49"
+
dependencies = [
+
"blake3",
+
"cbor4ii 1.2.0",
+
"data-encoding",
+
"data-encoding-macro",
+
"scopeguard",
+
"serde",
+
"serde_bytes",
+
"sha2",
+
"thiserror 2.0.17",
+
]
+
+
[[package]]
name = "data-encoding"
+
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
[[package]]
name = "data-encoding-macro"
+
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "47ce6c96ea0102f01122a185683611bd5ac8d99e62bc59dd12e6bda344ee673d"
dependencies = [
"data-encoding",
"data-encoding-macro-internal",
···
[[package]]
name = "data-encoding-macro-internal"
+
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "8d162beedaa69905488a8da94f5ac3edb4dd4788b732fadb7bd120b2625c1976"
dependencies = [
"data-encoding",
+
"syn 2.0.106",
]
[[package]]
···
"darling 0.20.11",
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c"
dependencies = [
"derive_builder_core",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
"unicode-xid",
]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
[[package]]
name = "dropshot"
+
version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "eedf902e40c1024b8ed9ca16378a54e9655cdf0e698245ba82d81a3778dcbc54"
dependencies = [
"async-stream",
"async-trait",
···
"http-body-util",
"hyper",
"hyper-util",
+
"indexmap 2.11.4",
"multer",
"openapiv3",
"paste",
···
"slog-bunyan",
"slog-json",
"slog-term",
+
"thiserror 2.0.17",
"tokio",
"tokio-rustls 0.25.0",
+
"toml 0.9.7",
"uuid",
"version_check",
"waitgroup",
···
[[package]]
name = "dropshot_endpoint"
+
version = "0.16.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "89d09440e73a9dcf8a0f7fbd6ab889a7751d59f0fe76e5082a0a6d5623ec6da3"
dependencies = [
"heck",
"proc-macro2",
···
"semver",
"serde",
"serde_tokenstream",
+
"syn 2.0.106",
]
[[package]]
···
"heck",
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
"once_cell",
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
]
[[package]]
+
name = "fallible-iterator"
+
version = "0.3.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
+
+
[[package]]
+
name = "fallible-streaming-iterator"
+
version = "0.1.9"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
+
+
[[package]]
name = "fastrand"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "fjall"
+
version = "2.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0b25ad44cd4360a0448a9b5a0a6f1c7a621101cca4578706d43c9a821418aebc"
dependencies = [
"byteorder",
+
"byteview 0.6.1",
"dashmap",
"log",
+
"lsm-tree 2.10.4",
"path-absolutize",
"std-semaphore",
"tempfile",
···
]
[[package]]
+
name = "fjall"
+
version = "2.11.2"
+
source = "git+https://github.com/fjall-rs/fjall.git#42d811f7c8cc9004407d520d37d2a1d8d246c03d"
+
dependencies = [
+
"byteorder",
+
"byteview 0.6.1",
+
"dashmap",
+
"log",
+
"lsm-tree 2.10.4",
+
"path-absolutize",
+
"std-semaphore",
+
"tempfile",
+
"xxhash-rust",
+
]
+
+
[[package]]
+
name = "fjall"
+
version = "3.0.0-pre.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "467588c1f15d1cfa9e43f02a45cf55d82fa1f12a6ae961b848c520458525600c"
+
dependencies = [
+
"byteorder-lite",
+
"byteview 0.8.0",
+
"dashmap",
+
"log",
+
"lsm-tree 3.0.0-pre.0",
+
"std-semaphore",
+
"tempfile",
+
"xxhash-rust",
+
]
+
+
[[package]]
name = "flate2"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"mixtrics",
"pin-project",
"serde",
+
"thiserror 2.0.17",
"tokio",
"tracing",
]
···
"parking_lot",
"pin-project",
"serde",
+
"thiserror 2.0.17",
"tokio",
"twox-hash",
]
···
"parking_lot",
"pin-project",
"serde",
+
"thiserror 2.0.17",
"tokio",
"tracing",
]
···
"pin-project",
"rand 0.9.1",
"serde",
+
"thiserror 2.0.17",
"tokio",
"tracing",
"twox-hash",
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
"futures-core",
"futures-sink",
"http",
+
"indexmap 2.11.4",
"slab",
"tokio",
"tokio-util",
···
]
[[package]]
+
name = "half"
+
version = "2.6.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9"
+
dependencies = [
+
"cfg-if",
+
"crunchy",
+
]
+
+
[[package]]
name = "handlebars"
version = "6.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"pest_derive",
"serde",
"serde_json",
+
"thiserror 2.0.17",
"walkdir",
]
···
]
[[package]]
+
name = "hashlink"
+
version = "0.10.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
+
dependencies = [
+
"hashbrown 0.15.2",
+
]
+
+
[[package]]
name = "headers"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
+
name = "hex-conservative"
+
version = "0.2.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
+
dependencies = [
+
"arrayvec",
+
]
+
+
[[package]]
name = "hickory-proto"
version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"once_cell",
"rand 0.9.1",
"ring",
+
"thiserror 2.0.17",
"tinyvec",
"tokio",
"tracing",
···
"rand 0.9.1",
"resolv-conf",
"smallvec",
+
"thiserror 2.0.17",
"tokio",
"tracing",
]
···
"js-sys",
"log",
"wasm-bindgen",
+
"windows-core",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
[[package]]
name = "indexmap"
+
version = "2.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
dependencies = [
"equivalent",
"hashbrown 0.15.2",
"serde",
+
"serde_core",
]
[[package]]
···
]
[[package]]
+
name = "iroh-car"
+
version = "0.5.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "cb7f8cd4cb9aa083fba8b52e921764252d0b4dcb1cd6d120b809dbfe1106e81a"
+
dependencies = [
+
"anyhow",
+
"cid",
+
"futures",
+
"serde",
+
"serde_ipld_dagcbor",
+
"thiserror 1.0.69",
+
"tokio",
+
"unsigned-varint 0.7.2",
+
]
+
+
[[package]]
name = "is-terminal"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
dependencies = [
"anyhow",
"async-trait",
+
"atrium-api 0.25.4 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
"chrono",
"clap",
"futures-util",
···
"metrics",
"serde",
"serde_json",
+
"thiserror 2.0.17",
"tokio",
"tokio-tungstenite 0.26.2",
"url",
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
]
[[package]]
+
name = "jwt-compact"
+
version = "0.9.0-beta.1"
+
source = "git+https://github.com/fatfingers23/jwt-compact.git#aed088b8ff5ad44ef2785c453f6a4b7916728b1c"
+
dependencies = [
+
"anyhow",
+
"base64ct",
+
"chrono",
+
"ciborium",
+
"hmac",
+
"lazy_static",
+
"rand_core 0.6.4",
+
"secp256k1",
+
"serde",
+
"serde_json",
+
"sha2",
+
"smallvec",
+
"subtle",
+
"zeroize",
+
]
+
+
[[package]]
+
name = "k256"
+
version = "0.13.4"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b"
+
dependencies = [
+
"cfg-if",
+
"ecdsa",
+
"elliptic-curve",
+
"sha2",
+
]
+
+
[[package]]
name = "langtag"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
]
[[package]]
+
name = "libsqlite3-sys"
+
version = "0.35.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "133c182a6a2c87864fe97778797e46c7e999672690dc9fa3ee8e241aa4a9c13f"
+
dependencies = [
+
"pkg-config",
+
"vcpkg",
+
]
+
+
[[package]]
name = "libz-sys"
version = "1.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
version = "0.1.0"
dependencies = [
"anyhow",
+
"dasl",
"fluent-uri",
"nom",
+
"serde",
+
"thiserror 2.0.17",
"tinyjson",
]
···
[[package]]
name = "log"
+
version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
[[package]]
name = "loom"
···
[[package]]
name = "lsm-tree"
+
version = "2.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "799399117a2bfb37660e08be33f470958babb98386b04185288d829df362ea15"
dependencies = [
"byteorder",
"crossbeam-skiplist",
···
]
[[package]]
+
name = "lsm-tree"
+
version = "3.0.0-pre.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "be375d45e348328e78582dffbda4f1709dd52fca27c1a81c7bf6ca134e6335f7"
+
dependencies = [
+
"byteorder-lite",
+
"byteview 0.8.0",
+
"crossbeam-skiplist",
+
"enum_dispatch",
+
"interval-heap",
+
"log",
+
"lz4_flex",
+
"quick_cache",
+
"rustc-hash 2.1.1",
+
"self_cell",
+
"sfa",
+
"tempfile",
+
"varint-rs",
+
"xxhash-rust",
+
]
+
+
[[package]]
name = "lz4"
version = "1.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "lz4_flex"
+
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "08ab2867e3eeeca90e844d1940eab391c9dc5228783db2ed999acbc0a9ed375a"
[[package]]
name = "mach2"
···
"spin",
"tokio",
"tokio-util",
+
"toml 0.8.23",
"tracing",
"tracing-subscriber",
]
···
]
[[package]]
+
name = "match-lookup"
+
version = "0.1.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "1265724d8cb29dbbc2b0f06fffb8bf1a8c0cf73a78eede9ba73a4a66c52a981e"
+
dependencies = [
+
"proc-macro2",
+
"quote",
+
"syn 1.0.109",
+
]
+
+
[[package]]
name = "match_cfg"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "matchers"
+
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"
dependencies = [
+
"regex-automata",
]
[[package]]
···
"http-body-util",
"hyper",
"hyper-util",
+
"indexmap 2.11.4",
"ipnet",
"metrics",
"metrics-util 0.19.0",
···
"hyper",
"hyper-rustls",
"hyper-util",
+
"indexmap 2.11.4",
"ipnet",
"metrics",
"metrics-util 0.20.0",
"quanta",
+
"thiserror 2.0.17",
"tokio",
"tracing",
]
···
[[package]]
name = "multibase"
+
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "8694bb4835f452b0e3bb06dbebb1d6fc5385b6ca1caf2e55fd165c042390ec77"
dependencies = [
"base-x",
+
"base256emoji",
"data-encoding",
"data-encoding-macro",
]
···
dependencies = [
"core2",
"serde",
+
"unsigned-varint 0.8.0",
]
[[package]]
···
[[package]]
name = "nu-ansi-term"
+
version = "0.50.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399"
dependencies = [
+
"windows-sys 0.52.0",
]
[[package]]
···
[[package]]
name = "openapiv3"
+
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "5c8d427828b22ae1fff2833a03d8486c2c881367f1c336349f307f321e7f4d05"
dependencies = [
+
"indexmap 2.11.4",
"serde",
"serde_json",
]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
]
[[package]]
name = "p256"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323"
dependencies = [
"memchr",
+
"thiserror 2.0.17",
"ucd-trie",
]
···
"pest_meta",
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
[[package]]
+
name = "pocket"
+
version = "0.1.0"
+
dependencies = [
+
"atrium-crypto",
+
"clap",
+
"jwt-compact",
+
"log",
+
"poem",
+
"poem-openapi",
+
"reqwest",
+
"rusqlite",
+
"serde",
+
"serde_json",
+
"thiserror 2.0.17",
+
"tokio",
+
"tracing-subscriber",
+
]
+
+
[[package]]
name = "poem"
version = "3.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"headers",
"http",
"http-body-util",
+
"httpdate",
"hyper",
"hyper-util",
"mime",
+
"mime_guess",
"multer",
"nix",
"parking_lot",
···
"smallvec",
"sync_wrapper",
"tempfile",
+
"thiserror 2.0.17",
"tokio",
"tokio-rustls 0.26.2",
"tokio-stream",
···
"proc-macro-crate",
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
"bytes",
"derive_more",
"futures-util",
+
"indexmap 2.11.4",
"itertools 0.14.0",
"mime",
"num-traits",
···
"serde_json",
"serde_urlencoded",
"serde_yaml",
+
"thiserror 2.0.17",
"tokio",
]
···
dependencies = [
"darling 0.20.11",
"http",
+
"indexmap 2.11.4",
"mime",
"proc-macro-crate",
"proc-macro2",
"quote",
"regex",
+
"syn 2.0.106",
+
"thiserror 2.0.17",
]
[[package]]
···
checksum = "6837b9e10d61f45f987d50808f83d1ee3d206c66acf650c3e4ae2e1f6ddedf55"
dependencies = [
"proc-macro2",
+
"syn 2.0.106",
]
[[package]]
···
]
[[package]]
+
name = "quasar"
+
version = "0.1.0"
+
dependencies = [
+
"clap",
+
"fjall 2.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
+
]
+
+
[[package]]
name = "quick-xml"
version = "0.36.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "quick_cache"
+
version = "0.6.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "9ad6644cb07b7f3488b9f3d2fde3b4c0a7fa367cafefb39dff93a659f76eb786"
dependencies = [
"equivalent",
"hashbrown 0.15.2",
···
"rustc-hash 2.1.1",
"rustls 0.23.31",
"socket2 0.5.9",
+
"thiserror 2.0.17",
"tokio",
"tracing",
"web-time",
···
"rustls 0.23.31",
"rustls-pki-types",
"slab",
+
"thiserror 2.0.17",
"tinyvec",
"tracing",
"web-time",
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
+
]
+
+
[[package]]
+
name = "reflector"
+
version = "0.1.0"
+
dependencies = [
+
"clap",
+
"log",
+
"poem",
+
"serde",
+
"tokio",
+
"tracing-subscriber",
]
[[package]]
···
dependencies = [
"aho-corasick",
"memchr",
+
"regex-automata",
+
"regex-syntax",
]
[[package]]
···
dependencies = [
"aho-corasick",
"memchr",
+
"regex-syntax",
]
[[package]]
name = "regex-syntax"
+
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
+
name = "repo-stream"
+
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "093b48e604c138949bf3d4a1a9bc1165feb1db28a73af0101c84eb703d279f43"
+
dependencies = [
+
"bincode 2.0.1",
+
"futures",
+
"futures-core",
+
"ipld-core",
+
"iroh-car",
+
"log",
+
"multibase",
+
"rusqlite",
+
"serde",
+
"serde_bytes",
+
"serde_ipld_dagcbor",
+
"sha2",
+
"thiserror 2.0.17",
+
"tokio",
+
]
[[package]]
name = "reqwest"
+
version = "0.12.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f"
dependencies = [
"async-compression",
"base64 0.22.1",
···
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
+
"wasm-streams",
"web-sys",
]
···
"spki",
"subtle",
"zeroize",
+
]
+
+
[[package]]
+
name = "rusqlite"
+
version = "0.37.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "165ca6e57b20e1351573e3729b958bc62f0e48025386970b6e4d29e7a7e71f3f"
+
dependencies = [
+
"bitflags",
+
"fallible-iterator",
+
"fallible-streaming-iterator",
+
"hashlink",
+
"libsqlite3-sys",
+
"smallvec",
]
[[package]]
···
"proc-macro2",
"quote",
"serde_derive_internals",
+
"syn 2.0.106",
]
[[package]]
···
]
[[package]]
+
name = "secp256k1"
+
version = "0.30.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b50c5943d326858130af85e049f2661ba3c78b26589b8ab98e65e80ae44a1252"
+
dependencies = [
+
"bitcoin_hashes",
+
"rand 0.8.5",
+
"secp256k1-sys",
+
]
+
+
[[package]]
+
name = "secp256k1-sys"
+
version = "0.10.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9"
+
dependencies = [
+
"cc",
+
]
+
+
[[package]]
name = "security-framework"
version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
[[package]]
name = "self_cell"
+
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749"
[[package]]
name = "semver"
···
[[package]]
name = "serde"
+
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
+
"serde_core",
"serde_derive",
]
[[package]]
name = "serde_bytes"
+
version = "0.11.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
dependencies = [
"serde",
+
"serde_core",
+
]
+
+
[[package]]
+
name = "serde_core"
+
version = "1.0.228"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
+
dependencies = [
+
"serde_derive",
]
[[package]]
name = "serde_derive"
+
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
checksum = "9d2de91cf02bbc07cde38891769ccd5d4f073d22a40683aa4bc7a95781aaa2c4"
dependencies = [
"form_urlencoded",
+
"indexmap 2.11.4",
"itoa",
"ryu",
"serde",
]
[[package]]
+
name = "serde_ipld_dagcbor"
+
version = "0.6.4"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "46182f4f08349a02b45c998ba3215d3f9de826246ba02bb9dddfe9a2a2100778"
+
dependencies = [
+
"cbor4ii 0.2.14",
+
"ipld-core",
+
"scopeguard",
+
"serde",
+
]
+
+
[[package]]
name = "serde_json"
+
version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
+
"serde_core",
]
[[package]]
···
"percent-encoding",
"ryu",
"serde",
+
"thiserror 2.0.17",
]
[[package]]
···
]
[[package]]
+
name = "serde_spanned"
+
version = "1.0.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "5417783452c2be558477e104686f7de5dae53dba813c28435e0e70f82d9b04ee"
+
dependencies = [
+
"serde_core",
+
]
+
+
[[package]]
name = "serde_tokenstream"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
"proc-macro2",
"quote",
"serde",
+
"syn 2.0.106",
]
[[package]]
···
"chrono",
"hex",
"indexmap 1.9.3",
+
"indexmap 2.11.4",
"serde",
"serde_derive",
"serde_json",
···
"darling 0.20.11",
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
+
"indexmap 2.11.4",
"itoa",
"ryu",
"serde",
"unsafe-libyaml",
+
]
+
+
[[package]]
+
name = "sfa"
+
version = "0.0.1"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "e5f5f9dc21f55409f15103d5a7e7601b804935923c7fe4746dc806c3a422a038"
+
dependencies = [
+
"byteorder-lite",
+
"log",
+
"xxhash-rust",
]
[[package]]
···
dependencies = [
"num-bigint",
"num-traits",
+
"thiserror 2.0.17",
"time",
]
···
name = "slingshot"
version = "0.1.0"
dependencies = [
+
"atrium-api 0.25.4 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
+
"atrium-common 0.1.2 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
+
"atrium-identity 0.1.5 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
+
"atrium-oauth 0.1.3 (git+https://github.com/uniphil/atrium.git?branch=fix%2Fresolve-handle-https-accept-whitespace)",
"clap",
"ctrlc",
"foyer",
"hickory-resolver",
"jetstream",
+
"links",
"log",
"metrics",
"metrics-exporter-prometheus 0.17.2",
···
"rustls 0.23.31",
"serde",
"serde_json",
+
"thiserror 2.0.17",
"time",
"tokio",
"tokio-util",
···
name = "spacedust"
version = "0.1.0"
dependencies = [
+
"anyhow",
+
"async-channel",
"async-trait",
"clap",
"ctrlc",
+
"dasl",
"dropshot",
"env_logger",
+
"fjall 3.0.0-pre.0",
"futures",
"http",
+
"ipld-core",
"jetstream",
"links",
"log",
"metrics",
"metrics-exporter-prometheus 0.17.2",
"rand 0.9.1",
+
"repo-stream",
+
"reqwest",
"schemars",
"semver",
"serde",
+
"serde_ipld_dagcbor",
"serde_json",
"serde_qs",
+
"thiserror 2.0.17",
"tinyjson",
"tokio",
"tokio-tungstenite 0.27.0",
···
[[package]]
name = "syn"
+
version = "2.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
dependencies = [
"proc-macro2",
"quote",
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
[[package]]
name = "tempfile"
+
version = "3.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
dependencies = [
"fastrand",
"getrandom 0.3.3",
···
[[package]]
name = "thiserror"
+
version = "2.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
dependencies = [
+
"thiserror-impl 2.0.17",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
name = "thiserror-impl"
+
version = "2.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
[[package]]
name = "tokio"
+
version = "1.47.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
dependencies = [
"backtrace",
"bytes",
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
dependencies = [
"serde",
+
"serde_spanned 0.6.9",
+
"toml_datetime 0.6.11",
"toml_edit",
]
[[package]]
+
name = "toml"
+
version = "0.9.7"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "00e5e5d9bf2475ac9d4f0d9edab68cc573dc2fd644b0dba36b0c30a92dd9eaa0"
+
dependencies = [
+
"indexmap 2.11.4",
+
"serde_core",
+
"serde_spanned 1.0.2",
+
"toml_datetime 0.7.2",
+
"toml_parser",
+
"toml_writer",
+
"winnow",
+
]
+
+
[[package]]
name = "toml_datetime"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
]
[[package]]
+
name = "toml_datetime"
+
version = "0.7.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1"
+
dependencies = [
+
"serde_core",
+
]
+
+
[[package]]
name = "toml_edit"
version = "0.22.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
dependencies = [
+
"indexmap 2.11.4",
"serde",
+
"serde_spanned 0.6.9",
+
"toml_datetime 0.6.11",
"toml_write",
"winnow",
]
[[package]]
+
name = "toml_parser"
+
version = "1.0.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627"
+
dependencies = [
+
"winnow",
+
]
+
+
[[package]]
name = "toml_write"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
+
+
[[package]]
+
name = "toml_writer"
+
version = "1.0.3"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "d163a63c116ce562a22cda521fcc4d79152e7aba014456fb5eb442f6d6a10109"
[[package]]
name = "tower"
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
[[package]]
name = "tracing-subscriber"
+
version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
+
"regex-automata",
"sharded-slab",
"smallvec",
"thread_local",
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
"native-tls",
"rand 0.9.1",
"sha1",
+
"thiserror 2.0.17",
"url",
"utf-8",
]
···
"log",
"rand 0.9.1",
"sha1",
+
"thiserror 2.0.17",
"utf-8",
]
···
"clap",
"dropshot",
"env_logger",
+
"fjall 2.11.2 (git+https://github.com/fjall-rs/fjall.git)",
"getrandom 0.3.3",
"http",
"jetstream",
"log",
+
"lsm-tree 2.10.4",
"metrics",
"metrics-exporter-prometheus 0.17.2",
"schemars",
···
"serde_qs",
"sha2",
"tempfile",
+
"thiserror 2.0.17",
"tikv-jemallocator",
"tokio",
"tokio-util",
···
[[package]]
name = "unsigned-varint"
+
version = "0.7.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105"
+
+
[[package]]
+
name = "unsigned-varint"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06"
···
[[package]]
name = "uuid"
+
version = "1.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
dependencies = [
"getrandom 0.3.3",
+
"js-sys",
"serde",
+
"wasm-bindgen",
]
[[package]]
···
[[package]]
name = "value-log"
+
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "62fc7c4ce161f049607ecea654dca3f2d727da5371ae85e2e4f14ce2b98ed67c"
dependencies = [
"byteorder",
+
"byteview 0.6.1",
"interval-heap",
"log",
"path-absolutize",
···
"log",
"proc-macro2",
"quote",
+
"syn 2.0.106",
"wasm-bindgen-shared",
]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
···
]
[[package]]
+
name = "wasm-streams"
+
version = "0.4.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65"
+
dependencies = [
+
"futures-util",
+
"js-sys",
+
"wasm-bindgen",
+
"wasm-bindgen-futures",
+
"web-sys",
+
]
+
+
[[package]]
name = "web-sys"
version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
name = "who-am-i"
version = "0.1.0"
dependencies = [
+
"atrium-api 0.25.4 (registry+https://github.com/rust-lang/crates.io-index)",
+
"atrium-common 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+
"atrium-identity 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+
"atrium-oauth 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"axum",
"axum-extra",
"axum-template",
···
"reqwest",
"serde",
"serde_json",
+
"thiserror 2.0.17",
"tokio",
"tokio-util",
"url",
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
dependencies = [
+
"windows-core",
"windows-targets 0.52.6",
]
···
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
dependencies = [
+
"windows-implement",
+
"windows-interface",
"windows-result 0.2.0",
"windows-strings 0.1.0",
"windows-targets 0.52.6",
]
[[package]]
name = "windows-implement"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
[[package]]
name = "winnow"
+
version = "0.7.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf"
dependencies = [
"memchr",
]
···
"nom",
"oid-registry",
"rusticata-macros",
+
"thiserror 2.0.17",
"time",
]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
"synstructure",
]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
"synstructure",
]
···
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
dependencies = [
"serde",
+
"zeroize_derive",
+
]
+
+
[[package]]
+
name = "zeroize_derive"
+
version = "1.4.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
+
dependencies = [
+
"proc-macro2",
+
"quote",
+
"syn 2.0.106",
]
[[package]]
···
dependencies = [
"proc-macro2",
"quote",
+
"syn 2.0.106",
]
[[package]]
+3
Cargo.toml
···
"spacedust",
"who-am-i",
"slingshot",
]
···
"spacedust",
"who-am-i",
"slingshot",
+
"quasar",
+
"pocket",
+
"reflector",
]
+8 -1
Makefile
···
cargo test --all-features
fmt:
-
cargo fmt --package links --package constellation --package ufos --package spacedust --package who-am-i --package slingshot
cargo +nightly fmt --package jetstream
clippy:
···
cargo test --all-features
fmt:
+
cargo fmt --package links \
+
--package constellation \
+
--package ufos \
+
--package spacedust \
+
--package who-am-i \
+
--package slingshot \
+
--package pocket \
+
--package reflector
cargo +nightly fmt --package jetstream
clippy:
+1 -1
constellation/Cargo.toml
···
anyhow = "1.0.95"
askama = { version = "0.12.1", features = ["serde-json"] }
axum = "0.8.1"
-
axum-extra = { version = "0.10.0", features = ["typed-header"] }
axum-metrics = "0.2"
bincode = "1.3.3"
clap = { version = "4.5.26", features = ["derive"] }
···
anyhow = "1.0.95"
askama = { version = "0.12.1", features = ["serde-json"] }
axum = "0.8.1"
+
axum-extra = { version = "0.10.0", features = ["query", "typed-header"] }
axum-metrics = "0.2"
bincode = "1.3.3"
clap = { version = "4.5.26", features = ["derive"] }
+661
constellation/LICENSE
···
···
+
GNU AFFERO GENERAL PUBLIC LICENSE
+
Version 3, 19 November 2007
+
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+
Everyone is permitted to copy and distribute verbatim copies
+
of this license document, but changing it is not allowed.
+
+
Preamble
+
+
The GNU Affero General Public License is a free, copyleft license for
+
software and other kinds of works, specifically designed to ensure
+
cooperation with the community in the case of network server software.
+
+
The licenses for most software and other practical works are designed
+
to take away your freedom to share and change the works. By contrast,
+
our General Public Licenses are intended to guarantee your freedom to
+
share and change all versions of a program--to make sure it remains free
+
software for all its users.
+
+
When we speak of free software, we are referring to freedom, not
+
price. Our General Public Licenses are designed to make sure that you
+
have the freedom to distribute copies of free software (and charge for
+
them if you wish), that you receive source code or can get it if you
+
want it, that you can change the software or use pieces of it in new
+
free programs, and that you know you can do these things.
+
+
Developers that use our General Public Licenses protect your rights
+
with two steps: (1) assert copyright on the software, and (2) offer
+
you this License which gives you legal permission to copy, distribute
+
and/or modify the software.
+
+
A secondary benefit of defending all users' freedom is that
+
improvements made in alternate versions of the program, if they
+
receive widespread use, become available for other developers to
+
incorporate. Many developers of free software are heartened and
+
encouraged by the resulting cooperation. However, in the case of
+
software used on network servers, this result may fail to come about.
+
The GNU General Public License permits making a modified version and
+
letting the public access it on a server without ever releasing its
+
source code to the public.
+
+
The GNU Affero General Public License is designed specifically to
+
ensure that, in such cases, the modified source code becomes available
+
to the community. It requires the operator of a network server to
+
provide the source code of the modified version running there to the
+
users of that server. Therefore, public use of a modified version, on
+
a publicly accessible server, gives the public access to the source
+
code of the modified version.
+
+
An older license, called the Affero General Public License and
+
published by Affero, was designed to accomplish similar goals. This is
+
a different license, not a version of the Affero GPL, but Affero has
+
released a new version of the Affero GPL which permits relicensing under
+
this license.
+
+
The precise terms and conditions for copying, distribution and
+
modification follow.
+
+
TERMS AND CONDITIONS
+
+
0. Definitions.
+
+
"This License" refers to version 3 of the GNU Affero General Public License.
+
+
"Copyright" also means copyright-like laws that apply to other kinds of
+
works, such as semiconductor masks.
+
+
"The Program" refers to any copyrightable work licensed under this
+
License. Each licensee is addressed as "you". "Licensees" and
+
"recipients" may be individuals or organizations.
+
+
To "modify" a work means to copy from or adapt all or part of the work
+
in a fashion requiring copyright permission, other than the making of an
+
exact copy. The resulting work is called a "modified version" of the
+
earlier work or a work "based on" the earlier work.
+
+
A "covered work" means either the unmodified Program or a work based
+
on the Program.
+
+
To "propagate" a work means to do anything with it that, without
+
permission, would make you directly or secondarily liable for
+
infringement under applicable copyright law, except executing it on a
+
computer or modifying a private copy. Propagation includes copying,
+
distribution (with or without modification), making available to the
+
public, and in some countries other activities as well.
+
+
To "convey" a work means any kind of propagation that enables other
+
parties to make or receive copies. Mere interaction with a user through
+
a computer network, with no transfer of a copy, is not conveying.
+
+
An interactive user interface displays "Appropriate Legal Notices"
+
to the extent that it includes a convenient and prominently visible
+
feature that (1) displays an appropriate copyright notice, and (2)
+
tells the user that there is no warranty for the work (except to the
+
extent that warranties are provided), that licensees may convey the
+
work under this License, and how to view a copy of this License. If
+
the interface presents a list of user commands or options, such as a
+
menu, a prominent item in the list meets this criterion.
+
+
1. Source Code.
+
+
The "source code" for a work means the preferred form of the work
+
for making modifications to it. "Object code" means any non-source
+
form of a work.
+
+
A "Standard Interface" means an interface that either is an official
+
standard defined by a recognized standards body, or, in the case of
+
interfaces specified for a particular programming language, one that
+
is widely used among developers working in that language.
+
+
The "System Libraries" of an executable work include anything, other
+
than the work as a whole, that (a) is included in the normal form of
+
packaging a Major Component, but which is not part of that Major
+
Component, and (b) serves only to enable use of the work with that
+
Major Component, or to implement a Standard Interface for which an
+
implementation is available to the public in source code form. A
+
"Major Component", in this context, means a major essential component
+
(kernel, window system, and so on) of the specific operating system
+
(if any) on which the executable work runs, or a compiler used to
+
produce the work, or an object code interpreter used to run it.
+
+
The "Corresponding Source" for a work in object code form means all
+
the source code needed to generate, install, and (for an executable
+
work) run the object code and to modify the work, including scripts to
+
control those activities. However, it does not include the work's
+
System Libraries, or general-purpose tools or generally available free
+
programs which are used unmodified in performing those activities but
+
which are not part of the work. For example, Corresponding Source
+
includes interface definition files associated with source files for
+
the work, and the source code for shared libraries and dynamically
+
linked subprograms that the work is specifically designed to require,
+
such as by intimate data communication or control flow between those
+
subprograms and other parts of the work.
+
+
The Corresponding Source need not include anything that users
+
can regenerate automatically from other parts of the Corresponding
+
Source.
+
+
The Corresponding Source for a work in source code form is that
+
same work.
+
+
2. Basic Permissions.
+
+
All rights granted under this License are granted for the term of
+
copyright on the Program, and are irrevocable provided the stated
+
conditions are met. This License explicitly affirms your unlimited
+
permission to run the unmodified Program. The output from running a
+
covered work is covered by this License only if the output, given its
+
content, constitutes a covered work. This License acknowledges your
+
rights of fair use or other equivalent, as provided by copyright law.
+
+
You may make, run and propagate covered works that you do not
+
convey, without conditions so long as your license otherwise remains
+
in force. You may convey covered works to others for the sole purpose
+
of having them make modifications exclusively for you, or provide you
+
with facilities for running those works, provided that you comply with
+
the terms of this License in conveying all material for which you do
+
not control copyright. Those thus making or running the covered works
+
for you must do so exclusively on your behalf, under your direction
+
and control, on terms that prohibit them from making any copies of
+
your copyrighted material outside their relationship with you.
+
+
Conveying under any other circumstances is permitted solely under
+
the conditions stated below. Sublicensing is not allowed; section 10
+
makes it unnecessary.
+
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+
No covered work shall be deemed part of an effective technological
+
measure under any applicable law fulfilling obligations under article
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
+
similar laws prohibiting or restricting circumvention of such
+
measures.
+
+
When you convey a covered work, you waive any legal power to forbid
+
circumvention of technological measures to the extent such circumvention
+
is effected by exercising rights under this License with respect to
+
the covered work, and you disclaim any intention to limit operation or
+
modification of the work as a means of enforcing, against the work's
+
users, your or third parties' legal rights to forbid circumvention of
+
technological measures.
+
+
4. Conveying Verbatim Copies.
+
+
You may convey verbatim copies of the Program's source code as you
+
receive it, in any medium, provided that you conspicuously and
+
appropriately publish on each copy an appropriate copyright notice;
+
keep intact all notices stating that this License and any
+
non-permissive terms added in accord with section 7 apply to the code;
+
keep intact all notices of the absence of any warranty; and give all
+
recipients a copy of this License along with the Program.
+
+
You may charge any price or no price for each copy that you convey,
+
and you may offer support or warranty protection for a fee.
+
+
5. Conveying Modified Source Versions.
+
+
You may convey a work based on the Program, or the modifications to
+
produce it from the Program, in the form of source code under the
+
terms of section 4, provided that you also meet all of these conditions:
+
+
a) The work must carry prominent notices stating that you modified
+
it, and giving a relevant date.
+
+
b) The work must carry prominent notices stating that it is
+
released under this License and any conditions added under section
+
7. This requirement modifies the requirement in section 4 to
+
"keep intact all notices".
+
+
c) You must license the entire work, as a whole, under this
+
License to anyone who comes into possession of a copy. This
+
License will therefore apply, along with any applicable section 7
+
additional terms, to the whole of the work, and all its parts,
+
regardless of how they are packaged. This License gives no
+
permission to license the work in any other way, but it does not
+
invalidate such permission if you have separately received it.
+
+
d) If the work has interactive user interfaces, each must display
+
Appropriate Legal Notices; however, if the Program has interactive
+
interfaces that do not display Appropriate Legal Notices, your
+
work need not make them do so.
+
+
A compilation of a covered work with other separate and independent
+
works, which are not by their nature extensions of the covered work,
+
and which are not combined with it such as to form a larger program,
+
in or on a volume of a storage or distribution medium, is called an
+
"aggregate" if the compilation and its resulting copyright are not
+
used to limit the access or legal rights of the compilation's users
+
beyond what the individual works permit. Inclusion of a covered work
+
in an aggregate does not cause this License to apply to the other
+
parts of the aggregate.
+
+
6. Conveying Non-Source Forms.
+
+
You may convey a covered work in object code form under the terms
+
of sections 4 and 5, provided that you also convey the
+
machine-readable Corresponding Source under the terms of this License,
+
in one of these ways:
+
+
a) Convey the object code in, or embodied in, a physical product
+
(including a physical distribution medium), accompanied by the
+
Corresponding Source fixed on a durable physical medium
+
customarily used for software interchange.
+
+
b) Convey the object code in, or embodied in, a physical product
+
(including a physical distribution medium), accompanied by a
+
written offer, valid for at least three years and valid for as
+
long as you offer spare parts or customer support for that product
+
model, to give anyone who possesses the object code either (1) a
+
copy of the Corresponding Source for all the software in the
+
product that is covered by this License, on a durable physical
+
medium customarily used for software interchange, for a price no
+
more than your reasonable cost of physically performing this
+
conveying of source, or (2) access to copy the
+
Corresponding Source from a network server at no charge.
+
+
c) Convey individual copies of the object code with a copy of the
+
written offer to provide the Corresponding Source. This
+
alternative is allowed only occasionally and noncommercially, and
+
only if you received the object code with such an offer, in accord
+
with subsection 6b.
+
+
d) Convey the object code by offering access from a designated
+
place (gratis or for a charge), and offer equivalent access to the
+
Corresponding Source in the same way through the same place at no
+
further charge. You need not require recipients to copy the
+
Corresponding Source along with the object code. If the place to
+
copy the object code is a network server, the Corresponding Source
+
may be on a different server (operated by you or a third party)
+
that supports equivalent copying facilities, provided you maintain
+
clear directions next to the object code saying where to find the
+
Corresponding Source. Regardless of what server hosts the
+
Corresponding Source, you remain obligated to ensure that it is
+
available for as long as needed to satisfy these requirements.
+
+
e) Convey the object code using peer-to-peer transmission, provided
+
you inform other peers where the object code and Corresponding
+
Source of the work are being offered to the general public at no
+
charge under subsection 6d.
+
+
A separable portion of the object code, whose source code is excluded
+
from the Corresponding Source as a System Library, need not be
+
included in conveying the object code work.
+
+
A "User Product" is either (1) a "consumer product", which means any
+
tangible personal property which is normally used for personal, family,
+
or household purposes, or (2) anything designed or sold for incorporation
+
into a dwelling. In determining whether a product is a consumer product,
+
doubtful cases shall be resolved in favor of coverage. For a particular
+
product received by a particular user, "normally used" refers to a
+
typical or common use of that class of product, regardless of the status
+
of the particular user or of the way in which the particular user
+
actually uses, or expects or is expected to use, the product. A product
+
is a consumer product regardless of whether the product has substantial
+
commercial, industrial or non-consumer uses, unless such uses represent
+
the only significant mode of use of the product.
+
+
"Installation Information" for a User Product means any methods,
+
procedures, authorization keys, or other information required to install
+
and execute modified versions of a covered work in that User Product from
+
a modified version of its Corresponding Source. The information must
+
suffice to ensure that the continued functioning of the modified object
+
code is in no case prevented or interfered with solely because
+
modification has been made.
+
+
If you convey an object code work under this section in, or with, or
+
specifically for use in, a User Product, and the conveying occurs as
+
part of a transaction in which the right of possession and use of the
+
User Product is transferred to the recipient in perpetuity or for a
+
fixed term (regardless of how the transaction is characterized), the
+
Corresponding Source conveyed under this section must be accompanied
+
by the Installation Information. But this requirement does not apply
+
if neither you nor any third party retains the ability to install
+
modified object code on the User Product (for example, the work has
+
been installed in ROM).
+
+
The requirement to provide Installation Information does not include a
+
requirement to continue to provide support service, warranty, or updates
+
for a work that has been modified or installed by the recipient, or for
+
the User Product in which it has been modified or installed. Access to a
+
network may be denied when the modification itself materially and
+
adversely affects the operation of the network or violates the rules and
+
protocols for communication across the network.
+
+
Corresponding Source conveyed, and Installation Information provided,
+
in accord with this section must be in a format that is publicly
+
documented (and with an implementation available to the public in
+
source code form), and must require no special password or key for
+
unpacking, reading or copying.
+
+
7. Additional Terms.
+
+
"Additional permissions" are terms that supplement the terms of this
+
License by making exceptions from one or more of its conditions.
+
Additional permissions that are applicable to the entire Program shall
+
be treated as though they were included in this License, to the extent
+
that they are valid under applicable law. If additional permissions
+
apply only to part of the Program, that part may be used separately
+
under those permissions, but the entire Program remains governed by
+
this License without regard to the additional permissions.
+
+
When you convey a copy of a covered work, you may at your option
+
remove any additional permissions from that copy, or from any part of
+
it. (Additional permissions may be written to require their own
+
removal in certain cases when you modify the work.) You may place
+
additional permissions on material, added by you to a covered work,
+
for which you have or can give appropriate copyright permission.
+
+
Notwithstanding any other provision of this License, for material you
+
add to a covered work, you may (if authorized by the copyright holders of
+
that material) supplement the terms of this License with terms:
+
+
a) Disclaiming warranty or limiting liability differently from the
+
terms of sections 15 and 16 of this License; or
+
+
b) Requiring preservation of specified reasonable legal notices or
+
author attributions in that material or in the Appropriate Legal
+
Notices displayed by works containing it; or
+
+
c) Prohibiting misrepresentation of the origin of that material, or
+
requiring that modified versions of such material be marked in
+
reasonable ways as different from the original version; or
+
+
d) Limiting the use for publicity purposes of names of licensors or
+
authors of the material; or
+
+
e) Declining to grant rights under trademark law for use of some
+
trade names, trademarks, or service marks; or
+
+
f) Requiring indemnification of licensors and authors of that
+
material by anyone who conveys the material (or modified versions of
+
it) with contractual assumptions of liability to the recipient, for
+
any liability that these contractual assumptions directly impose on
+
those licensors and authors.
+
+
All other non-permissive additional terms are considered "further
+
restrictions" within the meaning of section 10. If the Program as you
+
received it, or any part of it, contains a notice stating that it is
+
governed by this License along with a term that is a further
+
restriction, you may remove that term. If a license document contains
+
a further restriction but permits relicensing or conveying under this
+
License, you may add to a covered work material governed by the terms
+
of that license document, provided that the further restriction does
+
not survive such relicensing or conveying.
+
+
If you add terms to a covered work in accord with this section, you
+
must place, in the relevant source files, a statement of the
+
additional terms that apply to those files, or a notice indicating
+
where to find the applicable terms.
+
+
Additional terms, permissive or non-permissive, may be stated in the
+
form of a separately written license, or stated as exceptions;
+
the above requirements apply either way.
+
+
8. Termination.
+
+
You may not propagate or modify a covered work except as expressly
+
provided under this License. Any attempt otherwise to propagate or
+
modify it is void, and will automatically terminate your rights under
+
this License (including any patent licenses granted under the third
+
paragraph of section 11).
+
+
However, if you cease all violation of this License, then your
+
license from a particular copyright holder is reinstated (a)
+
provisionally, unless and until the copyright holder explicitly and
+
finally terminates your license, and (b) permanently, if the copyright
+
holder fails to notify you of the violation by some reasonable means
+
prior to 60 days after the cessation.
+
+
Moreover, your license from a particular copyright holder is
+
reinstated permanently if the copyright holder notifies you of the
+
violation by some reasonable means, this is the first time you have
+
received notice of violation of this License (for any work) from that
+
copyright holder, and you cure the violation prior to 30 days after
+
your receipt of the notice.
+
+
Termination of your rights under this section does not terminate the
+
licenses of parties who have received copies or rights from you under
+
this License. If your rights have been terminated and not permanently
+
reinstated, you do not qualify to receive new licenses for the same
+
material under section 10.
+
+
9. Acceptance Not Required for Having Copies.
+
+
You are not required to accept this License in order to receive or
+
run a copy of the Program. Ancillary propagation of a covered work
+
occurring solely as a consequence of using peer-to-peer transmission
+
to receive a copy likewise does not require acceptance. However,
+
nothing other than this License grants you permission to propagate or
+
modify any covered work. These actions infringe copyright if you do
+
not accept this License. Therefore, by modifying or propagating a
+
covered work, you indicate your acceptance of this License to do so.
+
+
10. Automatic Licensing of Downstream Recipients.
+
+
Each time you convey a covered work, the recipient automatically
+
receives a license from the original licensors, to run, modify and
+
propagate that work, subject to this License. You are not responsible
+
for enforcing compliance by third parties with this License.
+
+
An "entity transaction" is a transaction transferring control of an
+
organization, or substantially all assets of one, or subdividing an
+
organization, or merging organizations. If propagation of a covered
+
work results from an entity transaction, each party to that
+
transaction who receives a copy of the work also receives whatever
+
licenses to the work the party's predecessor in interest had or could
+
give under the previous paragraph, plus a right to possession of the
+
Corresponding Source of the work from the predecessor in interest, if
+
the predecessor has it or can get it with reasonable efforts.
+
+
You may not impose any further restrictions on the exercise of the
+
rights granted or affirmed under this License. For example, you may
+
not impose a license fee, royalty, or other charge for exercise of
+
rights granted under this License, and you may not initiate litigation
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
+
any patent claim is infringed by making, using, selling, offering for
+
sale, or importing the Program or any portion of it.
+
+
11. Patents.
+
+
A "contributor" is a copyright holder who authorizes use under this
+
License of the Program or a work on which the Program is based. The
+
work thus licensed is called the contributor's "contributor version".
+
+
A contributor's "essential patent claims" are all patent claims
+
owned or controlled by the contributor, whether already acquired or
+
hereafter acquired, that would be infringed by some manner, permitted
+
by this License, of making, using, or selling its contributor version,
+
but do not include claims that would be infringed only as a
+
consequence of further modification of the contributor version. For
+
purposes of this definition, "control" includes the right to grant
+
patent sublicenses in a manner consistent with the requirements of
+
this License.
+
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
+
patent license under the contributor's essential patent claims, to
+
make, use, sell, offer for sale, import and otherwise run, modify and
+
propagate the contents of its contributor version.
+
+
In the following three paragraphs, a "patent license" is any express
+
agreement or commitment, however denominated, not to enforce a patent
+
(such as an express permission to practice a patent or covenant not to
+
sue for patent infringement). To "grant" such a patent license to a
+
party means to make such an agreement or commitment not to enforce a
+
patent against the party.
+
+
If you convey a covered work, knowingly relying on a patent license,
+
and the Corresponding Source of the work is not available for anyone
+
to copy, free of charge and under the terms of this License, through a
+
publicly available network server or other readily accessible means,
+
then you must either (1) cause the Corresponding Source to be so
+
available, or (2) arrange to deprive yourself of the benefit of the
+
patent license for this particular work, or (3) arrange, in a manner
+
consistent with the requirements of this License, to extend the patent
+
license to downstream recipients. "Knowingly relying" means you have
+
actual knowledge that, but for the patent license, your conveying the
+
covered work in a country, or your recipient's use of the covered work
+
in a country, would infringe one or more identifiable patents in that
+
country that you have reason to believe are valid.
+
+
If, pursuant to or in connection with a single transaction or
+
arrangement, you convey, or propagate by procuring conveyance of, a
+
covered work, and grant a patent license to some of the parties
+
receiving the covered work authorizing them to use, propagate, modify
+
or convey a specific copy of the covered work, then the patent license
+
you grant is automatically extended to all recipients of the covered
+
work and works based on it.
+
+
A patent license is "discriminatory" if it does not include within
+
the scope of its coverage, prohibits the exercise of, or is
+
conditioned on the non-exercise of one or more of the rights that are
+
specifically granted under this License. You may not convey a covered
+
work if you are a party to an arrangement with a third party that is
+
in the business of distributing software, under which you make payment
+
to the third party based on the extent of your activity of conveying
+
the work, and under which the third party grants, to any of the
+
parties who would receive the covered work from you, a discriminatory
+
patent license (a) in connection with copies of the covered work
+
conveyed by you (or copies made from those copies), or (b) primarily
+
for and in connection with specific products or compilations that
+
contain the covered work, unless you entered into that arrangement,
+
or that patent license was granted, prior to 28 March 2007.
+
+
Nothing in this License shall be construed as excluding or limiting
+
any implied license or other defenses to infringement that may
+
otherwise be available to you under applicable patent law.
+
+
12. No Surrender of Others' Freedom.
+
+
If conditions are imposed on you (whether by court order, agreement or
+
otherwise) that contradict the conditions of this License, they do not
+
excuse you from the conditions of this License. If you cannot convey a
+
covered work so as to satisfy simultaneously your obligations under this
+
License and any other pertinent obligations, then as a consequence you may
+
not convey it at all. For example, if you agree to terms that obligate you
+
to collect a royalty for further conveying from those to whom you convey
+
the Program, the only way you could satisfy both those terms and this
+
License would be to refrain entirely from conveying the Program.
+
+
13. Remote Network Interaction; Use with the GNU General Public License.
+
+
Notwithstanding any other provision of this License, if you modify the
+
Program, your modified version must prominently offer all users
+
interacting with it remotely through a computer network (if your version
+
supports such interaction) an opportunity to receive the Corresponding
+
Source of your version by providing access to the Corresponding Source
+
from a network server at no charge, through some standard or customary
+
means of facilitating copying of software. This Corresponding Source
+
shall include the Corresponding Source for any work covered by version 3
+
of the GNU General Public License that is incorporated pursuant to the
+
following paragraph.
+
+
Notwithstanding any other provision of this License, you have
+
permission to link or combine any covered work with a work licensed
+
under version 3 of the GNU General Public License into a single
+
combined work, and to convey the resulting work. The terms of this
+
License will continue to apply to the part which is the covered work,
+
but the work with which it is combined will remain governed by version
+
3 of the GNU General Public License.
+
+
14. Revised Versions of this License.
+
+
The Free Software Foundation may publish revised and/or new versions of
+
the GNU Affero General Public License from time to time. Such new versions
+
will be similar in spirit to the present version, but may differ in detail to
+
address new problems or concerns.
+
+
Each version is given a distinguishing version number. If the
+
Program specifies that a certain numbered version of the GNU Affero General
+
Public License "or any later version" applies to it, you have the
+
option of following the terms and conditions either of that numbered
+
version or of any later version published by the Free Software
+
Foundation. If the Program does not specify a version number of the
+
GNU Affero General Public License, you may choose any version ever published
+
by the Free Software Foundation.
+
+
If the Program specifies that a proxy can decide which future
+
versions of the GNU Affero General Public License can be used, that proxy's
+
public statement of acceptance of a version permanently authorizes you
+
to choose that version for the Program.
+
+
Later license versions may give you additional or different
+
permissions. However, no additional obligations are imposed on any
+
author or copyright holder as a result of your choosing to follow a
+
later version.
+
+
15. Disclaimer of Warranty.
+
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+
16. Limitation of Liability.
+
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+
SUCH DAMAGES.
+
+
17. Interpretation of Sections 15 and 16.
+
+
If the disclaimer of warranty and limitation of liability provided
+
above cannot be given local legal effect according to their terms,
+
reviewing courts shall apply local law that most closely approximates
+
an absolute waiver of all civil liability in connection with the
+
Program, unless a warranty or assumption of liability accompanies a
+
copy of the Program in return for a fee.
+
+
END OF TERMS AND CONDITIONS
+
+
How to Apply These Terms to Your New Programs
+
+
If you develop a new program, and you want it to be of the greatest
+
possible use to the public, the best way to achieve this is to make it
+
free software which everyone can redistribute and change under these terms.
+
+
To do so, attach the following notices to the program. It is safest
+
to attach them to the start of each source file to most effectively
+
state the exclusion of warranty; and each file should have at least
+
the "copyright" line and a pointer to where the full notice is found.
+
+
<one line to give the program's name and a brief idea of what it does.>
+
Copyright (C) <year> <name of author>
+
+
This program is free software: you can redistribute it and/or modify
+
it under the terms of the GNU Affero General Public License as published
+
by the Free Software Foundation, either version 3 of the License, or
+
(at your option) any later version.
+
+
This program is distributed in the hope that it will be useful,
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+
GNU Affero General Public License for more details.
+
+
You should have received a copy of the GNU Affero General Public License
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+
Also add information on how to contact you by electronic and paper mail.
+
+
If your software can interact with users remotely through a computer
+
network, you should also make sure that it provides a way for users to
+
get its source. For example, if your program is a web application, its
+
interface could display a "Source" link that leads users to an archive
+
of the code. There are many ways you could offer source, and different
+
solutions will be better for different programs; see section 13 for the
+
specific requirements.
+
+
You should also get your employer (if you work as a programmer) or school,
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
+
For more information on this, and how to apply and follow the GNU AGPL, see
+
<https://www.gnu.org/licenses/>.
+3
constellation/LICENSE.future
···
···
+
constellation's source code is currently only available under the AGPL license.
+
+
it MAY be relicensed in the future to MIT and/or Apache 2.0, at the sole discretion of the microcosm organization, but is not available under these licenses today.
+9
constellation/readme.md
···
```
some todos
- [x] find links and write them to rocksdb
···
```
+
## Contributions
+
+
### Licensing
+
+
Constellation's source code is currently available exclusively under the AGPL license (see [LICENSE](./LICENSE)).
+
+
In the future, its code MAY become available under the MIT and/or Apache2.0 licenses, at the sole discretion of the microcosm organization. Contributing implies acceptance with this possible future licensing change. The change has not happed yet and is not guaranteed.
+
+
some todos
- [x] find links and write them to rocksdb
+57 -14
constellation/src/bin/main.rs
···
use anyhow::{bail, Result};
use clap::{Parser, ValueEnum};
use metrics_exporter_prometheus::PrometheusBuilder;
use std::num::NonZero;
use std::path::PathBuf;
use std::sync::{atomic::AtomicU32, Arc};
···
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
-
#[arg(short, long)]
/// Jetstream server to connect to (exclusive with --fixture). Provide either a wss:// URL, or a shorhand value:
/// 'us-east-1', 'us-east-2', 'us-west-1', or 'us-west-2'
#[arg(short, long)]
···
/// Saved jsonl from jetstream to use instead of a live subscription
#[arg(short, long)]
fixture: Option<PathBuf>,
}
#[derive(Debug, Clone, ValueEnum)]
···
let stream = jetstream_url(&args.jetstream);
println!("using jetstream server {stream:?}...",);
let stay_alive = CancellationToken::new();
match args.backend {
-
StorageBackend::Memory => run(MemStorage::new(), fixture, None, stream, stay_alive),
#[cfg(feature = "rocks")]
StorageBackend::Rocks => {
let storage_dir = args.data.clone().unwrap_or("rocks.test".into());
···
rocks.start_backup(backup_dir, auto_backup, stay_alive.clone())?;
}
println!("rocks ready.");
-
run(rocks, fixture, args.data, stream, stay_alive)
}
}
}
···
fixture: Option<PathBuf>,
data_dir: Option<PathBuf>,
stream: String,
stay_alive: CancellationToken,
) -> Result<()> {
ctrlc::set_handler({
···
.build()
.expect("axum startup")
.block_on(async {
-
install_metrics_server()?;
-
serve(readable, "0.0.0.0:6789", staying_alive).await
})
.unwrap();
stay_alive.drop_guard();
···
'monitor: loop {
match readable.get_stats() {
-
Ok(StorageStats { dids, targetables, linking_records }) => {
metrics::gauge!("storage.stats.dids").set(dids as f64);
metrics::gauge!("storage.stats.targetables").set(targetables as f64);
metrics::gauge!("storage.stats.linking_records").set(linking_records as f64);
···
Ok(())
}
-
fn install_metrics_server() -> Result<()> {
println!("installing metrics server...");
-
let host = [0, 0, 0, 0];
-
let port = 8765;
PrometheusBuilder::new()
.set_quantiles(&[0.5, 0.9, 0.99, 1.0])?
.set_bucket_duration(time::Duration::from_secs(30))?
.set_bucket_count(NonZero::new(10).unwrap()) // count * duration = 5 mins. stuff doesn't happen that fast here.
.set_enable_unit_suffix(true)
-
.with_http_listener((host, port))
.install()?;
-
println!(
-
"metrics server installed! listening on http://{}.{}.{}.{}:{port}",
-
host[0], host[1], host[2], host[3]
-
);
Ok(())
}
···
use anyhow::{bail, Result};
use clap::{Parser, ValueEnum};
use metrics_exporter_prometheus::PrometheusBuilder;
+
use std::net::SocketAddr;
use std::num::NonZero;
use std::path::PathBuf;
use std::sync::{atomic::AtomicU32, Arc};
···
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
+
/// constellation server's listen address
+
#[arg(long)]
+
#[clap(default_value = "0.0.0.0:6789")]
+
bind: SocketAddr,
+
/// metrics server's listen address
+
#[arg(long)]
+
#[clap(default_value = "0.0.0.0:8765")]
+
bind_metrics: SocketAddr,
/// Jetstream server to connect to (exclusive with --fixture). Provide either a wss:// URL, or a shorhand value:
/// 'us-east-1', 'us-east-2', 'us-west-1', or 'us-west-2'
#[arg(short, long)]
···
/// Saved jsonl from jetstream to use instead of a live subscription
#[arg(short, long)]
fixture: Option<PathBuf>,
+
/// run a scan across the target id table and write all key -> ids to id -> keys
+
#[arg(long, action)]
+
repair_target_ids: bool,
}
#[derive(Debug, Clone, ValueEnum)]
···
let stream = jetstream_url(&args.jetstream);
println!("using jetstream server {stream:?}...",);
+
let bind = args.bind;
+
let metrics_bind = args.bind_metrics;
+
let stay_alive = CancellationToken::new();
match args.backend {
+
StorageBackend::Memory => run(
+
MemStorage::new(),
+
fixture,
+
None,
+
stream,
+
bind,
+
metrics_bind,
+
stay_alive,
+
),
#[cfg(feature = "rocks")]
StorageBackend::Rocks => {
let storage_dir = args.data.clone().unwrap_or("rocks.test".into());
···
rocks.start_backup(backup_dir, auto_backup, stay_alive.clone())?;
}
println!("rocks ready.");
+
std::thread::scope(|s| {
+
if args.repair_target_ids {
+
let rocks = rocks.clone();
+
let stay_alive = stay_alive.clone();
+
s.spawn(move || {
+
let rep = rocks.run_repair(time::Duration::from_millis(0), stay_alive);
+
eprintln!("repair finished: {rep:?}");
+
rep
+
});
+
}
+
s.spawn(|| {
+
let r = run(
+
rocks,
+
fixture,
+
args.data,
+
stream,
+
bind,
+
metrics_bind,
+
stay_alive,
+
);
+
eprintln!("run finished: {r:?}");
+
r
+
});
+
});
+
Ok(())
}
}
}
···
fixture: Option<PathBuf>,
data_dir: Option<PathBuf>,
stream: String,
+
bind: SocketAddr,
+
metrics_bind: SocketAddr,
stay_alive: CancellationToken,
) -> Result<()> {
ctrlc::set_handler({
···
.build()
.expect("axum startup")
.block_on(async {
+
install_metrics_server(metrics_bind)?;
+
serve(readable, bind, staying_alive).await
})
.unwrap();
stay_alive.drop_guard();
···
'monitor: loop {
match readable.get_stats() {
+
Ok(StorageStats { dids, targetables, linking_records, .. }) => {
metrics::gauge!("storage.stats.dids").set(dids as f64);
metrics::gauge!("storage.stats.targetables").set(targetables as f64);
metrics::gauge!("storage.stats.linking_records").set(linking_records as f64);
···
Ok(())
}
+
fn install_metrics_server(metrics_bind: SocketAddr) -> Result<()> {
println!("installing metrics server...");
PrometheusBuilder::new()
.set_quantiles(&[0.5, 0.9, 0.99, 1.0])?
.set_bucket_duration(time::Duration::from_secs(30))?
.set_bucket_count(NonZero::new(10).unwrap()) // count * duration = 5 mins. stuff doesn't happen that fast here.
.set_enable_unit_suffix(true)
+
.with_http_listener(metrics_bind)
.install()?;
+
println!("metrics server installed! listening at {metrics_bind:?}");
Ok(())
}
+2
constellation/src/bin/rocks-restore-from-backup.rs
···
use clap::Parser;
use std::path::PathBuf;
use rocksdb::backup::{BackupEngine, BackupEngineOptions, RestoreOptions};
use std::time;
···
to_data_dir: PathBuf,
}
fn main() -> Result<()> {
let args = Args::parse();
···
use clap::Parser;
use std::path::PathBuf;
+
#[cfg(feature = "rocks")]
use rocksdb::backup::{BackupEngine, BackupEngineOptions, RestoreOptions};
use std::time;
···
to_data_dir: PathBuf,
}
+
#[cfg(feature = "rocks")]
fn main() -> Result<()> {
let args = Args::parse();
+8 -6
constellation/src/server/filters.rs
···
Ok({
if let Some(link) = parse_any_link(s) {
match link {
-
Link::AtUri(at_uri) => at_uri.strip_prefix("at://").map(|noproto| {
-
format!("https://atproto-browser-plus-links.vercel.app/at/{noproto}")
-
}),
-
Link::Did(did) => Some(format!(
-
"https://atproto-browser-plus-links.vercel.app/at/{did}"
-
)),
Link::Uri(uri) => Some(uri),
}
} else {
···
pub fn human_number(n: &u64) -> askama::Result<String> {
Ok(n.to_formatted_string(&Locale::en))
}
···
Ok({
if let Some(link) = parse_any_link(s) {
match link {
+
Link::AtUri(at_uri) => at_uri
+
.strip_prefix("at://")
+
.map(|noproto| format!("https://pdsls.dev/at://{noproto}")),
+
Link::Did(did) => Some(format!("https://pdsls.dev/at://{did}")),
Link::Uri(uri) => Some(uri),
}
} else {
···
pub fn human_number(n: &u64) -> askama::Result<String> {
Ok(n.to_formatted_string(&Locale::en))
}
+
+
pub fn to_u64(n: usize) -> askama::Result<u64> {
+
Ok(n as u64)
+
}
+332 -19
constellation/src/server/mod.rs
···
use bincode::Options;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
-
use std::collections::HashMap;
use std::time::{Duration, UNIX_EPOCH};
use tokio::net::{TcpListener, ToSocketAddrs};
-
use tokio::task::block_in_place;
use tokio_util::sync::CancellationToken;
use crate::storage::{LinkReader, StorageStats};
···
const DEFAULT_CURSOR_LIMIT: u64 = 16;
const DEFAULT_CURSOR_LIMIT_MAX: u64 = 100;
-
const INDEX_BEGAN_AT_TS: u64 = 1738083600; // TODO: not this
pub async fn serve<S, A>(store: S, addr: A, stay_alive: CancellationToken) -> anyhow::Result<()>
where
···
"/",
get({
let store = store.clone();
-
move |accept| async { block_in_place(|| hello(accept, store)) }
}),
)
.route(
"/links/count",
get({
let store = store.clone();
-
move |accept, query| async { block_in_place(|| count_links(accept, query, store)) }
}),
)
.route(
···
get({
let store = store.clone();
move |accept, query| async {
-
block_in_place(|| count_distinct_dids(accept, query, store))
}
}),
)
···
"/links",
get({
let store = store.clone();
-
move |accept, query| async { block_in_place(|| get_links(accept, query, store)) }
}),
)
.route(
···
get({
let store = store.clone();
move |accept, query| async {
-
block_in_place(|| get_distinct_dids(accept, query, store))
}
}),
)
···
get({
let store = store.clone();
move |accept, query| async {
-
block_in_place(|| count_all_links(accept, query, store))
}
}),
)
···
get({
let store = store.clone();
move |accept, query| async {
-
block_in_place(|| explore_links(accept, query, store))
}
}),
)
···
#[template(path = "hello.html.j2")]
struct HelloReponse {
help: &'static str,
-
days_indexed: u64,
stats: StorageStats,
}
fn hello(
···
let stats = store
.get_stats()
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
-
let days_indexed = (UNIX_EPOCH + Duration::from_secs(INDEX_BEGAN_AT_TS))
-
.elapsed()
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?
-
.as_secs()
-
/ 86400;
Ok(acceptable(accept, HelloReponse {
help: "open this URL in a web browser (or request with Accept: text/html) for information about this API.",
days_indexed,
···
}
#[derive(Clone, Deserialize)]
struct GetLinksCountQuery {
target: String,
collection: String,
···
}
#[derive(Clone, Deserialize)]
struct GetLinkItemsQuery {
target: String,
collection: String,
path: String,
cursor: Option<OpaqueApiCursor>,
-
limit: Option<u64>,
// TODO: allow reverse (er, forward) order as well
}
#[derive(Template, Serialize)]
···
}
fn get_links(
accept: ExtractAccept,
-
query: Query<GetLinkItemsQuery>,
store: impl LinkReader,
) -> Result<impl IntoResponse, http::StatusCode> {
let until = query
···
.transpose()?
.map(|c| c.next);
-
let limit = query.limit.unwrap_or(DEFAULT_CURSOR_LIMIT);
if limit > DEFAULT_CURSOR_LIMIT_MAX {
return Err(http::StatusCode::BAD_REQUEST);
}
let paged = store
-
.get_links(&query.target, &query.collection, &query.path, limit, until)
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
let cursor = paged.next.map(|next| {
···
OpaqueApiCursor(bincode::DefaultOptions::new().serialize(&item).unwrap())
}
}
···
use bincode::Options;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
+
use std::collections::{HashMap, HashSet};
use std::time::{Duration, UNIX_EPOCH};
use tokio::net::{TcpListener, ToSocketAddrs};
+
use tokio::task::spawn_blocking;
use tokio_util::sync::CancellationToken;
use crate::storage::{LinkReader, StorageStats};
···
const DEFAULT_CURSOR_LIMIT: u64 = 16;
const DEFAULT_CURSOR_LIMIT_MAX: u64 = 100;
+
fn get_default_cursor_limit() -> u64 {
+
DEFAULT_CURSOR_LIMIT
+
}
+
+
fn to500(e: tokio::task::JoinError) -> http::StatusCode {
+
eprintln!("handler error: {e}");
+
http::StatusCode::INTERNAL_SERVER_ERROR
+
}
pub async fn serve<S, A>(store: S, addr: A, stay_alive: CancellationToken) -> anyhow::Result<()>
where
···
"/",
get({
let store = store.clone();
+
move |accept| async {
+
spawn_blocking(|| hello(accept, store))
+
.await
+
.map_err(to500)?
+
}
+
}),
+
)
+
.route(
+
"/xrpc/blue.microcosm.links.getManyToManyCounts",
+
get({
+
let store = store.clone();
+
move |accept, query| async {
+
spawn_blocking(|| get_many_to_many_counts(accept, query, store))
+
.await
+
.map_err(to500)?
+
}
}),
)
.route(
"/links/count",
get({
let store = store.clone();
+
move |accept, query| async {
+
spawn_blocking(|| count_links(accept, query, store))
+
.await
+
.map_err(to500)?
+
}
}),
)
.route(
···
get({
let store = store.clone();
move |accept, query| async {
+
spawn_blocking(|| count_distinct_dids(accept, query, store))
+
.await
+
.map_err(to500)?
+
}
+
}),
+
)
+
.route(
+
"/xrpc/blue.microcosm.links.getBacklinks",
+
get({
+
let store = store.clone();
+
move |accept, query| async {
+
spawn_blocking(|| get_backlinks(accept, query, store))
+
.await
+
.map_err(to500)?
}
}),
)
···
"/links",
get({
let store = store.clone();
+
move |accept, query| async {
+
spawn_blocking(|| get_links(accept, query, store))
+
.await
+
.map_err(to500)?
+
}
}),
)
.route(
···
get({
let store = store.clone();
move |accept, query| async {
+
spawn_blocking(|| get_distinct_dids(accept, query, store))
+
.await
+
.map_err(to500)?
}
}),
)
···
get({
let store = store.clone();
move |accept, query| async {
+
spawn_blocking(|| count_all_links(accept, query, store))
+
.await
+
.map_err(to500)?
}
}),
)
···
get({
let store = store.clone();
move |accept, query| async {
+
spawn_blocking(|| explore_links(accept, query, store))
+
.await
+
.map_err(to500)?
}
}),
)
···
#[template(path = "hello.html.j2")]
struct HelloReponse {
help: &'static str,
+
days_indexed: Option<u64>,
stats: StorageStats,
}
fn hello(
···
let stats = store
.get_stats()
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
+
let days_indexed = stats
+
.started_at
+
.map(|c| (UNIX_EPOCH + Duration::from_micros(c)).elapsed())
+
.transpose()
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?
+
.map(|d| d.as_secs() / 86_400);
Ok(acceptable(accept, HelloReponse {
help: "open this URL in a web browser (or request with Accept: text/html) for information about this API.",
days_indexed,
···
}
#[derive(Clone, Deserialize)]
+
#[serde(rename_all = "camelCase")]
+
struct GetManyToManyCountsQuery {
+
subject: String,
+
source: String,
+
/// path to the secondary link in the linking record
+
path_to_other: String,
+
/// filter to linking records (join of the m2m) by these DIDs
+
#[serde(default)]
+
did: Vec<String>,
+
/// filter to specific secondary records
+
#[serde(default)]
+
other_subject: Vec<String>,
+
cursor: Option<OpaqueApiCursor>,
+
/// Set the max number of links to return per page of results
+
#[serde(default = "get_default_cursor_limit")]
+
limit: u64,
+
}
+
#[derive(Serialize)]
+
struct OtherSubjectCount {
+
subject: String,
+
total: u64,
+
distinct: u64,
+
}
+
#[derive(Template, Serialize)]
+
#[template(path = "get-many-to-many-counts.html.j2")]
+
struct GetManyToManyCountsResponse {
+
counts_by_other_subject: Vec<OtherSubjectCount>,
+
cursor: Option<OpaqueApiCursor>,
+
#[serde(skip_serializing)]
+
query: GetManyToManyCountsQuery,
+
}
+
fn get_many_to_many_counts(
+
accept: ExtractAccept,
+
query: axum_extra::extract::Query<GetManyToManyCountsQuery>,
+
store: impl LinkReader,
+
) -> Result<impl IntoResponse, http::StatusCode> {
+
let cursor_key = query
+
.cursor
+
.clone()
+
.map(|oc| ApiKeyedCursor::try_from(oc).map_err(|_| http::StatusCode::BAD_REQUEST))
+
.transpose()?
+
.map(|c| c.next);
+
+
let limit = query.limit;
+
if limit > DEFAULT_CURSOR_LIMIT_MAX {
+
return Err(http::StatusCode::BAD_REQUEST);
+
}
+
+
let filter_dids: HashSet<Did> = HashSet::from_iter(
+
query
+
.did
+
.iter()
+
.map(|d| d.trim())
+
.filter(|d| !d.is_empty())
+
.map(|d| Did(d.to_string())),
+
);
+
+
let filter_other_subjects: HashSet<String> = HashSet::from_iter(
+
query
+
.other_subject
+
.iter()
+
.map(|s| s.trim().to_string())
+
.filter(|s| !s.is_empty()),
+
);
+
+
let Some((collection, path)) = query.source.split_once(':') else {
+
return Err(http::StatusCode::BAD_REQUEST);
+
};
+
let path = format!(".{path}");
+
+
let path_to_other = format!(".{}", query.path_to_other);
+
+
let paged = store
+
.get_many_to_many_counts(
+
&query.subject,
+
collection,
+
&path,
+
&path_to_other,
+
limit,
+
cursor_key,
+
&filter_dids,
+
&filter_other_subjects,
+
)
+
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
+
+
let cursor = paged.next.map(|next| ApiKeyedCursor { next }.into());
+
+
let items = paged
+
.items
+
.into_iter()
+
.map(|(subject, total, distinct)| OtherSubjectCount {
+
subject,
+
total,
+
distinct,
+
})
+
.collect();
+
+
Ok(acceptable(
+
accept,
+
GetManyToManyCountsResponse {
+
counts_by_other_subject: items,
+
cursor,
+
query: (*query).clone(),
+
},
+
))
+
}
+
+
#[derive(Clone, Deserialize)]
struct GetLinksCountQuery {
target: String,
collection: String,
···
}
#[derive(Clone, Deserialize)]
+
struct GetBacklinksQuery {
+
/// The link target
+
///
+
/// can be an AT-URI, plain DID, or regular URI
+
subject: String,
+
/// Filter links only from this link source
+
///
+
/// eg.: `app.bsky.feed.like:subject.uri`
+
source: String,
+
cursor: Option<OpaqueApiCursor>,
+
/// Filter links only from these DIDs
+
///
+
/// include multiple times to filter by multiple source DIDs
+
#[serde(default)]
+
did: Vec<String>,
+
/// Set the max number of links to return per page of results
+
#[serde(default = "get_default_cursor_limit")]
+
limit: u64,
+
// TODO: allow reverse (er, forward) order as well
+
}
+
#[derive(Template, Serialize)]
+
#[template(path = "get-backlinks.html.j2")]
+
struct GetBacklinksResponse {
+
total: u64,
+
records: Vec<RecordId>,
+
cursor: Option<OpaqueApiCursor>,
+
#[serde(skip_serializing)]
+
query: GetBacklinksQuery,
+
#[serde(skip_serializing)]
+
collection: String,
+
#[serde(skip_serializing)]
+
path: String,
+
}
+
fn get_backlinks(
+
accept: ExtractAccept,
+
query: axum_extra::extract::Query<GetBacklinksQuery>, // supports multiple param occurrences
+
store: impl LinkReader,
+
) -> Result<impl IntoResponse, http::StatusCode> {
+
let until = query
+
.cursor
+
.clone()
+
.map(|oc| ApiCursor::try_from(oc).map_err(|_| http::StatusCode::BAD_REQUEST))
+
.transpose()?
+
.map(|c| c.next);
+
+
let limit = query.limit;
+
if limit > DEFAULT_CURSOR_LIMIT_MAX {
+
return Err(http::StatusCode::BAD_REQUEST);
+
}
+
+
let filter_dids: HashSet<Did> = HashSet::from_iter(
+
query
+
.did
+
.iter()
+
.map(|d| d.trim())
+
.filter(|d| !d.is_empty())
+
.map(|d| Did(d.to_string())),
+
);
+
+
let Some((collection, path)) = query.source.split_once(':') else {
+
return Err(http::StatusCode::BAD_REQUEST);
+
};
+
let path = format!(".{path}");
+
+
let paged = store
+
.get_links(
+
&query.subject,
+
collection,
+
&path,
+
limit,
+
until,
+
&filter_dids,
+
)
+
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
+
+
let cursor = paged.next.map(|next| {
+
ApiCursor {
+
version: paged.version,
+
next,
+
}
+
.into()
+
});
+
+
Ok(acceptable(
+
accept,
+
GetBacklinksResponse {
+
total: paged.total,
+
records: paged.items,
+
cursor,
+
query: (*query).clone(),
+
collection: collection.to_string(),
+
path,
+
},
+
))
+
}
+
+
#[derive(Clone, Deserialize)]
struct GetLinkItemsQuery {
target: String,
collection: String,
path: String,
cursor: Option<OpaqueApiCursor>,
+
/// Filter links only from these DIDs
+
///
+
/// include multiple times to filter by multiple source DIDs
+
#[serde(default)]
+
did: Vec<String>,
+
/// [deprecated] Filter links only from these DIDs
+
///
+
/// format: comma-separated sequence of DIDs
+
///
+
/// errors: if `did` parameter is also present
+
///
+
/// deprecated: use `did`, which can be repeated multiple times
+
from_dids: Option<String>, // comma separated: gross
+
#[serde(default = "get_default_cursor_limit")]
+
limit: u64,
// TODO: allow reverse (er, forward) order as well
}
#[derive(Template, Serialize)]
···
}
fn get_links(
accept: ExtractAccept,
+
query: axum_extra::extract::Query<GetLinkItemsQuery>, // supports multiple param occurrences
store: impl LinkReader,
) -> Result<impl IntoResponse, http::StatusCode> {
let until = query
···
.transpose()?
.map(|c| c.next);
+
let limit = query.limit;
if limit > DEFAULT_CURSOR_LIMIT_MAX {
return Err(http::StatusCode::BAD_REQUEST);
}
+
let mut filter_dids: HashSet<Did> = HashSet::from_iter(
+
query
+
.did
+
.iter()
+
.map(|d| d.trim())
+
.filter(|d| !d.is_empty())
+
.map(|d| Did(d.to_string())),
+
);
+
+
if let Some(comma_joined) = &query.from_dids {
+
if !filter_dids.is_empty() {
+
return Err(http::StatusCode::BAD_REQUEST);
+
}
+
for did in comma_joined.split(',') {
+
filter_dids.insert(Did(did.to_string()));
+
}
+
}
+
let paged = store
+
.get_links(
+
&query.target,
+
&query.collection,
+
&query.path,
+
limit,
+
until,
+
&filter_dids,
+
)
.map_err(|_| http::StatusCode::INTERNAL_SERVER_ERROR)?;
let cursor = paged.next.map(|next| {
···
OpaqueApiCursor(bincode::DefaultOptions::new().serialize(&item).unwrap())
}
}
+
+
#[derive(Serialize, Deserialize)] // for bincode
+
struct ApiKeyedCursor {
+
next: String, // the key
+
}
+
+
impl TryFrom<OpaqueApiCursor> for ApiKeyedCursor {
+
type Error = bincode::Error;
+
+
fn try_from(item: OpaqueApiCursor) -> Result<Self, Self::Error> {
+
bincode::DefaultOptions::new().deserialize(&item.0)
+
}
+
}
+
+
impl From<ApiKeyedCursor> for OpaqueApiCursor {
+
fn from(item: ApiKeyedCursor) -> Self {
+
OpaqueApiCursor(bincode::DefaultOptions::new().serialize(&item).unwrap())
+
}
+
}
+93 -1
constellation/src/storage/mem_store.rs
···
-
use super::{LinkReader, LinkStorage, PagedAppendingCollection, StorageStats};
use crate::{ActionableEvent, CountsByCount, Did, RecordId};
use anyhow::Result;
use links::CollectedLink;
···
}
impl LinkReader for MemStorage {
fn get_count(&self, target: &str, collection: &str, path: &str) -> Result<u64> {
let data = self.0.lock().unwrap();
let Some(paths) = data.targets.get(&Target::new(target)) else {
···
path: &str,
limit: u64,
until: Option<u64>,
) -> Result<PagedAppendingCollection<RecordId>> {
let data = self.0.lock().unwrap();
let Some(paths) = data.targets.get(&Target::new(target)) else {
···
next: None,
total: 0,
});
};
let total = did_rkeys.len();
···
dids,
targetables,
linking_records,
})
}
}
···
+
use super::{
+
LinkReader, LinkStorage, PagedAppendingCollection, PagedOrderedCollection, StorageStats,
+
};
use crate::{ActionableEvent, CountsByCount, Did, RecordId};
use anyhow::Result;
use links::CollectedLink;
···
}
impl LinkReader for MemStorage {
+
fn get_many_to_many_counts(
+
&self,
+
target: &str,
+
collection: &str,
+
path: &str,
+
path_to_other: &str,
+
limit: u64,
+
after: Option<String>,
+
filter_dids: &HashSet<Did>,
+
filter_to_targets: &HashSet<String>,
+
) -> Result<PagedOrderedCollection<(String, u64, u64), String>> {
+
let data = self.0.lock().unwrap();
+
let Some(paths) = data.targets.get(&Target::new(target)) else {
+
return Ok(PagedOrderedCollection::default());
+
};
+
let Some(linkers) = paths.get(&Source::new(collection, path)) else {
+
return Ok(PagedOrderedCollection::default());
+
};
+
+
let path_to_other = RecordPath::new(path_to_other);
+
let filter_to_targets: HashSet<Target> =
+
HashSet::from_iter(filter_to_targets.iter().map(|s| Target::new(s)));
+
+
let mut grouped_counts: HashMap<Target, (u64, HashSet<Did>)> = HashMap::new();
+
for (did, rkey) in linkers.iter().flatten().cloned() {
+
if !filter_dids.is_empty() && !filter_dids.contains(&did) {
+
continue;
+
}
+
if let Some(fwd_target) = data
+
.links
+
.get(&did)
+
.unwrap_or(&HashMap::new())
+
.get(&RepoId {
+
collection: collection.to_string(),
+
rkey,
+
})
+
.unwrap_or(&Vec::new())
+
.iter()
+
.filter_map(|(path, target)| {
+
if *path == path_to_other
+
&& (filter_to_targets.is_empty() || filter_to_targets.contains(target))
+
{
+
Some(target)
+
} else {
+
None
+
}
+
})
+
.take(1)
+
.next()
+
{
+
let e = grouped_counts.entry(fwd_target.clone()).or_default();
+
e.0 += 1;
+
e.1.insert(did.clone());
+
}
+
}
+
let mut items: Vec<(String, u64, u64)> = grouped_counts
+
.iter()
+
.map(|(k, (n, u))| (k.0.clone(), *n, u.len() as u64))
+
.collect();
+
items.sort();
+
items = items
+
.into_iter()
+
.skip_while(|(t, _, _)| after.as_ref().map(|a| t <= a).unwrap_or(false))
+
.take(limit as usize)
+
.collect();
+
let next = if items.len() as u64 >= limit {
+
items.last().map(|(t, _, _)| t.clone())
+
} else {
+
None
+
};
+
Ok(PagedOrderedCollection { items, next })
+
}
+
fn get_count(&self, target: &str, collection: &str, path: &str) -> Result<u64> {
let data = self.0.lock().unwrap();
let Some(paths) = data.targets.get(&Target::new(target)) else {
···
path: &str,
limit: u64,
until: Option<u64>,
+
filter_dids: &HashSet<Did>,
) -> Result<PagedAppendingCollection<RecordId>> {
let data = self.0.lock().unwrap();
let Some(paths) = data.targets.get(&Target::new(target)) else {
···
next: None,
total: 0,
});
+
};
+
+
let did_rkeys: Vec<_> = if !filter_dids.is_empty() {
+
did_rkeys
+
.iter()
+
.filter(|m| {
+
Option::<(Did, RKey)>::clone(m)
+
.map(|(did, _)| filter_dids.contains(&did))
+
.unwrap_or(false)
+
})
+
.cloned()
+
.collect()
+
} else {
+
did_rkeys.to_vec()
};
let total = did_rkeys.len();
···
dids,
targetables,
linking_records,
+
started_at: None,
+
other_data: Default::default(),
})
}
}
+484 -14
constellation/src/storage/mod.rs
···
use crate::{ActionableEvent, CountsByCount, Did, RecordId};
use anyhow::Result;
use serde::{Deserialize, Serialize};
-
use std::collections::HashMap;
pub mod mem_store;
pub use mem_store::MemStorage;
···
pub total: u64,
}
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct StorageStats {
/// estimate of how many accounts we've seen create links. the _subjects_ of any links are not represented here.
···
/// records with multiple links are single-counted.
/// for LSM stores, deleted links don't decrement this, and updated records with any links will likely increment it.
pub linking_records: u64,
}
pub trait LinkStorage: Send + Sync {
···
}
pub trait LinkReader: Clone + Send + Sync + 'static {
fn get_count(&self, target: &str, collection: &str, path: &str) -> Result<u64>;
fn get_distinct_did_count(&self, target: &str, collection: &str, path: &str) -> Result<u64>;
···
path: &str,
limit: u64,
until: Option<u64>,
) -> Result<PagedAppendingCollection<RecordId>>;
fn get_distinct_dids(
···
);
assert_eq!(storage.get_distinct_did_count("", "", "")?, 0);
assert_eq!(
-
storage.get_links("a.com", "app.t.c", ".abc.uri", 100, None)?,
PagedAppendingCollection {
version: (0, 0),
items: vec![],
···
0,
)?;
assert_eq!(
-
storage.get_links("a.com", "app.t.c", ".abc.uri", 100, None)?,
PagedAppendingCollection {
version: (1, 0),
items: vec![RecordId {
···
0,
)?;
}
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
let dids = storage.get_distinct_dids("a.com", "app.t.c", ".abc.uri", 2, None)?;
assert_eq!(
links,
···
total: 5,
}
);
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
let dids = storage.get_distinct_dids("a.com", "app.t.c", ".abc.uri", 2, dids.next)?;
assert_eq!(
links,
···
total: 5,
}
);
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
let dids = storage.get_distinct_dids("a.com", "app.t.c", ".abc.uri", 2, dids.next)?;
assert_eq!(
links,
···
assert_stats(storage.get_stats()?, 5..=5, 1..=1, 5..=5);
});
test_each_storage!(get_links_exact_multiple, |storage| {
for i in 1..=4 {
storage.push(
···
0,
)?;
}
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
assert_eq!(
links,
PagedAppendingCollection {
···
total: 4,
}
);
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
assert_eq!(
links,
PagedAppendingCollection {
···
0,
)?;
}
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
assert_eq!(
links,
PagedAppendingCollection {
···
},
0,
)?;
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
assert_eq!(
links,
PagedAppendingCollection {
···
0,
)?;
}
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
assert_eq!(
links,
PagedAppendingCollection {
···
}),
0,
)?;
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
assert_eq!(
links,
PagedAppendingCollection {
···
0,
)?;
}
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None)?;
assert_eq!(
links,
PagedAppendingCollection {
···
&ActionableEvent::DeactivateAccount("did:plc:asdf-1".into()),
0,
)?;
-
let links = storage.get_links("a.com", "app.t.c", ".abc.uri", 2, links.next)?;
assert_eq!(
links,
PagedAppendingCollection {
···
counts
});
assert_stats(storage.get_stats()?, 1..=1, 2..=2, 1..=1);
});
}
···
use crate::{ActionableEvent, CountsByCount, Did, RecordId};
use anyhow::Result;
use serde::{Deserialize, Serialize};
+
use std::collections::{HashMap, HashSet};
pub mod mem_store;
pub use mem_store::MemStorage;
···
pub total: u64,
}
+
/// A paged collection whose keys are sorted instead of indexed
+
///
+
/// this has weaker guarantees than PagedAppendingCollection: it might
+
/// return a totally consistent snapshot. but it should avoid duplicates
+
/// and each page should at least be internally consistent.
+
#[derive(Debug, PartialEq, Default)]
+
pub struct PagedOrderedCollection<T, K: Ord> {
+
pub items: Vec<T>,
+
pub next: Option<K>,
+
}
+
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct StorageStats {
/// estimate of how many accounts we've seen create links. the _subjects_ of any links are not represented here.
···
/// records with multiple links are single-counted.
/// for LSM stores, deleted links don't decrement this, and updated records with any links will likely increment it.
pub linking_records: u64,
+
+
/// first jetstream cursor when this instance first started
+
pub started_at: Option<u64>,
+
+
/// anything else we want to throw in
+
pub other_data: HashMap<String, u64>,
}
pub trait LinkStorage: Send + Sync {
···
}
pub trait LinkReader: Clone + Send + Sync + 'static {
+
#[allow(clippy::too_many_arguments)]
+
fn get_many_to_many_counts(
+
&self,
+
target: &str,
+
collection: &str,
+
path: &str,
+
path_to_other: &str,
+
limit: u64,
+
after: Option<String>,
+
filter_dids: &HashSet<Did>,
+
filter_to_targets: &HashSet<String>,
+
) -> Result<PagedOrderedCollection<(String, u64, u64), String>>;
+
fn get_count(&self, target: &str, collection: &str, path: &str) -> Result<u64>;
fn get_distinct_did_count(&self, target: &str, collection: &str, path: &str) -> Result<u64>;
···
path: &str,
limit: u64,
until: Option<u64>,
+
filter_dids: &HashSet<Did>,
) -> Result<PagedAppendingCollection<RecordId>>;
fn get_distinct_dids(
···
);
assert_eq!(storage.get_distinct_did_count("", "", "")?, 0);
assert_eq!(
+
storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
100,
+
None,
+
&HashSet::default()
+
)?,
PagedAppendingCollection {
version: (0, 0),
items: vec![],
···
0,
)?;
assert_eq!(
+
storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
100,
+
None,
+
&HashSet::default()
+
)?,
PagedAppendingCollection {
version: (1, 0),
items: vec![RecordId {
···
0,
)?;
}
+
let links =
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
let dids = storage.get_distinct_dids("a.com", "app.t.c", ".abc.uri", 2, None)?;
assert_eq!(
links,
···
total: 5,
}
);
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
links.next,
+
&HashSet::default(),
+
)?;
let dids = storage.get_distinct_dids("a.com", "app.t.c", ".abc.uri", 2, dids.next)?;
assert_eq!(
links,
···
total: 5,
}
);
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
links.next,
+
&HashSet::default(),
+
)?;
let dids = storage.get_distinct_dids("a.com", "app.t.c", ".abc.uri", 2, dids.next)?;
assert_eq!(
links,
···
assert_stats(storage.get_stats()?, 5..=5, 1..=1, 5..=5);
});
+
test_each_storage!(get_filtered_links, |storage| {
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
None,
+
&HashSet::from([Did("did:plc:linker".to_string())]),
+
)?;
+
assert_eq!(
+
links,
+
PagedAppendingCollection {
+
version: (0, 0),
+
items: vec![],
+
next: None,
+
total: 0,
+
}
+
);
+
+
storage.push(
+
&ActionableEvent::CreateLinks {
+
record_id: RecordId {
+
did: "did:plc:linker".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf".into(),
+
},
+
links: vec![CollectedLink {
+
target: Link::Uri("a.com".into()),
+
path: ".abc.uri".into(),
+
}],
+
},
+
0,
+
)?;
+
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
None,
+
&HashSet::from([Did("did:plc:linker".to_string())]),
+
)?;
+
assert_eq!(
+
links,
+
PagedAppendingCollection {
+
version: (1, 0),
+
items: vec![RecordId {
+
did: "did:plc:linker".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf".into(),
+
},],
+
next: None,
+
total: 1,
+
}
+
);
+
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
None,
+
&HashSet::from([Did("did:plc:someone-else".to_string())]),
+
)?;
+
assert_eq!(
+
links,
+
PagedAppendingCollection {
+
version: (0, 0),
+
items: vec![],
+
next: None,
+
total: 0,
+
}
+
);
+
+
storage.push(
+
&ActionableEvent::CreateLinks {
+
record_id: RecordId {
+
did: "did:plc:linker".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf-2".into(),
+
},
+
links: vec![CollectedLink {
+
target: Link::Uri("a.com".into()),
+
path: ".abc.uri".into(),
+
}],
+
},
+
0,
+
)?;
+
storage.push(
+
&ActionableEvent::CreateLinks {
+
record_id: RecordId {
+
did: "did:plc:someone-else".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf".into(),
+
},
+
links: vec![CollectedLink {
+
target: Link::Uri("a.com".into()),
+
path: ".abc.uri".into(),
+
}],
+
},
+
0,
+
)?;
+
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
None,
+
&HashSet::from([Did("did:plc:linker".to_string())]),
+
)?;
+
assert_eq!(
+
links,
+
PagedAppendingCollection {
+
version: (2, 0),
+
items: vec![
+
RecordId {
+
did: "did:plc:linker".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf-2".into(),
+
},
+
RecordId {
+
did: "did:plc:linker".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf".into(),
+
},
+
],
+
next: None,
+
total: 2,
+
}
+
);
+
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
None,
+
&HashSet::from([
+
Did("did:plc:linker".to_string()),
+
Did("did:plc:someone-else".to_string()),
+
]),
+
)?;
+
assert_eq!(
+
links,
+
PagedAppendingCollection {
+
version: (3, 0),
+
items: vec![
+
RecordId {
+
did: "did:plc:someone-else".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf".into(),
+
},
+
RecordId {
+
did: "did:plc:linker".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf-2".into(),
+
},
+
],
+
next: Some(1),
+
total: 3,
+
}
+
);
+
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
None,
+
&HashSet::from([Did("did:plc:someone-unknown".to_string())]),
+
)?;
+
assert_eq!(
+
links,
+
PagedAppendingCollection {
+
version: (0, 0),
+
items: vec![],
+
next: None,
+
total: 0,
+
}
+
);
+
});
+
test_each_storage!(get_links_exact_multiple, |storage| {
for i in 1..=4 {
storage.push(
···
0,
)?;
}
+
let links =
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
assert_eq!(
links,
PagedAppendingCollection {
···
total: 4,
}
);
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
links.next,
+
&HashSet::default(),
+
)?;
assert_eq!(
links,
PagedAppendingCollection {
···
0,
)?;
}
+
let links =
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
assert_eq!(
links,
PagedAppendingCollection {
···
},
0,
)?;
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
links.next,
+
&HashSet::default(),
+
)?;
assert_eq!(
links,
PagedAppendingCollection {
···
0,
)?;
}
+
let links =
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
assert_eq!(
links,
PagedAppendingCollection {
···
}),
0,
)?;
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
links.next,
+
&HashSet::default(),
+
)?;
assert_eq!(
links,
PagedAppendingCollection {
···
0,
)?;
}
+
let links =
+
storage.get_links("a.com", "app.t.c", ".abc.uri", 2, None, &HashSet::default())?;
assert_eq!(
links,
PagedAppendingCollection {
···
&ActionableEvent::DeactivateAccount("did:plc:asdf-1".into()),
0,
)?;
+
let links = storage.get_links(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
2,
+
links.next,
+
&HashSet::default(),
+
)?;
assert_eq!(
links,
PagedAppendingCollection {
···
counts
});
assert_stats(storage.get_stats()?, 1..=1, 2..=2, 1..=1);
+
});
+
+
//////// many-to-many /////////
+
+
test_each_storage!(get_m2m_counts_empty, |storage| {
+
assert_eq!(
+
storage.get_many_to_many_counts(
+
"a.com",
+
"a.b.c",
+
".d.e",
+
".f.g",
+
10,
+
None,
+
&HashSet::new(),
+
&HashSet::new(),
+
)?,
+
PagedOrderedCollection {
+
items: vec![],
+
next: None,
+
}
+
);
+
});
+
+
test_each_storage!(get_m2m_counts_single, |storage| {
+
storage.push(
+
&ActionableEvent::CreateLinks {
+
record_id: RecordId {
+
did: "did:plc:asdf".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf".into(),
+
},
+
links: vec![
+
CollectedLink {
+
target: Link::Uri("a.com".into()),
+
path: ".abc.uri".into(),
+
},
+
CollectedLink {
+
target: Link::Uri("b.com".into()),
+
path: ".def.uri".into(),
+
},
+
CollectedLink {
+
target: Link::Uri("b.com".into()),
+
path: ".ghi.uri".into(),
+
},
+
],
+
},
+
0,
+
)?;
+
assert_eq!(
+
storage.get_many_to_many_counts(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
".def.uri",
+
10,
+
None,
+
&HashSet::new(),
+
&HashSet::new(),
+
)?,
+
PagedOrderedCollection {
+
items: vec![("b.com".to_string(), 1, 1)],
+
next: None,
+
}
+
);
+
});
+
+
test_each_storage!(get_m2m_counts_filters, |storage| {
+
storage.push(
+
&ActionableEvent::CreateLinks {
+
record_id: RecordId {
+
did: "did:plc:asdf".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf".into(),
+
},
+
links: vec![
+
CollectedLink {
+
target: Link::Uri("a.com".into()),
+
path: ".abc.uri".into(),
+
},
+
CollectedLink {
+
target: Link::Uri("b.com".into()),
+
path: ".def.uri".into(),
+
},
+
],
+
},
+
0,
+
)?;
+
storage.push(
+
&ActionableEvent::CreateLinks {
+
record_id: RecordId {
+
did: "did:plc:asdfasdf".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf".into(),
+
},
+
links: vec![
+
CollectedLink {
+
target: Link::Uri("a.com".into()),
+
path: ".abc.uri".into(),
+
},
+
CollectedLink {
+
target: Link::Uri("b.com".into()),
+
path: ".def.uri".into(),
+
},
+
],
+
},
+
1,
+
)?;
+
storage.push(
+
&ActionableEvent::CreateLinks {
+
record_id: RecordId {
+
did: "did:plc:fdsa".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf".into(),
+
},
+
links: vec![
+
CollectedLink {
+
target: Link::Uri("a.com".into()),
+
path: ".abc.uri".into(),
+
},
+
CollectedLink {
+
target: Link::Uri("c.com".into()),
+
path: ".def.uri".into(),
+
},
+
],
+
},
+
2,
+
)?;
+
storage.push(
+
&ActionableEvent::CreateLinks {
+
record_id: RecordId {
+
did: "did:plc:fdsa".into(),
+
collection: "app.t.c".into(),
+
rkey: "asdf2".into(),
+
},
+
links: vec![
+
CollectedLink {
+
target: Link::Uri("a.com".into()),
+
path: ".abc.uri".into(),
+
},
+
CollectedLink {
+
target: Link::Uri("c.com".into()),
+
path: ".def.uri".into(),
+
},
+
],
+
},
+
3,
+
)?;
+
assert_eq!(
+
storage.get_many_to_many_counts(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
".def.uri",
+
10,
+
None,
+
&HashSet::new(),
+
&HashSet::new(),
+
)?,
+
PagedOrderedCollection {
+
items: vec![("b.com".to_string(), 2, 2), ("c.com".to_string(), 2, 1),],
+
next: None,
+
}
+
);
+
assert_eq!(
+
storage.get_many_to_many_counts(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
".def.uri",
+
10,
+
None,
+
&HashSet::from_iter([Did("did:plc:fdsa".to_string())]),
+
&HashSet::new(),
+
)?,
+
PagedOrderedCollection {
+
items: vec![("c.com".to_string(), 2, 1),],
+
next: None,
+
}
+
);
+
assert_eq!(
+
storage.get_many_to_many_counts(
+
"a.com",
+
"app.t.c",
+
".abc.uri",
+
".def.uri",
+
10,
+
None,
+
&HashSet::new(),
+
&HashSet::from_iter(["b.com".to_string()]),
+
)?,
+
PagedOrderedCollection {
+
items: vec![("b.com".to_string(), 2, 2),],
+
next: None,
+
}
+
);
});
}
+361 -41
constellation/src/storage/rocks_store.rs
···
-
use super::{ActionableEvent, LinkReader, LinkStorage, PagedAppendingCollection, StorageStats};
use crate::{CountsByCount, Did, RecordId};
use anyhow::{bail, Result};
use bincode::Options as BincodeOptions;
···
MultiThreaded, Options, PrefixRange, ReadOptions, WriteBatch,
};
use serde::{Deserialize, Serialize};
-
use std::collections::{HashMap, HashSet};
use std::io::Read;
use std::marker::PhantomData;
use std::path::{Path, PathBuf};
···
Arc,
};
use std::thread;
-
use std::time::{Duration, Instant};
use tokio_util::sync::CancellationToken;
static DID_IDS_CF: &str = "did_ids";
···
static LINK_TARGETS_CF: &str = "link_targets";
static JETSTREAM_CURSOR_KEY: &str = "jetstream_cursor";
// todo: actually understand and set these options probably better
fn rocks_opts_base() -> Options {
···
#[derive(Debug, Clone)]
pub struct RocksStorage {
pub db: Arc<DBWithThreadMode<MultiThreaded>>, // TODO: mov seqs here (concat merge op will be fun)
-
did_id_table: IdTable<Did, DidIdValue, true>,
-
target_id_table: IdTable<TargetKey, TargetId, false>,
is_writer: bool,
backup_task: Arc<Option<thread::JoinHandle<Result<()>>>>,
}
···
fn cf_descriptor(&self) -> ColumnFamilyDescriptor {
ColumnFamilyDescriptor::new(&self.name, rocks_opts_base())
}
-
fn init<const WITH_REVERSE: bool>(
-
self,
-
db: &DBWithThreadMode<MultiThreaded>,
-
) -> Result<IdTable<Orig, IdVal, WITH_REVERSE>> {
if db.cf_handle(&self.name).is_none() {
bail!("failed to get cf handle from db -- was the db open with our .cf_descriptor()?");
}
···
}
}
#[derive(Debug, Clone)]
-
struct IdTable<Orig, IdVal: IdTableValue, const WITH_REVERSE: bool>
where
Orig: KeyFromRocks,
for<'a> &'a Orig: AsRocksKey,
···
base: IdTableBase<Orig, IdVal>,
priv_id_seq: u64,
}
-
impl<Orig: Clone, IdVal: IdTableValue, const WITH_REVERSE: bool> IdTable<Orig, IdVal, WITH_REVERSE>
where
Orig: KeyFromRocks,
for<'v> &'v IdVal: AsRocksValue,
···
_key_marker: PhantomData,
_val_marker: PhantomData,
name: name.into(),
-
id_seq: Arc::new(AtomicU64::new(0)), // zero is "uninint", first seq num will be 1
}
}
fn get_id_val(
···
id_value
}))
}
fn estimate_count(&self) -> u64 {
self.base.id_seq.load(Ordering::SeqCst) - 1 // -1 because seq zero is reserved
}
-
}
-
impl<Orig: Clone, IdVal: IdTableValue> IdTable<Orig, IdVal, true>
-
where
-
Orig: KeyFromRocks,
-
for<'v> &'v IdVal: AsRocksValue,
-
for<'k> &'k Orig: AsRocksKey,
-
{
fn get_or_create_id_val(
&mut self,
db: &DBWithThreadMode<MultiThreaded>,
···
}
}
}
-
impl<Orig: Clone, IdVal: IdTableValue> IdTable<Orig, IdVal, false>
-
where
-
Orig: KeyFromRocks,
-
for<'v> &'v IdVal: AsRocksValue,
-
for<'k> &'k Orig: AsRocksKey,
-
{
-
fn get_or_create_id_val(
-
&mut self,
-
db: &DBWithThreadMode<MultiThreaded>,
-
batch: &mut WriteBatch,
-
orig: &Orig,
-
) -> Result<IdVal> {
-
let cf = db.cf_handle(&self.base.name).unwrap();
-
self.__get_or_create_id_val(&cf, db, batch, orig)
-
}
-
}
impl IdTableValue for DidIdValue {
fn new(v: u64) -> Self {
···
}
}
impl RocksStorage {
pub fn new(path: impl AsRef<Path>) -> Result<Self> {
Self::describe_metrics();
-
RocksStorage::open_readmode(path, false)
}
pub fn open_readonly(path: impl AsRef<Path>) -> Result<Self> {
···
}
fn open_readmode(path: impl AsRef<Path>, readonly: bool) -> Result<Self> {
-
let did_id_table = IdTable::<_, _, true>::setup(DID_IDS_CF);
-
let target_id_table = IdTable::<_, _, false>::setup(TARGET_IDS_CF);
let cfs = vec![
// id reference tables
did_id_table.cf_descriptor(),
···
is_writer: !readonly,
backup_task: None.into(),
})
}
pub fn start_backup(
···
}
impl LinkReader for RocksStorage {
fn get_count(&self, target: &str, collection: &str, path: &str) -> Result<u64> {
let target_key = TargetKey(
Target(target.to_string()),
···
path: &str,
limit: u64,
until: Option<u64>,
) -> Result<PagedAppendingCollection<RecordId>> {
let target_key = TargetKey(
Target(target.to_string()),
···
});
};
-
let linkers = self.get_target_linkers(&target_id)?;
let (alive, gone) = linkers.count();
let total = alive + gone;
···
.map(|s| s.parse::<u64>())
.transpose()?
.unwrap_or(0);
Ok(StorageStats {
dids,
targetables,
linking_records,
})
}
}
···
impl AsRocksValue for &TargetId {}
impl KeyFromRocks for TargetKey {}
impl ValueFromRocks for TargetId {}
// target_links table
impl AsRocksKey for &TargetId {}
···
}
// target ids
-
#[derive(Debug, Clone, Serialize, Deserialize)]
struct TargetId(u64); // key
-
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Target(pub String); // the actual target/uri
// targets (uris, dids, etc.): the reverse index
···
+
use super::{
+
ActionableEvent, LinkReader, LinkStorage, PagedAppendingCollection, PagedOrderedCollection,
+
StorageStats,
+
};
use crate::{CountsByCount, Did, RecordId};
use anyhow::{bail, Result};
use bincode::Options as BincodeOptions;
···
MultiThreaded, Options, PrefixRange, ReadOptions, WriteBatch,
};
use serde::{Deserialize, Serialize};
+
use std::collections::{BTreeMap, HashMap, HashSet};
use std::io::Read;
use std::marker::PhantomData;
use std::path::{Path, PathBuf};
···
Arc,
};
use std::thread;
+
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use tokio_util::sync::CancellationToken;
static DID_IDS_CF: &str = "did_ids";
···
static LINK_TARGETS_CF: &str = "link_targets";
static JETSTREAM_CURSOR_KEY: &str = "jetstream_cursor";
+
static STARTED_AT_KEY: &str = "jetstream_first_cursor";
+
// add reverse mappings for targets if this db was running before that was a thing
+
static TARGET_ID_REPAIR_STATE_KEY: &str = "target_id_table_repair_state";
+
+
static COZY_FIRST_CURSOR: u64 = 1_738_083_600_000_000; // constellation.microcosm.blue started
+
+
#[derive(Debug, Clone, Serialize, Deserialize)]
+
struct TargetIdRepairState {
+
/// start time for repair, microseconds timestamp
+
current_us_started_at: u64,
+
/// id table's latest id when repair started
+
id_when_started: u64,
+
/// id table id
+
latest_repaired_i: u64,
+
}
+
impl AsRocksValue for TargetIdRepairState {}
+
impl ValueFromRocks for TargetIdRepairState {}
// todo: actually understand and set these options probably better
fn rocks_opts_base() -> Options {
···
#[derive(Debug, Clone)]
pub struct RocksStorage {
pub db: Arc<DBWithThreadMode<MultiThreaded>>, // TODO: mov seqs here (concat merge op will be fun)
+
did_id_table: IdTable<Did, DidIdValue>,
+
target_id_table: IdTable<TargetKey, TargetId>,
is_writer: bool,
backup_task: Arc<Option<thread::JoinHandle<Result<()>>>>,
}
···
fn cf_descriptor(&self) -> ColumnFamilyDescriptor {
ColumnFamilyDescriptor::new(&self.name, rocks_opts_base())
}
+
fn init(self, db: &DBWithThreadMode<MultiThreaded>) -> Result<IdTable<Orig, IdVal>> {
if db.cf_handle(&self.name).is_none() {
bail!("failed to get cf handle from db -- was the db open with our .cf_descriptor()?");
}
···
}
}
#[derive(Debug, Clone)]
+
struct IdTable<Orig, IdVal: IdTableValue>
where
Orig: KeyFromRocks,
for<'a> &'a Orig: AsRocksKey,
···
base: IdTableBase<Orig, IdVal>,
priv_id_seq: u64,
}
+
impl<Orig: Clone, IdVal: IdTableValue> IdTable<Orig, IdVal>
where
Orig: KeyFromRocks,
for<'v> &'v IdVal: AsRocksValue,
···
_key_marker: PhantomData,
_val_marker: PhantomData,
name: name.into(),
+
id_seq: Arc::new(AtomicU64::new(0)), // zero is "uninit", first seq num will be 1
}
}
fn get_id_val(
···
id_value
}))
}
+
fn estimate_count(&self) -> u64 {
self.base.id_seq.load(Ordering::SeqCst) - 1 // -1 because seq zero is reserved
}
+
fn get_or_create_id_val(
&mut self,
db: &DBWithThreadMode<MultiThreaded>,
···
}
}
}
impl IdTableValue for DidIdValue {
fn new(v: u64) -> Self {
···
}
}
+
fn now() -> u64 {
+
SystemTime::now()
+
.duration_since(UNIX_EPOCH)
+
.unwrap()
+
.as_micros() as u64
+
}
+
impl RocksStorage {
pub fn new(path: impl AsRef<Path>) -> Result<Self> {
Self::describe_metrics();
+
let me = RocksStorage::open_readmode(path, false)?;
+
me.global_init()?;
+
Ok(me)
}
pub fn open_readonly(path: impl AsRef<Path>) -> Result<Self> {
···
}
fn open_readmode(path: impl AsRef<Path>, readonly: bool) -> Result<Self> {
+
let did_id_table = IdTable::setup(DID_IDS_CF);
+
let target_id_table = IdTable::setup(TARGET_IDS_CF);
+
// note: global stuff like jetstream cursor goes in the default cf
+
// these are bonus extra cfs
let cfs = vec![
// id reference tables
did_id_table.cf_descriptor(),
···
is_writer: !readonly,
backup_task: None.into(),
})
+
}
+
+
fn global_init(&self) -> Result<()> {
+
let first_run = self.db.get(JETSTREAM_CURSOR_KEY)?.is_some();
+
if first_run {
+
self.db.put(STARTED_AT_KEY, _rv(now()))?;
+
+
// hack / temporary: if we're a new db, put in a completed repair
+
// state so we don't run repairs (repairs are for old-code dbs)
+
let completed = TargetIdRepairState {
+
id_when_started: 0,
+
current_us_started_at: 0,
+
latest_repaired_i: 0,
+
};
+
self.db.put(TARGET_ID_REPAIR_STATE_KEY, _rv(completed))?;
+
}
+
Ok(())
+
}
+
+
pub fn run_repair(&self, breather: Duration, stay_alive: CancellationToken) -> Result<bool> {
+
let mut state = match self
+
.db
+
.get(TARGET_ID_REPAIR_STATE_KEY)?
+
.map(|s| _vr(&s))
+
.transpose()?
+
{
+
Some(s) => s,
+
None => TargetIdRepairState {
+
id_when_started: self.did_id_table.priv_id_seq,
+
current_us_started_at: now(),
+
latest_repaired_i: 0,
+
},
+
};
+
+
eprintln!("initial repair state: {state:?}");
+
+
let cf = self.db.cf_handle(TARGET_IDS_CF).unwrap();
+
+
let mut iter = self.db.raw_iterator_cf(&cf);
+
iter.seek_to_first();
+
+
eprintln!("repair iterator sent to first key");
+
+
// skip ahead if we're done some, or take a single first step
+
for _ in 0..state.latest_repaired_i {
+
iter.next();
+
}
+
+
eprintln!(
+
"repair iterator skipped to {}th key",
+
state.latest_repaired_i
+
);
+
+
let mut maybe_done = false;
+
+
let mut write_fast = rocksdb::WriteOptions::default();
+
write_fast.set_sync(false);
+
write_fast.disable_wal(true);
+
+
while !stay_alive.is_cancelled() && !maybe_done {
+
// let mut batch = WriteBatch::default();
+
+
let mut any_written = false;
+
+
for _ in 0..1000 {
+
if state.latest_repaired_i % 1_000_000 == 0 {
+
eprintln!("target iter at {}", state.latest_repaired_i);
+
}
+
state.latest_repaired_i += 1;
+
+
if !iter.valid() {
+
eprintln!("invalid iter, are we done repairing?");
+
maybe_done = true;
+
break;
+
};
+
+
// eprintln!("iterator seems to be valid! getting the key...");
+
let raw_key = iter.key().unwrap();
+
if raw_key.len() == 8 {
+
// eprintln!("found an 8-byte key, skipping it since it's probably an id...");
+
iter.next();
+
continue;
+
}
+
let target: TargetKey = _kr::<TargetKey>(raw_key)?;
+
let target_id: TargetId = _vr(iter.value().unwrap())?;
+
+
self.db
+
.put_cf_opt(&cf, target_id.id().to_be_bytes(), _rv(&target), &write_fast)?;
+
any_written = true;
+
iter.next();
+
}
+
+
if any_written {
+
self.db
+
.put(TARGET_ID_REPAIR_STATE_KEY, _rv(state.clone()))?;
+
std::thread::sleep(breather);
+
}
+
}
+
+
eprintln!("repair iterator done.");
+
+
Ok(false)
}
pub fn start_backup(
···
}
impl LinkReader for RocksStorage {
+
fn get_many_to_many_counts(
+
&self,
+
target: &str,
+
collection: &str,
+
path: &str,
+
path_to_other: &str,
+
limit: u64,
+
after: Option<String>,
+
filter_dids: &HashSet<Did>,
+
filter_to_targets: &HashSet<String>,
+
) -> Result<PagedOrderedCollection<(String, u64, u64), String>> {
+
let collection = Collection(collection.to_string());
+
let path = RPath(path.to_string());
+
+
let target_key = TargetKey(Target(target.to_string()), collection.clone(), path.clone());
+
+
// unfortunately the cursor is a, uh, stringified number.
+
// this was easier for the memstore (plain target, not target id), and
+
// making it generic is a bit awful.
+
// so... parse the number out of a string here :(
+
// TODO: this should bubble up to a BAD_REQUEST response
+
let after = after.map(|s| s.parse::<u64>().map(TargetId)).transpose()?;
+
+
let Some(target_id) = self.target_id_table.get_id_val(&self.db, &target_key)? else {
+
eprintln!("nothin doin for this target, {target_key:?}");
+
return Ok(Default::default());
+
};
+
+
let filter_did_ids: HashMap<DidId, bool> = filter_dids
+
.iter()
+
.filter_map(|did| self.did_id_table.get_id_val(&self.db, did).transpose())
+
.collect::<Result<Vec<DidIdValue>>>()?
+
.into_iter()
+
.map(|DidIdValue(id, active)| (id, active))
+
.collect();
+
+
// stored targets are keyed by triples of (target, collection, path).
+
// target filtering only consideres the target itself, so we actually
+
// need to do a prefix iteration of all target ids for this target and
+
// keep them all.
+
// i *think* the number of keys at a target prefix should usually be
+
// pretty small, so this is hopefully fine. but if it turns out to be
+
// large, we can push this filtering back into the main links loop and
+
// do forward db queries per backlink to get the raw target back out.
+
let mut filter_to_target_ids: HashSet<TargetId> = HashSet::new();
+
for t in filter_to_targets {
+
for (_, target_id) in self.iter_targets_for_target(&Target(t.to_string())) {
+
filter_to_target_ids.insert(target_id);
+
}
+
}
+
+
let linkers = self.get_target_linkers(&target_id)?;
+
+
let mut grouped_counts: BTreeMap<TargetId, (u64, HashSet<DidId>)> = BTreeMap::new();
+
+
for (did_id, rkey) in linkers.0 {
+
if did_id.is_empty() {
+
continue;
+
}
+
+
if !filter_did_ids.is_empty() && filter_did_ids.get(&did_id) != Some(&true) {
+
continue;
+
}
+
+
let record_link_key = RecordLinkKey(did_id, collection.clone(), rkey);
+
let Some(targets) = self.get_record_link_targets(&record_link_key)? else {
+
continue;
+
};
+
+
let Some(fwd_target) = targets
+
.0
+
.into_iter()
+
.filter_map(|RecordLinkTarget(rpath, target_id)| {
+
if rpath.0 == path_to_other
+
&& (filter_to_target_ids.is_empty()
+
|| filter_to_target_ids.contains(&target_id))
+
{
+
Some(target_id)
+
} else {
+
None
+
}
+
})
+
.take(1)
+
.next()
+
else {
+
eprintln!("no forward match");
+
continue;
+
};
+
+
// small relief: we page over target ids, so we can already bail
+
// reprocessing previous pages here
+
if after.as_ref().map(|a| fwd_target <= *a).unwrap_or(false) {
+
continue;
+
}
+
+
// aand we can skip target ids that must be on future pages
+
// (this check continues after the did-lookup, which we have to do)
+
let page_is_full = grouped_counts.len() as u64 >= limit;
+
if page_is_full {
+
let current_max = grouped_counts.keys().next_back().unwrap(); // limit should be non-zero bleh
+
if fwd_target > *current_max {
+
continue;
+
}
+
}
+
+
// bit painful: 2-step lookup to make sure this did is active
+
let Some(did) = self.did_id_table.get_val_from_id(&self.db, did_id.0)? else {
+
eprintln!("failed to look up did from did_id {did_id:?}");
+
continue;
+
};
+
let Some(DidIdValue(_, active)) = self.did_id_table.get_id_val(&self.db, &did)? else {
+
eprintln!("failed to look up did_value from did_id {did_id:?}: {did:?}: data consistency bug?");
+
continue;
+
};
+
if !active {
+
continue;
+
}
+
+
// page-management, continued
+
// if we have a full page, and we're inserting a *new* key less than
+
// the current max, then we can evict the current max
+
let mut should_evict = false;
+
let entry = grouped_counts.entry(fwd_target.clone()).or_insert_with(|| {
+
// this is a *new* key, so kick the max if we're full
+
should_evict = page_is_full;
+
Default::default()
+
});
+
entry.0 += 1;
+
entry.1.insert(did_id);
+
+
if should_evict {
+
grouped_counts.pop_last();
+
}
+
}
+
+
let mut items: Vec<(String, u64, u64)> = Vec::with_capacity(grouped_counts.len());
+
for (target_id, (n, dids)) in &grouped_counts {
+
let Some(target) = self
+
.target_id_table
+
.get_val_from_id(&self.db, target_id.0)?
+
else {
+
eprintln!("failed to look up target from target_id {target_id:?}");
+
continue;
+
};
+
items.push((target.0 .0, *n, dids.len() as u64));
+
}
+
+
let next = if grouped_counts.len() as u64 >= limit {
+
// yeah.... it's a number saved as a string......sorry
+
grouped_counts
+
.keys()
+
.next_back()
+
.map(|k| format!("{}", k.0))
+
} else {
+
None
+
};
+
+
Ok(PagedOrderedCollection { items, next })
+
}
+
fn get_count(&self, target: &str, collection: &str, path: &str) -> Result<u64> {
let target_key = TargetKey(
Target(target.to_string()),
···
path: &str,
limit: u64,
until: Option<u64>,
+
filter_dids: &HashSet<Did>,
) -> Result<PagedAppendingCollection<RecordId>> {
let target_key = TargetKey(
Target(target.to_string()),
···
});
};
+
let mut linkers = self.get_target_linkers(&target_id)?;
+
if !filter_dids.is_empty() {
+
let mut did_filter = HashSet::new();
+
for did in filter_dids {
+
let Some(DidIdValue(did_id, active)) =
+
self.did_id_table.get_id_val(&self.db, did)?
+
else {
+
eprintln!("failed to find a did_id for {did:?}");
+
continue;
+
};
+
if !active {
+
eprintln!("excluding inactive did from filtered results");
+
continue;
+
}
+
did_filter.insert(did_id);
+
}
+
linkers.0.retain(|linker| did_filter.contains(&linker.0));
+
}
let (alive, gone) = linkers.count();
let total = alive + gone;
···
.map(|s| s.parse::<u64>())
.transpose()?
.unwrap_or(0);
+
let started_at = self
+
.db
+
.get(STARTED_AT_KEY)?
+
.map(|c| _vr(&c))
+
.transpose()?
+
.unwrap_or(COZY_FIRST_CURSOR);
+
+
let other_data = self
+
.db
+
.get(TARGET_ID_REPAIR_STATE_KEY)?
+
.map(|s| _vr(&s))
+
.transpose()?
+
.map(
+
|TargetIdRepairState {
+
current_us_started_at,
+
id_when_started,
+
latest_repaired_i,
+
}| {
+
HashMap::from([
+
("current_us_started_at".to_string(), current_us_started_at),
+
("id_when_started".to_string(), id_when_started),
+
("latest_repaired_i".to_string(), latest_repaired_i),
+
])
+
},
+
)
+
.unwrap_or(HashMap::default());
+
Ok(StorageStats {
dids,
targetables,
linking_records,
+
started_at: Some(started_at),
+
other_data,
})
}
}
···
impl AsRocksValue for &TargetId {}
impl KeyFromRocks for TargetKey {}
impl ValueFromRocks for TargetId {}
+
+
// temp?
+
impl KeyFromRocks for TargetId {}
+
impl AsRocksValue for &TargetKey {}
// target_links table
impl AsRocksKey for &TargetId {}
···
}
// target ids
+
#[derive(Debug, Clone, Serialize, Deserialize, PartialOrd, Ord, PartialEq, Eq, Hash)]
struct TargetId(u64); // key
+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct Target(pub String); // the actual target/uri
// targets (uris, dids, etc.): the reverse index
+1 -1
constellation/templates/dids.html.j2
···
{% for did in linking_dids %}
<pre style="display: block; margin: 1em 2em" class="code"><strong>DID</strong>: {{ did.0 }}
-> see <a href="/links/all?target={{ did.0|urlencode }}">links to this DID</a>
-
-> browse <a href="https://atproto-browser-plus-links.vercel.app/at/{{ did.0|urlencode }}">this DID record</a></pre>
{% endfor %}
{% if let Some(c) = cursor %}
···
{% for did in linking_dids %}
<pre style="display: block; margin: 1em 2em" class="code"><strong>DID</strong>: {{ did.0 }}
-> see <a href="/links/all?target={{ did.0|urlencode }}">links to this DID</a>
+
-> browse <a href="https://pdsls.dev/at://{{ did.0|urlencode }}">this DID record</a></pre>
{% endfor %}
{% if let Some(c) = cursor %}
+54
constellation/templates/get-backlinks.html.j2
···
···
+
{% extends "base.html.j2" %}
+
{% import "try-it-macros.html.j2" as try_it %}
+
+
{% block title %}Backlinks{% endblock %}
+
{% block description %}All {{ query.source }} records with links to {{ query.subject }}{% endblock %}
+
+
{% block content %}
+
+
{% call try_it::get_backlinks(query.subject, query.source, query.did, query.limit) %}
+
+
<h2>
+
Links to <code>{{ query.subject }}</code>
+
{% if let Some(browseable_uri) = query.subject|to_browseable %}
+
<small style="font-weight: normal; font-size: 1rem"><a href="{{ browseable_uri }}">browse record</a></small>
+
{% endif %}
+
</h2>
+
+
<p><strong>{{ total|human_number }} links</strong> from <code>{{ query.source }}</code>.</p>
+
+
<ul>
+
<li>See distinct linking DIDs at <code>/links/distinct-dids</code>: <a href="/links/distinct-dids?target={{ query.subject|urlencode }}&collection={{ collection|urlencode }}&path={{ path|urlencode }}">/links/distinct-dids?target={{ query.subject }}&collection={{ collection }}&path={{ path }}</a></li>
+
<li>See all links to this target at <code>/links/all</code>: <a href="/links/all?target={{ query.subject|urlencode }}">/links/all?target={{ query.subject }}</a></li>
+
</ul>
+
+
<h3>Links, most recent first:</h3>
+
+
{% for record in records %}
+
<pre style="display: block; margin: 1em 2em" class="code"><strong>DID</strong>: {{ record.did().0 }} (<a href="/links/all?target={{ record.did().0|urlencode }}">DID links</a>)
+
<strong>Collection</strong>: {{ record.collection }}
+
<strong>RKey</strong>: {{ record.rkey }}
+
-> <a href="https://pdsls.dev/at://{{ record.did().0 }}/{{ record.collection }}/{{ record.rkey }}">browse record</a></pre>
+
{% endfor %}
+
+
{% if let Some(c) = cursor %}
+
<form method="get" action="/xrpc/blue.microcosm.links.getBacklinks">
+
<input type="hidden" name="subject" value="{{ query.subject }}" />
+
<input type="hidden" name="source" value="{{ query.source }}" />
+
<input type="hidden" name="limit" value="{{ query.limit }}" />
+
{% for did in query.did %}
+
<input type="hidden" name="did" value="{{ did }}" />
+
{% endfor %}
+
<input type="hidden" name="cursor" value={{ c|json|safe }} />
+
<button type="submit">next page&hellip;</button>
+
</form>
+
{% else %}
+
<button disabled><em>end of results</em></button>
+
{% endif %}
+
+
<details>
+
<summary>Raw JSON response</summary>
+
<pre class="code">{{ self|tojson }}</pre>
+
</details>
+
+
{% endblock %}
+67
constellation/templates/get-many-to-many-counts.html.j2
···
···
+
{% extends "base.html.j2" %}
+
{% import "try-it-macros.html.j2" as try_it %}
+
+
{% block title %}Many to Many counts{% endblock %}
+
{% block description %}Counts of many-to-many {{ query.source }} join records with links to {{ query.subject }} and a secondary target at {{ query.path_to_other }}{% endblock %}
+
+
{% block content %}
+
+
{% call try_it::get_many_to_many_counts(
+
query.subject,
+
query.source,
+
query.path_to_other,
+
query.did,
+
query.other_subject,
+
query.limit,
+
) %}
+
+
<h2>
+
Many-to-many links to <code>{{ query.subject }}</code> joining through <code>{{ query.path_to_other }}</code>
+
{% if let Some(browseable_uri) = query.subject|to_browseable %}
+
<small style="font-weight: normal; font-size: 1rem"><a href="{{ browseable_uri }}">browse record</a></small>
+
{% endif %}
+
</h2>
+
+
<p><strong>{% if cursor.is_some() || query.cursor.is_some() %}more than {% endif %}{{ counts_by_other_subject.len()|to_u64|human_number }} joins</strong> <code>{{ query.source }}โ†’{{ query.path_to_other }}</code></p>
+
+
<ul>
+
<li>See direct backlinks at <code>/xrpc/blue.microcosm.links.getBacklinks</code>: <a href="/xrpc/blue.microcosm.links.getBacklinks?subject={{ query.subject|urlencode }}&source={{ query.source|urlencode }}">/xrpc/blue.microcosm.links.getBacklinks?subject={{ query.subject }}&source={{ query.source }}</a></li>
+
<li>See all links to this target at <code>/links/all</code>: <a href="/links/all?target={{ query.subject|urlencode }}">/links/all?target={{ query.subject }}</a></li>
+
</ul>
+
+
<h3>Counts by other subject:</h3>
+
+
{% for counts in counts_by_other_subject %}
+
<pre style="display: block; margin: 1em 2em" class="code"><strong>Joined subject</strong>: {{ counts.subject }}
+
<strong>Joining records</strong>: {{ counts.total }}
+
<strong>Unique joiner ids</strong>: {{ counts.distinct }}
+
-> {% if let Some(browseable_uri) = counts.subject|to_browseable -%}
+
<a href="{{ browseable_uri }}">browse record</a>
+
{%- endif %}</pre>
+
{% endfor %}
+
+
{% if let Some(c) = cursor %}
+
<form method="get" action="/xrpc/blue.microcosm.links.getManyToManyCounts">
+
<input type="hidden" name="subject" value="{{ query.subject }}" />
+
<input type="hidden" name="source" value="{{ query.source }}" />
+
<input type="hidden" name="pathToOther" value="{{ query.path_to_other }}" />
+
{% for did in query.did %}
+
<input type="hidden" name="did" value="{{ did }}" />
+
{% endfor %}
+
{% for otherSubject in query.other_subject %}
+
<input type="hidden" name="otherSubject" value="{{ otherSubject }}" />
+
{% endfor %}
+
<input type="hidden" name="limit" value="{{ query.limit }}" />
+
<input type="hidden" name="cursor" value={{ c|json|safe }} />
+
<button type="submit">next page&hellip;</button>
+
</form>
+
{% else %}
+
<button disabled><em>end of results</em></button>
+
{% endif %}
+
+
<details>
+
<summary>Raw JSON response</summary>
+
<pre class="code">{{ self|tojson }}</pre>
+
</details>
+
+
{% endblock %}
+65 -7
constellation/templates/hello.html.j2
···
<p>It works by recursively walking <em>all</em> records coming through the firehose, searching for anything that looks like a link. Links are indexed by the target they point at, the collection the record came from, and the JSON path to the link in that record.</p>
<p>
-
This server has indexed <span class="stat">{{ stats.linking_records|human_number }}</span> links between <span class="stat">{{ stats.targetables|human_number }}</span> targets and sources from <span class="stat">{{ stats.dids|human_number }}</span> identities over <span class="stat">{{ days_indexed|human_number }}</span> days.<br/>
-
<small>(indexing new records in real time, backfill still TODO)</small>
</p>
-
<p>The API is currently <strong>unstable</strong>. But feel free to use it! If you want to be nice, put your project name and bsky username (or email) in your user-agent header for api requests.</p>
<h2>API Endpoints</h2>
<h3 class="route"><code>GET /links</code></h3>
<p>A list of records linking to a target.</p>
<h4>Query parameters:</h4>
<ul>
-
<li><code>target</code>: required, must url-encode. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></li>
-
<li><code>collection</code>: required. Example: <code>app.bsky.feed.like</code></li>
-
<li><code>path</code>: required, must url-encode. Example: <code>.subject.uri</code></li>
</ul>
<p style="margin-bottom: 0"><strong>Try it:</strong></p>
-
{% call try_it::links("at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r", "app.bsky.feed.like", ".subject.uri") %}
<h3 class="route"><code>GET /links/distinct-dids</code></h3>
···
<p>It works by recursively walking <em>all</em> records coming through the firehose, searching for anything that looks like a link. Links are indexed by the target they point at, the collection the record came from, and the JSON path to the link in that record.</p>
<p>
+
This server has indexed <span class="stat">{{ stats.linking_records|human_number }}</span> links between <span class="stat">{{ stats.targetables|human_number }}</span> targets and sources from <span class="stat">{{ stats.dids|human_number }}</span> identities over <span class="stat">
+
{%- if let Some(days) = days_indexed %}
+
{{ days|human_number }}
+
{% else %}
+
???
+
{% endif -%}
+
</span> days.<br/>
+
<small>(indexing new records in real time, backfill coming soon!)</small>
</p>
+
{# {% for k, v in stats.other_data.iter() %}
+
<p><strong>{{ k }}</strong>: {{ v }}</p>
+
{% endfor %} #}
+
+
<p>You're welcome to use this public instance! Please do not build the torment nexus. If you want to be nice, put your project name and bsky username (or email) in your user-agent header for api requests.</p>
<h2>API Endpoints</h2>
+
<h3 class="route"><code>GET /xrpc/blue.microcosm.links.getBacklinks</code></h3>
+
+
<p>A list of records linking to any record, identity, or uri.</p>
+
+
<h4>Query parameters:</h4>
+
+
<ul>
+
<li><p><code>subject</code>: required, must url-encode. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></p></li>
+
<li><p><code>source</code>: required. Example: <code>app.bsky.feed.like:subject.uri</code></p></li>
+
<li><p><code>did</code>: optional, filter links to those from specific users. Include multiple times to filter by multiple users. Example: <code>did=did:plc:vc7f4oafdgxsihk4cry2xpze&did=did:plc:vc7f4oafdgxsihk4cry2xpze</code></p></li>
+
<li><p><code>limit</code>: optional. Default: <code>16</code>. Maximum: <code>100</code></p></li>
+
</ul>
+
+
<p style="margin-bottom: 0"><strong>Try it:</strong></p>
+
{% call try_it::get_backlinks("at://did:plc:a4pqq234yw7fqbddawjo7y35/app.bsky.feed.post/3m237ilwc372e", "app.bsky.feed.like:subject.uri", [""], 16) %}
+
+
+
<h3 class="route"><code>GET /xrpc/blue.microcosm.links.getManyToManyCounts</code></h3>
+
+
<p>TODO: description</p>
+
+
<h4>Query parameters:</h4>
+
+
<ul>
+
<li><p><code>subject</code>: required, must url-encode. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></p></li>
+
<li><p><code>source</code>: required. Example: <code>app.bsky.feed.like:subject.uri</code></p></li>
+
<li><p><code>pathToOther</code>: required. Path to the secondary link in the many-to-many record. Example: <code>otherThing.uri</code></p></li>
+
<li><p><code>did</code>: optional, filter links to those from specific users. Include multiple times to filter by multiple users. Example: <code>did=did:plc:vc7f4oafdgxsihk4cry2xpze&did=did:plc:vc7f4oafdgxsihk4cry2xpze</code></p></li>
+
<li><p><code>otherSubject</code>: optional, filter secondary links to specific subjects. Include multiple times to filter by multiple users. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></p></li>
+
<li><p><code>limit</code>: optional. Default: <code>16</code>. Maximum: <code>100</code></p></li>
+
</ul>
+
+
<p style="margin-bottom: 0"><strong>Try it:</strong></p>
+
{% call try_it::get_many_to_many_counts(
+
"at://did:plc:wshs7t2adsemcrrd4snkeqli/sh.tangled.label.definition/good-first-issue",
+
"sh.tangled.label.op:add[].key",
+
"subject",
+
[""],
+
[""],
+
25,
+
) %}
+
+
<h3 class="route"><code>GET /links</code></h3>
<p>A list of records linking to a target.</p>
+
<p>[DEPRECATED]: use <code>GET /xrpc/blue.microcosm.links.getBacklinks</code>. New apps should avoid it, but this endpoint <strong>will</strong> remain supported for the forseeable future.</p>
+
<h4>Query parameters:</h4>
<ul>
+
<li><p><code>target</code>: required, must url-encode. Example: <code>at://did:plc:vc7f4oafdgxsihk4cry2xpze/app.bsky.feed.post/3lgwdn7vd722r</code></p></li>
+
<li><p><code>collection</code>: required. Example: <code>app.bsky.feed.like</code></p></li>
+
<li><p><code>path</code>: required, must url-encode. Example: <code>.subject.uri</code></p></li>
+
<li><p><code>did</code>: optional, filter links to those from specific users. Include multiple times to filter by multiple users. Example: <code>did=did:plc:vc7f4oafdgxsihk4cry2xpze&did=did:plc:vc7f4oafdgxsihk4cry2xpze</code></p></li>
+
<li><p><code>from_dids</code> [deprecated]: optional. Use <code>did</code> instead. Example: <code>from_dids=did:plc:vc7f4oafdgxsihk4cry2xpze,did:plc:vc7f4oafdgxsihk4cry2xpze</code></p></li>
+
<li><p><code>limit</code>: optional. Default: <code>16</code>. Maximum: <code>100</code></p></li>
</ul>
<p style="margin-bottom: 0"><strong>Try it:</strong></p>
+
{% call try_it::links("at://did:plc:a4pqq234yw7fqbddawjo7y35/app.bsky.feed.post/3m237ilwc372e", "app.bsky.feed.like", ".subject.uri", [""], 16) %}
<h3 class="route"><code>GET /links/distinct-dids</code></h3>
+2 -2
constellation/templates/links.html.j2
···
{% block content %}
-
{% call try_it::links(query.target, query.collection, query.path) %}
<h2>
Links to <code>{{ query.target }}</code>
···
<pre style="display: block; margin: 1em 2em" class="code"><strong>DID</strong>: {{ record.did().0 }} (<a href="/links/all?target={{ record.did().0|urlencode }}">DID links</a>)
<strong>Collection</strong>: {{ record.collection }}
<strong>RKey</strong>: {{ record.rkey }}
-
-> <a href="https://atproto-browser-plus-links.vercel.app/at/{{ record.did().0|urlencode }}/{{ record.collection }}/{{ record.rkey }}">browse record</a></pre>
{% endfor %}
{% if let Some(c) = cursor %}
···
{% block content %}
+
{% call try_it::links(query.target, query.collection, query.path, query.did, query.limit) %}
<h2>
Links to <code>{{ query.target }}</code>
···
<pre style="display: block; margin: 1em 2em" class="code"><strong>DID</strong>: {{ record.did().0 }} (<a href="/links/all?target={{ record.did().0|urlencode }}">DID links</a>)
<strong>Collection</strong>: {{ record.collection }}
<strong>RKey</strong>: {{ record.rkey }}
+
-> <a href="https://pdsls.dev/at://{{ record.did().0 }}/{{ record.collection }}/{{ record.rkey }}">browse record</a></pre>
{% endfor %}
{% if let Some(c) = cursor %}
+88 -3
constellation/templates/try-it-macros.html.j2
···
-
{% macro links(target, collection, path) %}
<form method="get" action="/links">
<pre class="code"><strong>GET</strong> /links
?target= <input type="text" name="target" value="{{ target }}" placeholder="target" />
&collection= <input type="text" name="collection" value="{{ collection }}" placeholder="collection" />
-
&path= <input type="text" name="path" value="{{ path }}" placeholder="path" /> <button type="submit">get links</button></pre>
</form>
{% endmacro %}
-
{% macro dids(target, collection, path) %}
<form method="get" action="/links/distinct-dids">
···
+
{% macro get_backlinks(subject, source, dids, limit) %}
+
<form method="get" action="/xrpc/blue.microcosm.links.getBacklinks">
+
<pre class="code"><strong>GET</strong> /xrpc/blue.microcosm.links.getBacklinks
+
?subject= <input type="text" name="subject" value="{{ subject }}" placeholder="at-uri, did, uri..." />
+
&source= <input type="text" name="source" value="{{ source }}" placeholder="app.bsky.feed.like:subject.uri" />
+
{%- for did in dids %}{% if !did.is_empty() %}
+
&did= <input type="text" name="did" value="{{ did }}" placeholder="did:plc:..." />{% endif %}{% endfor %}
+
<span id="did-placeholder"></span> <button id="add-did">+ did filter</button>
+
&limit= <input type="number" name="limit" value="{{ limit }}" max="100" placeholder="100" /> <button type="submit">get links</button></pre>
+
</form>
+
<script>
+
const addDidButton = document.getElementById('add-did');
+
const didPlaceholder = document.getElementById('did-placeholder');
+
addDidButton.addEventListener('click', e => {
+
e.preventDefault();
+
const i = document.createElement('input');
+
i.placeholder = 'did:plc:...';
+
i.name = "did"
+
const p = addDidButton.parentNode;
+
p.insertBefore(document.createTextNode('&did= '), didPlaceholder);
+
p.insertBefore(i, didPlaceholder);
+
p.insertBefore(document.createTextNode('\n '), didPlaceholder);
+
});
+
</script>
+
{% endmacro %}
+
+
{% macro get_many_to_many_counts(subject, source, pathToOther, dids, otherSubjects, limit) %}
+
<form method="get" action="/xrpc/blue.microcosm.links.getManyToManyCounts">
+
<pre class="code"><strong>GET</strong> /xrpc/blue.microcosm.links.getManyToManyCounts
+
?subject= <input type="text" name="subject" value="{{ subject }}" placeholder="at-uri, did, uri..." />
+
&source= <input type="text" name="source" value="{{ source }}" placeholder="app.bsky.feed.like:subject.uri" />
+
&pathToOther= <input type="text" name="pathToOther" value="{{ pathToOther }}" placeholder="otherThing.uri" />
+
{%- for did in dids %}{% if !did.is_empty() %}
+
&did= <input type="text" name="did" value="{{ did }}" placeholder="did:plc:..." />{% endif %}{% endfor %}
+
<span id="m2m-subject-placeholder"></span> <button id="m2m-add-subject">+ other subject filter</button>
+
{%- for otherSubject in otherSubjects %}{% if !otherSubject.is_empty() %}
+
&otherSubject= <input type="text" name="did" value="{{ otherSubject }}" placeholder="at-uri, did, uri..." />{% endif %}{% endfor %}
+
<span id="m2m-did-placeholder"></span> <button id="m2m-add-did">+ did filter</button>
+
&limit= <input type="number" name="limit" value="{{ limit }}" max="100" placeholder="100" /> <button type="submit">get links</button></pre>
+
</form>
+
<script>
+
const m2mAddDidButton = document.getElementById('m2m-add-did');
+
const m2mDidPlaceholder = document.getElementById('m2m-did-placeholder');
+
m2mAddDidButton.addEventListener('click', e => {
+
e.preventDefault();
+
const i = document.createElement('input');
+
i.placeholder = 'did:plc:...';
+
i.name = "did"
+
const p = m2mAddDidButton.parentNode;
+
p.insertBefore(document.createTextNode('&did= '), m2mDidPlaceholder);
+
p.insertBefore(i, m2mDidPlaceholder);
+
p.insertBefore(document.createTextNode('\n '), m2mDidPlaceholder);
+
});
+
const m2mAddSubjectButton = document.getElementById('m2m-add-subject');
+
const m2mSubjectPlaceholder = document.getElementById('m2m-subject-placeholder');
+
m2mAddSubjectButton.addEventListener('click', e => {
+
e.preventDefault();
+
const i = document.createElement('input');
+
i.placeholder = 'at-uri, did, uri...';
+
i.name = "otherSubject"
+
const p = m2mAddSubjectButton.parentNode;
+
p.insertBefore(document.createTextNode('&otherSubject= '), m2mSubjectPlaceholder);
+
p.insertBefore(i, m2mSubjectPlaceholder);
+
p.insertBefore(document.createTextNode('\n '), m2mSubjectPlaceholder);
+
});
+
</script>
+
{% endmacro %}
+
+
{% macro links(target, collection, path, dids, limit) %}
<form method="get" action="/links">
<pre class="code"><strong>GET</strong> /links
?target= <input type="text" name="target" value="{{ target }}" placeholder="target" />
&collection= <input type="text" name="collection" value="{{ collection }}" placeholder="collection" />
+
&path= <input type="text" name="path" value="{{ path }}" placeholder="path" />
+
{%- for did in dids %}{% if !did.is_empty() %}
+
&did= <input type="text" name="did" value="{{ did }}" placeholder="did:plc:..." />{% endif %}{% endfor %}
+
<span id="did-placeholder"></span> <button id="add-did">+ did filter</button>
+
&limit= <input type="number" name="limit" value="{{ limit }}" max="100" placeholder="100" /> <button type="submit">get links</button></pre>
</form>
+
<script>
+
const addDidButton = document.getElementById('add-did');
+
const didPlaceholder = document.getElementById('did-placeholder');
+
addDidButton.addEventListener('click', e => {
+
e.preventDefault();
+
const i = document.createElement('input');
+
i.placeholder = 'did:plc:...';
+
i.name = "did"
+
const p = addDidButton.parentNode;
+
p.insertBefore(document.createTextNode('&did= '), didPlaceholder);
+
p.insertBefore(i, didPlaceholder);
+
p.insertBefore(document.createTextNode('\n '), didPlaceholder);
+
});
+
</script>
{% endmacro %}
{% macro dids(target, collection, path) %}
<form method="get" action="/links/distinct-dids">
-496
cozy-setup (move to another repo).md
···
-
cozy-ucosm
-
-
-
## gateway
-
-
- tailscale (exit node enabled)
-
-> allow ipv4 and ipv6 forwarding
-
- caddy
-
-
```bash
-
apt install golang
-
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
-
go/bin/xcaddy build \
-
--with github.com/caddyserver/cache-handler \
-
--with github.com/darkweak/storages/badger/caddy \
-
--with github.com/mholt/caddy-ratelimit
-
# then https://caddyserver.com/docs/running#manual-installation
-
-
mkdir /var/cache/caddy-badger
-
chown -R caddy:caddy /var/cache/caddy-badger/
-
```
-
-
- `/etc/caddy/Caddyfile`
-
-
```
-
{
-
cache {
-
badger
-
api {
-
prometheus
-
}
-
}
-
}
-
-
links.bsky.bad-example.com {
-
reverse_proxy link-aggregator:6789
-
-
@browser `{header.Origin.startsWith("Mozilla/5.0")`
-
rate_limit {
-
zone global_burst {
-
key {remote_host}
-
events 10
-
window 1s
-
}
-
zone global_general {
-
key {remote_host}
-
events 100
-
window 60s
-
log_key true
-
}
-
zone website_harsh_limit {
-
key {header.Origin}
-
match {
-
expression {header.User-Agent}.startsWith("Mozilla/5.0")
-
}
-
events 1000
-
window 30s
-
log_key true
-
}
-
}
-
respond /souin-api/metrics "denied" 403 # does not work
-
cache {
-
ttl 3s
-
stale 1h
-
default_cache_control public, s-maxage=3
-
badger {
-
path /var/cache/caddy-badger/links
-
}
-
}
-
}
-
-
gateway:80 {
-
metrics
-
cache
-
}
-
```
-
well... the gateway fell over IMMEDIATELY with like 2 req/sec from deletions, with that ^^ config. for now i removed everything except the reverse proxy config + normal caddy metrics and it's running fine on vanilla caddy. i did try reducing the rate-limiting configs to a single, fixed-key global limit but it still ate all the ram and died. maybe badger w/ the cache config was still a problem. maybe it would have been ok on a machine with more than 1GB mem.
-
-
-
alternative proxies:
-
-
- nginx. i should probably just use this. acme-client is a piece of cake to set up, and i know how to configure it.
-
- haproxy. also kind of familiar, it's old and stable. no idea how it handle low-mem (our 1gb) vs nginx.
-
- sozu. popular rust thing, fast. doesn't have rate-limiting or cache feature?
-
- rpxy. like caddy (auto-tls) but in rust and actually fast? has an "experimental" cache feature. but the cache feature looks good.
-
- rama. build-your-own proxy. not sure that it has both cache and limiter in their standard features?
-
- pingora. build-your-own cloudflare, so like, probably stable. has tools for cache and limiting. low-mem...?
-
- cache stuff in pingora seems a little... hit and miss (byeeeee). only a test impl for Storage for the main cache feature?
-
- but the rate-limiter has a guide: https://github.com/cloudflare/pingora/blob/main/docs/user_guide/rate_limiter.md
-
-
what i want is low-resource reverse proxy with built-in rate-limiting and caching. but maybe cache (and/or ratelimiting) could be external to the reverse proxy
-
- varnish is a dedicated cache. has https://github.com/varnish/varnish-modules/blob/master/src/vmod_vsthrottle.vcc
-
- apache traffic control has experimental rate-limiting plugins
-
-
-
- victoriametrics
-
-
```bash
-
curl -LO https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.109.1/victoria-metrics-linux-amd64-v1.109.1.tar.gz
-
tar xzf victoria-metrics-linux-amd64-v1.109.1.tar.gz
-
# and then https://docs.victoriametrics.com/quick-start/#starting-vm-single-from-a-binary
-
sudo mkdir /etc/victoria-metrics && sudo chown -R victoriametrics:victoriametrics /etc/victoria-metrics
-
-
```
-
-
- `/etc/victoria-metrics/prometheus.yml`
-
-
```yaml
-
global:
-
scrape_interval: '15s'
-
-
scrape_configs:
-
- job_name: 'link_aggregator'
-
static_configs:
-
- targets: ['link-aggregator:8765']
-
- job_name: 'gateway:caddy'
-
static_configs:
-
- targets: ['gateway:80/metrics']
-
- job_name: 'gateway:cache'
-
static_configs:
-
- targets: ['gateway:80/souin-api/metrics']
-
```
-
-
- `ExecStart` in `/etc/systemd/system/victoriametrics.service`:
-
-
```
-
ExecStart=/usr/local/bin/victoria-metrics-prod -storageDataPath=/var/lib/victoria-metrics -retentionPeriod=90d -selfScrapeInterval=1m -promscrape.config=/etc/victoria-metrics/prometheus.yml
-
```
-
-
- grafana
-
-
followed `https://grafana.com/docs/grafana/latest/setup-grafana/installation/debian/#install-grafana-on-debian-or-ubuntu`
-
-
something something something then
-
-
```
-
sudo grafana-cli --pluginUrl https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/download/v0.11.1/victoriametrics-datasource-v0.11.1.zip plugins install victoriametrics
-
```
-
-
- raspi node_exporter
-
-
```bash
-
curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-armv7.tar.gz
-
tar xzf node_exporter-1.8.2.linux-armv7.tar.gz
-
sudo cp node_exporter-1.8.2.linux-armv7/node_exporter /usr/local/bin/
-
sudo useradd --no-create-home --shell /bin/false node_exporter
-
sudo nano /etc/systemd/system/node_exporter.service
-
# [Unit]
-
# Description=Node Exporter
-
# Wants=network-online.target
-
# After=network-online.target
-
-
# [Service]
-
# User=node_exporter
-
# Group=node_exporter
-
# Type=simple
-
# ExecStart=/usr/local/bin/node_exporter
-
# Restart=always
-
# RestartSec=3
-
-
# [Install]
-
# WantedBy=multi-user.target
-
sudo systemctl daemon-reload
-
sudo systemctl enable node_exporter.service
-
sudo systemctl start node_exporter.service
-
```
-
-
todo: get raspi vcgencmd outputs into metrics
-
-
- nginx on gateway
-
-
```nginx
-
# in http
-
-
##
-
# cozy cache
-
##
-
proxy_cache_path /var/cache/nginx keys_zone=cozy_zone:10m;
-
-
##
-
# cozy limit
-
##
-
limit_req_zone $binary_remote_addr zone=cozy_ip_limit:10m rate=50r/s;
-
limit_req_zone $server_name zone=cozy_global_limit:10m rate=1000r/s;
-
-
# in sites-available/constellation.microcosm.blue
-
-
upstream cozy_link_aggregator {
-
server link-aggregator:6789;
-
keepalive 16;
-
}
-
-
server {
-
listen 8080;
-
listen [::]:8080;
-
-
server_name constellation.microcosm.blue;
-
-
proxy_cache cozy_zone;
-
proxy_cache_background_update on;
-
proxy_cache_key "$scheme$proxy_host$uri$is_args$args$http_accept";
-
proxy_cache_lock on; # make simlutaneous requests for the same uri wait for it to appear in cache instead of hitting origin
-
proxy_cache_lock_age 1s;
-
proxy_cache_lock_timeout 2s;
-
proxy_cache_valid 10s; # default -- should be explicitly set in the response headers
-
proxy_cache_valid any 15s; # non-200s default
-
proxy_read_timeout 5s;
-
proxy_send_timeout 15s;
-
proxy_socket_keepalive on;
-
-
limit_req zone=cozy_ip_limit nodelay burst=100;
-
limit_req zone=cozy_global_limit;
-
limit_req_status 429;
-
-
location / {
-
proxy_pass http://cozy_link_aggregator;
-
include proxy_params;
-
proxy_http_version 1.1;
-
proxy_set_header Connection ""; # for keepalive
-
}
-
}
-
```
-
-
also `systemctl edit nginx` and paste
-
-
```
-
[Service]
-
Restart=always
-
```
-
-
โ€”https://serverfault.com/a/1003373
-
-
now making browsers redirect to the microcosm.blue url:
-
-
```
-
[...]
-
server_name links.bsky.bad-example.com;
-
-
add_header Access-Control-Allow-Origin * always; # bit of hack to have it here but nginx doesn't like it in the `if`
-
if ($http_user_agent ~ ^Mozilla/) {
-
# for now send *browsers* to the new location, hopefully without impacting api requests
-
# (yeah we're doing UA test here and content-negotatiation in the app. whatever.)
-
return 301 https://constellation.microcosm.blue$request_uri;
-
}
-
[...]
-
```
-
-
- nginx metrics
-
-
- download nginx-prometheus-exporter
-
https://github.com/nginx/nginx-prometheus-exporter/releases/download/v1.4.1/nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
-
-
- err actually going to make mistakes and try with snap
-
`snap install nginx-prometheus-exporter`
-
- so it got a binary for me but no systemd task set up. boooo.
-
`snap remove nginx-prometheus-exporter`
-
-
- ```bash
-
curl -LO https://github.com/nginx/nginx-prometheus-exporter/releases/download/v1.4.1/nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
-
tar xzf nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
-
mv nginx-prometheus-exporter /usr/local/bin
-
useradd --no-create-home --shell /bin/false nginx-prometheus-exporter
-
nano /etc/systemd/system/nginx-prometheus-exporter.service
-
# [Unit]
-
# Description=NGINX Exporter
-
# Wants=network-online.target
-
# After=network-online.target
-
-
# [Service]
-
# User=nginx-prometheus-exporter
-
# Group=nginx-prometheus-exporter
-
# Type=simple
-
# ExecStart=/usr/local/bin/nginx-prometheus-exporter --nginx.scrape-uri=http://gateway:8080/stub_status --web.listen-address=gateway:9113
-
# Restart=always
-
# RestartSec=3
-
-
# [Install]
-
# WantedBy=multi-user.target
-
systemctl daemon-reload
-
systemctl start nginx-prometheus-exporter.service
-
systemctl enable nginx-prometheus-exporter.service
-
```
-
-
- nginx `/etc/nginx/sites-available/gateway-nginx-status`
-
-
```nginx
-
server {
-
listen 8080;
-
listen [::]:8080;
-
-
server_name gateway;
-
-
location /stub_status {
-
stub_status;
-
}
-
location / {
-
return 404;
-
}
-
}
-
```
-
-
```bash
-
ln -s /etc/nginx/sites-available/gateway-nginx-status /etc/nginx/sites-enabled/
-
```
-
-
-
## bootes (pi5)
-
-
- mount sd card, touch `ssh` file echo `echo "pi:$(echo raspberry | openssl passwd -6 -stdin)" > userconf.txt`
-
- raspi-config: enable pcie 3, set hostname, enable ssh
-
- put ssh key into `.ssh/authorized_keys`
-
- put `PasswordAuthentication no` in `/etc/ssh/sshd_config`
-
- `sudo apt update && sudo apt upgrade`
-
- `sudo apt install xfsprogs`
-
- `sudo mkfs.xfs -L c11n-kv /dev/nvme0n1`
-
- `sudo mount /dev/nvme0n1 /mnt`
-
- set up tailscale
-
- `sudo tailscale up`
-
- `git clone https://github.com/atcosm/links.git`
-
- tailscale: disable bootes key expiry
-
- rustup `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
-
- `cd links/constellation`
-
- `sudo apt install libssl-dev` needed
-
- `sudo apt install clang` needed for bindgen
-
- (in tmux) `cargo build --release`
-
- `mkdir ~/backup`
-
- `sudo mount.cifs "//truenas.local/folks data" /home/pi/backup -o user=phil,uid=pi`
-
- `sudo chown pi:pi /mnt/`
-
- `RUST_BACKTRACE=full cargo run --bin rocks-restore-from-backup --release -- --from-backup-dir "/home/pi/backup/constellation-index" --to-data-dir /mnt/constellation-index`
-
etc
-
- follow above `- raspi node_exporter`
-
- configure victoriametrics to scrape the new pi
-
- configure ulimit before starting! `ulimit -n 16384`
-
- `RUST_BACKTRACE=full cargo run --release -- --backend rocks --data /mnt/constellation-index/ --jetstream us-east-2 --backup /home/pi/backup/constellation-index --backup-interval 6 --max-old-backups 20`
-
- add server to nginx gateway upstream: ` server 100.123.79.12:6789; # bootes`
-
- stop backups from running on the older instance! `RUST_BACKTRACE=full cargo run --release -- --backend rocks --data /mnt/links-2.rocks/ --jetstream us-east-1`
-
- stop upstreaming requests to older instance in nginx
-
-
-
- systemd unit for running: `sudo nano /etc/systemd/system/constellation.service`
-
-
```ini
-
[Unit]
-
Description=Constellation backlinks index
-
After=network.target
-
-
[Service]
-
User=pi
-
WorkingDirectory=/home/pi/links/constellation
-
ExecStart=/home/pi/links/target/release/main --backend rocks --data /mnt/constellation-index/ --jetstream us-east-2 --backup /home/pi/backup/constellation-index --backup-interval 6 --max-old-backups 20
-
LimitNOFILE=16384
-
Restart=always
-
-
[Install]
-
WantedBy=multi-user.target
-
```
-
-
-
- todo: overlayfs? would need to figure out builds/updates still, also i guess logs are currently written to sd? (oof)
-
- todo: cross-compile for raspi?
-
-
---
-
-
some todos
-
-
- [x] tailscale: exit node
-
- [!] link_aggregator: use exit node
-
-> worked, but reverted for now: tailscale on raspi was consuming ~50% cpu for the jetstream traffic. this might be near its max since it would have been catching up at the time (max jetstream throughput) but it feels a bit too much. we have to trust the jetstream server and link_aggregator doesn't (yet) make any other external connections, so for now the raspi connects directly from my home again.
-
- [x] caddy: reverse proxy
-
- [x] build with cache and rate-limit plugins
-
- [x] configure systemd to keep it alive
-
- [x] configure caddy cache
-
- [x] configure caddy rate-limit
-
- [ ] configure ~caddy~ nginx to use a health check (once it's added)
-
- [ ] ~configure caddy to only expose cache metrics to tailnet :/~
-
- [x] make some grafana dashboards
-
- [ ] raspi: mount /dev/sda on boot
-
- [ ] raspi: run link_aggregator via systemd so it starts on startup (and restarts?)
-
-
- [x] use nginx instead of caddy
-
- [x] nginx: enable cache
-
- [x] nginx: rate-limit
-
- [ ] nginx: get metrics
-
-
-
-
-
---
-
-
nginx cors for constellation + small burst bump
-
-
```nginx
-
upstream cozy_constellation {
-
server <tailnet ip>:6789; # bootes; ip so that we don't race on reboot with tailscale coming up, which nginx doesn't like
-
keepalive 16;
-
}
-
-
server {
-
server_name constellation.microcosm.blue;
-
-
proxy_cache cozy_zone;
-
proxy_cache_background_update on;
-
proxy_cache_key "$scheme$proxy_host$uri$is_args$args$http_accept";
-
proxy_cache_lock on; # make simlutaneous requests for the same uri wait for it to appear in cache instead of hitting origin
-
proxy_cache_lock_age 1s;
-
proxy_cache_lock_timeout 2s;
-
proxy_cache_valid 10s; # default -- should be explicitly set in the response headers
-
proxy_cache_valid any 2s; # non-200s default
-
proxy_read_timeout 5s;
-
proxy_send_timeout 15s;
-
proxy_socket_keepalive on;
-
-
# take over cors responsibility from upsteram. `always` applies it to error responses.
-
proxy_hide_header 'Access-Control-Allow-Origin';
-
proxy_hide_header 'Access-Control-Allowed-Methods';
-
proxy_hide_header 'Access-Control-Allow-Headers';
-
add_header 'Access-Control-Allow-Origin' '*' always;
-
add_header 'Access-Control-Allow-Methods' 'GET' always;
-
add_header 'Access-Control-Allow-Headers' '*' always;
-
-
-
limit_req zone=cozy_ip_limit nodelay burst=150;
-
limit_req zone=cozy_global_limit burst=1800;
-
limit_req_status 429;
-
-
location / {
-
proxy_pass http://cozy_constellation;
-
include proxy_params;
-
proxy_http_version 1.1;
-
proxy_set_header Connection ""; # for keepalive
-
}
-
-
-
listen 443 ssl; # managed by Certbot
-
ssl_certificate /etc/letsencrypt/live/constellation.microcosm.blue/fullchain.pem; # managed by Certbot
-
ssl_certificate_key /etc/letsencrypt/live/constellation.microcosm.blue/privkey.pem; # managed by Certbot
-
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
-
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
-
-
}
-
-
server {
-
if ($host = constellation.microcosm.blue) {
-
return 301 https://$host$request_uri;
-
} # managed by Certbot
-
-
-
server_name constellation.microcosm.blue;
-
listen 80;
-
return 404; # managed by Certbot
-
}
-
```
-
-
re-reading about `nodelay`, i should probably remove it -- nginx would then queue requests to upstream, but still service them at the configured limit. it's fine for my internet since the global limit isn't nodelay, but probably less "fair" to clients if there's contention around the global limit (earlier requests would get all of theirs serviced before later ones can get in the queue)
-
-
leaving it for now though.
-
-
-
### nginx logs to prom
-
-
```bash
-
curl -LO https://github.com/martin-helmich/prometheus-nginxlog-exporter/releases/download/v1.11.0/prometheus-nginxlog-exporter_1.11.0_linux_amd64.deb
-
apt install ./prometheus-nginxlog-exporter_1.11.0_linux_amd64.deb
-
systemctl enable prometheus-nginxlog-exporter.service
-
-
```
-
-
have it run as www-data (maybe not the best idea but...)
-
file `/usr/lib/systemd/system/prometheus-nginxlog-exporter.service`
-
set User under service and remove capabilities bounding
-
-
```systemd
-
User=www-data
-
#CapabilityBoundingSet=
-
```
-
-
in `nginx.conf` in `http`:
-
-
```nginx
-
log_format constellation_format "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\"";
-
```
-
-
in `sites-available/constellation.microcosm.blue` in `server`:
-
-
```nginx
-
# log format must match prometheus-nginx-log-exporter
-
access_log /var/log/nginx/constellation-access.log constellation_format;
-
```
-
-
config at `/etc/prometheus-nginxlog-exporter.hcl`
-
-
-
-
```bash
-
systemctl start prometheus-nginxlog-exporter.service
-
```
···
+1 -1
jetstream/Cargo.toml
···
[dependencies]
async-trait = "0.1.83"
-
atrium-api = { version = "0.25.4", default-features = false, features = [
"namespace-appbsky",
] }
tokio = { version = "1.44.2", features = ["full", "sync", "time"] }
···
[dependencies]
async-trait = "0.1.83"
+
atrium-api = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace", default-features = false, features = [
"namespace-appbsky",
] }
tokio = { version = "1.44.2", features = ["full", "sync", "time"] }
+496
legacy/cozy-setup (move to another repo).md
···
···
+
cozy-ucosm
+
+
+
## gateway
+
+
- tailscale (exit node enabled)
+
-> allow ipv4 and ipv6 forwarding
+
- caddy
+
+
```bash
+
apt install golang
+
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
+
go/bin/xcaddy build \
+
--with github.com/caddyserver/cache-handler \
+
--with github.com/darkweak/storages/badger/caddy \
+
--with github.com/mholt/caddy-ratelimit
+
# then https://caddyserver.com/docs/running#manual-installation
+
+
mkdir /var/cache/caddy-badger
+
chown -R caddy:caddy /var/cache/caddy-badger/
+
```
+
+
- `/etc/caddy/Caddyfile`
+
+
```
+
{
+
cache {
+
badger
+
api {
+
prometheus
+
}
+
}
+
}
+
+
links.bsky.bad-example.com {
+
reverse_proxy link-aggregator:6789
+
+
@browser `{header.Origin.startsWith("Mozilla/5.0")`
+
rate_limit {
+
zone global_burst {
+
key {remote_host}
+
events 10
+
window 1s
+
}
+
zone global_general {
+
key {remote_host}
+
events 100
+
window 60s
+
log_key true
+
}
+
zone website_harsh_limit {
+
key {header.Origin}
+
match {
+
expression {header.User-Agent}.startsWith("Mozilla/5.0")
+
}
+
events 1000
+
window 30s
+
log_key true
+
}
+
}
+
respond /souin-api/metrics "denied" 403 # does not work
+
cache {
+
ttl 3s
+
stale 1h
+
default_cache_control public, s-maxage=3
+
badger {
+
path /var/cache/caddy-badger/links
+
}
+
}
+
}
+
+
gateway:80 {
+
metrics
+
cache
+
}
+
```
+
well... the gateway fell over IMMEDIATELY with like 2 req/sec from deletions, with that ^^ config. for now i removed everything except the reverse proxy config + normal caddy metrics and it's running fine on vanilla caddy. i did try reducing the rate-limiting configs to a single, fixed-key global limit but it still ate all the ram and died. maybe badger w/ the cache config was still a problem. maybe it would have been ok on a machine with more than 1GB mem.
+
+
+
alternative proxies:
+
+
- nginx. i should probably just use this. acme-client is a piece of cake to set up, and i know how to configure it.
+
- haproxy. also kind of familiar, it's old and stable. no idea how it handle low-mem (our 1gb) vs nginx.
+
- sozu. popular rust thing, fast. doesn't have rate-limiting or cache feature?
+
- rpxy. like caddy (auto-tls) but in rust and actually fast? has an "experimental" cache feature. but the cache feature looks good.
+
- rama. build-your-own proxy. not sure that it has both cache and limiter in their standard features?
+
- pingora. build-your-own cloudflare, so like, probably stable. has tools for cache and limiting. low-mem...?
+
- cache stuff in pingora seems a little... hit and miss (byeeeee). only a test impl for Storage for the main cache feature?
+
- but the rate-limiter has a guide: https://github.com/cloudflare/pingora/blob/main/docs/user_guide/rate_limiter.md
+
+
what i want is low-resource reverse proxy with built-in rate-limiting and caching. but maybe cache (and/or ratelimiting) could be external to the reverse proxy
+
- varnish is a dedicated cache. has https://github.com/varnish/varnish-modules/blob/master/src/vmod_vsthrottle.vcc
+
- apache traffic control has experimental rate-limiting plugins
+
+
+
- victoriametrics
+
+
```bash
+
curl -LO https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.109.1/victoria-metrics-linux-amd64-v1.109.1.tar.gz
+
tar xzf victoria-metrics-linux-amd64-v1.109.1.tar.gz
+
# and then https://docs.victoriametrics.com/quick-start/#starting-vm-single-from-a-binary
+
sudo mkdir /etc/victoria-metrics && sudo chown -R victoriametrics:victoriametrics /etc/victoria-metrics
+
+
```
+
+
- `/etc/victoria-metrics/prometheus.yml`
+
+
```yaml
+
global:
+
scrape_interval: '15s'
+
+
scrape_configs:
+
- job_name: 'link_aggregator'
+
static_configs:
+
- targets: ['link-aggregator:8765']
+
- job_name: 'gateway:caddy'
+
static_configs:
+
- targets: ['gateway:80/metrics']
+
- job_name: 'gateway:cache'
+
static_configs:
+
- targets: ['gateway:80/souin-api/metrics']
+
```
+
+
- `ExecStart` in `/etc/systemd/system/victoriametrics.service`:
+
+
```
+
ExecStart=/usr/local/bin/victoria-metrics-prod -storageDataPath=/var/lib/victoria-metrics -retentionPeriod=90d -selfScrapeInterval=1m -promscrape.config=/etc/victoria-metrics/prometheus.yml
+
```
+
+
- grafana
+
+
followed `https://grafana.com/docs/grafana/latest/setup-grafana/installation/debian/#install-grafana-on-debian-or-ubuntu`
+
+
something something something then
+
+
```
+
sudo grafana-cli --pluginUrl https://github.com/VictoriaMetrics/victoriametrics-datasource/releases/download/v0.11.1/victoriametrics-datasource-v0.11.1.zip plugins install victoriametrics
+
```
+
+
- raspi node_exporter
+
+
```bash
+
curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-armv7.tar.gz
+
tar xzf node_exporter-1.8.2.linux-armv7.tar.gz
+
sudo cp node_exporter-1.8.2.linux-armv7/node_exporter /usr/local/bin/
+
sudo useradd --no-create-home --shell /bin/false node_exporter
+
sudo nano /etc/systemd/system/node_exporter.service
+
# [Unit]
+
# Description=Node Exporter
+
# Wants=network-online.target
+
# After=network-online.target
+
+
# [Service]
+
# User=node_exporter
+
# Group=node_exporter
+
# Type=simple
+
# ExecStart=/usr/local/bin/node_exporter
+
# Restart=always
+
# RestartSec=3
+
+
# [Install]
+
# WantedBy=multi-user.target
+
sudo systemctl daemon-reload
+
sudo systemctl enable node_exporter.service
+
sudo systemctl start node_exporter.service
+
```
+
+
todo: get raspi vcgencmd outputs into metrics
+
+
- nginx on gateway
+
+
```nginx
+
# in http
+
+
##
+
# cozy cache
+
##
+
proxy_cache_path /var/cache/nginx keys_zone=cozy_zone:10m;
+
+
##
+
# cozy limit
+
##
+
limit_req_zone $binary_remote_addr zone=cozy_ip_limit:10m rate=50r/s;
+
limit_req_zone $server_name zone=cozy_global_limit:10m rate=1000r/s;
+
+
# in sites-available/constellation.microcosm.blue
+
+
upstream cozy_link_aggregator {
+
server link-aggregator:6789;
+
keepalive 16;
+
}
+
+
server {
+
listen 8080;
+
listen [::]:8080;
+
+
server_name constellation.microcosm.blue;
+
+
proxy_cache cozy_zone;
+
proxy_cache_background_update on;
+
proxy_cache_key "$scheme$proxy_host$uri$is_args$args$http_accept";
+
proxy_cache_lock on; # make simlutaneous requests for the same uri wait for it to appear in cache instead of hitting origin
+
proxy_cache_lock_age 1s;
+
proxy_cache_lock_timeout 2s;
+
proxy_cache_valid 10s; # default -- should be explicitly set in the response headers
+
proxy_cache_valid any 15s; # non-200s default
+
proxy_read_timeout 5s;
+
proxy_send_timeout 15s;
+
proxy_socket_keepalive on;
+
+
limit_req zone=cozy_ip_limit nodelay burst=100;
+
limit_req zone=cozy_global_limit;
+
limit_req_status 429;
+
+
location / {
+
proxy_pass http://cozy_link_aggregator;
+
include proxy_params;
+
proxy_http_version 1.1;
+
proxy_set_header Connection ""; # for keepalive
+
}
+
}
+
```
+
+
also `systemctl edit nginx` and paste
+
+
```
+
[Service]
+
Restart=always
+
```
+
+
โ€”https://serverfault.com/a/1003373
+
+
now making browsers redirect to the microcosm.blue url:
+
+
```
+
[...]
+
server_name links.bsky.bad-example.com;
+
+
add_header Access-Control-Allow-Origin * always; # bit of hack to have it here but nginx doesn't like it in the `if`
+
if ($http_user_agent ~ ^Mozilla/) {
+
# for now send *browsers* to the new location, hopefully without impacting api requests
+
# (yeah we're doing UA test here and content-negotatiation in the app. whatever.)
+
return 301 https://constellation.microcosm.blue$request_uri;
+
}
+
[...]
+
```
+
+
- nginx metrics
+
+
- download nginx-prometheus-exporter
+
https://github.com/nginx/nginx-prometheus-exporter/releases/download/v1.4.1/nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
+
+
- err actually going to make mistakes and try with snap
+
`snap install nginx-prometheus-exporter`
+
- so it got a binary for me but no systemd task set up. boooo.
+
`snap remove nginx-prometheus-exporter`
+
+
- ```bash
+
curl -LO https://github.com/nginx/nginx-prometheus-exporter/releases/download/v1.4.1/nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
+
tar xzf nginx-prometheus-exporter_1.4.1_linux_amd64.tar.gz
+
mv nginx-prometheus-exporter /usr/local/bin
+
useradd --no-create-home --shell /bin/false nginx-prometheus-exporter
+
nano /etc/systemd/system/nginx-prometheus-exporter.service
+
# [Unit]
+
# Description=NGINX Exporter
+
# Wants=network-online.target
+
# After=network-online.target
+
+
# [Service]
+
# User=nginx-prometheus-exporter
+
# Group=nginx-prometheus-exporter
+
# Type=simple
+
# ExecStart=/usr/local/bin/nginx-prometheus-exporter --nginx.scrape-uri=http://gateway:8080/stub_status --web.listen-address=gateway:9113
+
# Restart=always
+
# RestartSec=3
+
+
# [Install]
+
# WantedBy=multi-user.target
+
systemctl daemon-reload
+
systemctl start nginx-prometheus-exporter.service
+
systemctl enable nginx-prometheus-exporter.service
+
```
+
+
- nginx `/etc/nginx/sites-available/gateway-nginx-status`
+
+
```nginx
+
server {
+
listen 8080;
+
listen [::]:8080;
+
+
server_name gateway;
+
+
location /stub_status {
+
stub_status;
+
}
+
location / {
+
return 404;
+
}
+
}
+
```
+
+
```bash
+
ln -s /etc/nginx/sites-available/gateway-nginx-status /etc/nginx/sites-enabled/
+
```
+
+
+
## bootes (pi5)
+
+
- mount sd card, touch `ssh` file echo `echo "pi:$(echo raspberry | openssl passwd -6 -stdin)" > userconf.txt`
+
- raspi-config: enable pcie 3, set hostname, enable ssh
+
- put ssh key into `.ssh/authorized_keys`
+
- put `PasswordAuthentication no` in `/etc/ssh/sshd_config`
+
- `sudo apt update && sudo apt upgrade`
+
- `sudo apt install xfsprogs`
+
- `sudo mkfs.xfs -L c11n-kv /dev/nvme0n1`
+
- `sudo mount /dev/nvme0n1 /mnt`
+
- set up tailscale
+
- `sudo tailscale up`
+
- `git clone https://github.com/atcosm/links.git`
+
- tailscale: disable bootes key expiry
+
- rustup `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
+
- `cd links/constellation`
+
- `sudo apt install libssl-dev` needed
+
- `sudo apt install clang` needed for bindgen
+
- (in tmux) `cargo build --release`
+
- `mkdir ~/backup`
+
- `sudo mount.cifs "//truenas.local/folks data" /home/pi/backup -o user=phil,uid=pi`
+
- `sudo chown pi:pi /mnt/`
+
- `RUST_BACKTRACE=full cargo run --bin rocks-restore-from-backup --release -- --from-backup-dir "/home/pi/backup/constellation-index" --to-data-dir /mnt/constellation-index`
+
etc
+
- follow above `- raspi node_exporter`
+
- configure victoriametrics to scrape the new pi
+
- configure ulimit before starting! `ulimit -n 16384`
+
- `RUST_BACKTRACE=full cargo run --release -- --backend rocks --data /mnt/constellation-index/ --jetstream us-east-2 --backup /home/pi/backup/constellation-index --backup-interval 6 --max-old-backups 20`
+
- add server to nginx gateway upstream: ` server 100.123.79.12:6789; # bootes`
+
- stop backups from running on the older instance! `RUST_BACKTRACE=full cargo run --release -- --backend rocks --data /mnt/links-2.rocks/ --jetstream us-east-1`
+
- stop upstreaming requests to older instance in nginx
+
+
+
- systemd unit for running: `sudo nano /etc/systemd/system/constellation.service`
+
+
```ini
+
[Unit]
+
Description=Constellation backlinks index
+
After=network.target
+
+
[Service]
+
User=pi
+
WorkingDirectory=/home/pi/links/constellation
+
ExecStart=/home/pi/links/target/release/main --backend rocks --data /mnt/constellation-index/ --jetstream us-east-2 --backup /home/pi/backup/constellation-index --backup-interval 6 --max-old-backups 20
+
LimitNOFILE=16384
+
Restart=always
+
+
[Install]
+
WantedBy=multi-user.target
+
```
+
+
+
- todo: overlayfs? would need to figure out builds/updates still, also i guess logs are currently written to sd? (oof)
+
- todo: cross-compile for raspi?
+
+
---
+
+
some todos
+
+
- [x] tailscale: exit node
+
- [!] link_aggregator: use exit node
+
-> worked, but reverted for now: tailscale on raspi was consuming ~50% cpu for the jetstream traffic. this might be near its max since it would have been catching up at the time (max jetstream throughput) but it feels a bit too much. we have to trust the jetstream server and link_aggregator doesn't (yet) make any other external connections, so for now the raspi connects directly from my home again.
+
- [x] caddy: reverse proxy
+
- [x] build with cache and rate-limit plugins
+
- [x] configure systemd to keep it alive
+
- [x] configure caddy cache
+
- [x] configure caddy rate-limit
+
- [ ] configure ~caddy~ nginx to use a health check (once it's added)
+
- [ ] ~configure caddy to only expose cache metrics to tailnet :/~
+
- [x] make some grafana dashboards
+
- [ ] raspi: mount /dev/sda on boot
+
- [ ] raspi: run link_aggregator via systemd so it starts on startup (and restarts?)
+
+
- [x] use nginx instead of caddy
+
- [x] nginx: enable cache
+
- [x] nginx: rate-limit
+
- [ ] nginx: get metrics
+
+
+
+
+
---
+
+
nginx cors for constellation + small burst bump
+
+
```nginx
+
upstream cozy_constellation {
+
server <tailnet ip>:6789; # bootes; ip so that we don't race on reboot with tailscale coming up, which nginx doesn't like
+
keepalive 16;
+
}
+
+
server {
+
server_name constellation.microcosm.blue;
+
+
proxy_cache cozy_zone;
+
proxy_cache_background_update on;
+
proxy_cache_key "$scheme$proxy_host$uri$is_args$args$http_accept";
+
proxy_cache_lock on; # make simlutaneous requests for the same uri wait for it to appear in cache instead of hitting origin
+
proxy_cache_lock_age 1s;
+
proxy_cache_lock_timeout 2s;
+
proxy_cache_valid 10s; # default -- should be explicitly set in the response headers
+
proxy_cache_valid any 2s; # non-200s default
+
proxy_read_timeout 5s;
+
proxy_send_timeout 15s;
+
proxy_socket_keepalive on;
+
+
# take over cors responsibility from upsteram. `always` applies it to error responses.
+
proxy_hide_header 'Access-Control-Allow-Origin';
+
proxy_hide_header 'Access-Control-Allowed-Methods';
+
proxy_hide_header 'Access-Control-Allow-Headers';
+
add_header 'Access-Control-Allow-Origin' '*' always;
+
add_header 'Access-Control-Allow-Methods' 'GET' always;
+
add_header 'Access-Control-Allow-Headers' '*' always;
+
+
+
limit_req zone=cozy_ip_limit nodelay burst=150;
+
limit_req zone=cozy_global_limit burst=1800;
+
limit_req_status 429;
+
+
location / {
+
proxy_pass http://cozy_constellation;
+
include proxy_params;
+
proxy_http_version 1.1;
+
proxy_set_header Connection ""; # for keepalive
+
}
+
+
+
listen 443 ssl; # managed by Certbot
+
ssl_certificate /etc/letsencrypt/live/constellation.microcosm.blue/fullchain.pem; # managed by Certbot
+
ssl_certificate_key /etc/letsencrypt/live/constellation.microcosm.blue/privkey.pem; # managed by Certbot
+
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
+
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
+
+
}
+
+
server {
+
if ($host = constellation.microcosm.blue) {
+
return 301 https://$host$request_uri;
+
} # managed by Certbot
+
+
+
server_name constellation.microcosm.blue;
+
listen 80;
+
return 404; # managed by Certbot
+
}
+
```
+
+
re-reading about `nodelay`, i should probably remove it -- nginx would then queue requests to upstream, but still service them at the configured limit. it's fine for my internet since the global limit isn't nodelay, but probably less "fair" to clients if there's contention around the global limit (earlier requests would get all of theirs serviced before later ones can get in the queue)
+
+
leaving it for now though.
+
+
+
### nginx logs to prom
+
+
```bash
+
curl -LO https://github.com/martin-helmich/prometheus-nginxlog-exporter/releases/download/v1.11.0/prometheus-nginxlog-exporter_1.11.0_linux_amd64.deb
+
apt install ./prometheus-nginxlog-exporter_1.11.0_linux_amd64.deb
+
systemctl enable prometheus-nginxlog-exporter.service
+
+
```
+
+
have it run as www-data (maybe not the best idea but...)
+
file `/usr/lib/systemd/system/prometheus-nginxlog-exporter.service`
+
set User under service and remove capabilities bounding
+
+
```systemd
+
User=www-data
+
#CapabilityBoundingSet=
+
```
+
+
in `nginx.conf` in `http`:
+
+
```nginx
+
log_format constellation_format "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\"";
+
```
+
+
in `sites-available/constellation.microcosm.blue` in `server`:
+
+
```nginx
+
# log format must match prometheus-nginx-log-exporter
+
access_log /var/log/nginx/constellation-access.log constellation_format;
+
```
+
+
config at `/etc/prometheus-nginxlog-exporter.hcl`
+
+
+
+
```bash
+
systemctl start prometheus-nginxlog-exporter.service
+
```
+35
legacy/old-readme-details.md
···
···
+
[Constellation](./constellation/)
+
--------------------------------------------
+
+
A global atproto backlink index โœจ
+
+
- Self hostable: handles the full write throughput of the global atproto firehose on a raspberry pi 4b + single SSD
+
- Storage efficient: less than 2GB/day disk consumption indexing all references in all lexicons and all non-atproto URLs
+
- Handles record deletion, account de/re-activation, and account deletion, ensuring accurate link counts and respecting users data choices
+
- Simple JSON API
+
+
All social interactions in atproto tend to be represented by links (or references) between PDS records. This index can answer questions like "how many likes does a bsky post have", "who follows an account", "what are all the comments on a [frontpage](https://frontpage.fyi/) post", and more.
+
+
- **status**: works! api is unstable and likely to change, and no known instances have a full network backfill yet.
+
- source: [./constellation/](./constellation/)
+
- public instance: [constellation.microcosm.blue](https://constellation.microcosm.blue/)
+
+
_note: the public instance currently runs on a little raspberry pi in my house, feel free to use it! it comes with only with best-effort uptime, no commitment to not breaking the api for now, and possible rate-limiting. if you want to be nice you can put your project name and bsky username (or email) in your user-agent header for api requests._
+
+
+
App: Spacedust
+
--------------
+
+
A notification subscription service ๐Ÿ’ซ
+
+
using the same "link source" concept as [constellation](./constellation/), offer webhook notifications for new references created to records
+
+
- **status**: in design
+
+
+
Library: [links](./links/)
+
------------------------------------
+
+
A rust crate (not published on crates.io yet) for optimistically parsing links out of arbitrary atproto PDS records, and potentially canonicalizing them
+
+
- **status**: unstable, might remain an internal lib for constellation (and spacedust, soon)
+123
legacy/original-notes.md
···
···
+
---
+
+
+
old notes follow, ignore
+
------------------------
+
+
+
as far as i can tell, atproto lexicons today don't follow much of a convention for referencing across documents: sometimes it's a StrongRef, sometimes it's a DID, sometimes it's a bare at-uri. lexicon authors choose any old link-sounding key name for the key in their document.
+
+
it's pretty messy so embrace the mess: atproto wants to be part of the web, so this library will also extract URLs and other URIs if you want it to. all the links.
+
+
+
why
+
---
+
+
the atproto firehose that bluesky sprays at you will contain raw _contents_ from peoples' pdses. these are isolated, decontextualized updates. it's very easy to build some kinds of interesting downstream apps off of this feed.
+
+
- bluesky posts (firesky, deletions, )
+
- blueksy post stats (emojis, )
+
- trending keywords ()
+
+
but bringing almost kind of _context_ into your project requires a big step up in complexity and potentially cost: you're entering "appview" territory. _how many likes does a post have? who follows this account?_
+
+
you own your atproto data: it's kept in your personal data repository (PDS) and noone else can write to it. when someone likes your post, they create a "like" record in their _own_ pds, and that like belongs to _them_, not to you/your post.
+
+
in the firehose you'll see a `app.bsky.feed.post` record created, with no details about who has liked it. then you'll see separate `app.bsky.feed.like` records show up for each like that comes in on that post, with no context about the post except a random-looking reference to it. storing these in order to do so is up to you!
+
+
**so, why**
+
+
everything is links, and they're a mess, but they all kinda work the same, so maybe some tooling can bring down that big step in complexity from firehose raw-content apps -> apps requiring any social context.
+
+
everything is links:
+
+
- likes
+
- follows
+
- blocks
+
- reposts
+
- quotes
+
+
some low-level things you could make from links:
+
+
- notification streams (part of ucosm)
+
- a global reverse index (part of ucosm)
+
+
i think that making these low-level services as easy to use as jetstream could open up pathways for building more atproto apps that operate at full scale with interesting features for reasonable effort at low cost to operate.
+
+
+
extracting links
+
---------------
+
+
+
- low-level: pass a &str of a field value and get a parsed link back
+
+
- med-level: pass a &str of record in json form and get a list of parsed links + json paths back. (todo: should also handle dag-cbor prob?)
+
+
- high-ish level: pass the json record and maybe apply some pre-loaded rules based on known lexicons to get the best result.
+
+
for now, a link is only considered if it matches for the entire value of the record's field -- links embedded in text content are not included. note that urls in bluesky posts _will_ still be extracted, since they are broken out into facets.
+
+
+
resolving / canonicalizing links
+
--------------------------------
+
+
+
### at-uris
+
+
every at-uri has at least two equivalent forms, one with a `DID`, and one with an account handle. the at-uri spec [illustrates this by example](https://atproto.com/specs/at-uri-scheme):
+
+
- `at://did:plc:44ybard66vv44zksje25o7dz/app.bsky.feed.post/3jwdwj2ctlk26`
+
- `at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26`
+
+
some applications, like a reverse link index, may wish to canonicalize at-uris to a single form. the `DID`-form is stable as an account changes its handle and probably the right choice to canonicalize to, but maybe some apps would actually perfer to canonicalise to handles?
+
+
hopefully atrium will make it easy to resolve at-uris.
+
+
+
### urls
+
+
canonicalizing URLs is more annoying but also a bit more established. lots of details.
+
+
- do we have to deal with punycode?
+
- follow redirects (todo: only permanent ones, or all?)
+
- check for rel=canonical http header and possibly follow it
+
- check link rel=canonical meta tag and possibly follow it
+
- do we need to check site maps??
+
- do we have to care at all about AMP?
+
- do we want anything to do with url shorteners??
+
- how do multilingual sites affect this?
+
- do we have to care about `script type="application/ld+json"` ???
+
+
ugh. is there a crate for this.
+
+
+
### relative uris?
+
+
links might be relative, in which case they might need to be made absolute before being useful. is that a concern for this library, or up to the user? (seems like we might not have context here to determine its absolute)
+
+
+
### canonicalizing
+
+
there should be a few async functions available to canonicalize already-parsed links.
+
+
- what happens if a link can't be resolved?
+
+
+
---
+
+
- using `tinyjson` because it's nice -- maybe should switch to serde_json to share deps with atrium?
+
+
- would use atrium for parsing at-uris, but it's not in there. there's a did-only version in the non-lib commands.rs. its identifier parser is strict to did + handle, which makes sense, but for our purposes we might want to allow unknown methods too?
+
+
- rsky-syntax has an aturi
+
- adenosyne also
+
- might come back to these
+
+
+
-------
+
+
rocks
+
+
```bash
+
ROCKSDB_LIB_DIR=/nix/store/z2chn0hsik0clridr8mlprx1cngh1g3c-rocksdb-9.7.3/lib/ cargo build
+
```
+196
legacy/ufos ops (move to micro-ops).md
···
···
+
ufos ops
+
+
btrfs snapshots: snapper
+
+
```bash
+
sudo apt install snapper
+
sudo snapper -c ufos-db create-config /mnt/ufos-db
+
+
# edit /etc/snapper/configs/ufos-db
+
# change
+
TIMELINE_MIN_AGE="1800"
+
TIMELINE_LIMIT_HOURLY="10"
+
TIMELINE_LIMIT_DAILY="10"
+
TIMELINE_LIMIT_WEEKLY="0"
+
TIMELINE_LIMIT_MONTHLY="10"
+
TIMELINE_LIMIT_YEARLY="10"
+
# to
+
TIMELINE_MIN_AGE="1800"
+
TIMELINE_LIMIT_HOURLY="22"
+
TIMELINE_LIMIT_DAILY="4"
+
TIMELINE_LIMIT_WEEKLY="0"
+
TIMELINE_LIMIT_MONTHLY="0"
+
TIMELINE_LIMIT_YEARLY="0"
+
```
+
+
this should be enough?
+
+
list snapshots:
+
+
```bash
+
sudo snapper -c ufos-db list
+
```
+
+
systemd
+
+
create file: `/etc/systemd/system/ufos.service`
+
+
```ini
+
[Unit]
+
Description=UFOs-API
+
After=network.target
+
+
[Service]
+
User=pi
+
WorkingDirectory=/home/pi/
+
ExecStart=/home/pi/ufos --jetstream us-west-2 --data /mnt/ufos-db/
+
Environment="RUST_LOG=info"
+
LimitNOFILE=16384
+
Restart=always
+
+
[Install]
+
WantedBy=multi-user.target
+
```
+
+
then
+
+
```bash
+
sudo systemctl daemon-reload
+
sudo systemctl enable ufos
+
sudo systemctl start ufos
+
```
+
+
monitor with
+
+
```bash
+
journalctl -u ufos -f
+
```
+
+
make sure a backup dir exists
+
+
```bash
+
mkdir /home/pi/backup
+
```
+
+
mount the NAS
+
+
```bash
+
sudo mount.cifs "//truenas.local/folks data" /home/pi/backup -o user=phil,uid=pi
+
```
+
+
manual rsync
+
+
```bash
+
sudo rsync -ahP --delete /mnt/ufos-db/.snapshots/1/snapshot/ backup/ufos/
+
```
+
+
backup script sketch
+
+
```bash
+
NUM=$(sudo snapper --csvout -c ufos-db list --type single --columns number | tail -n1)
+
sudo rsync -ahP --delete "/mnt/ufos-db/.snapshots/${NUM}/snapshot/" backup/ufos/
+
```
+
+
just crontab it?
+
+
`sudo crontab -e`
+
```bash
+
0 1/6 * * * rsync -ahP --delete "/mnt/ufos-db/.snapshots/$(sudo snapper --csvout -c ufos-db list --columns number | tail -n1)/snapshot/" backup/ufos/
+
```
+
+
^^ try once initial backup is done
+
+
+
--columns subvolume,number
+
+
subvolume
+
number
+
+
+
+
+
gateway: follow constellation for nginx->prom thing
+
+
config at `/etc/prometheus-nginxlog-exporter.hcl`
+
+
before: `/etc/prometheus-nginxlog-exporter.hcl`
+
+
```hcl
+
listen {
+
port = 4044
+
}
+
+
namespace "nginx" {
+
source = {
+
files = [
+
"/var/log/nginx/constellation-access.log"
+
]
+
}
+
+
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
+
+
labels {
+
app = "constellation"
+
}
+
+
relabel "cache_status" {
+
from = "upstream_cache_status"
+
}
+
}
+
```
+
+
after:
+
+
```hcl
+
listen {
+
port = 4044
+
}
+
+
namespace "constellation" {
+
source = {
+
files = [
+
"/var/log/nginx/constellation-access.log"
+
]
+
}
+
+
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
+
+
labels {
+
app = "constellation"
+
}
+
+
relabel "cache_status" {
+
from = "upstream_cache_status"
+
}
+
+
namespace_label = "vhost"
+
metrics_override = { prefix = "nginx" }
+
}
+
+
namespace "ufos" {
+
source = {
+
files = [
+
"/var/log/nginx/ufos-access.log"
+
]
+
}
+
+
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
+
+
labels {
+
app = "ufos"
+
}
+
+
relabel "cache_status" {
+
from = "upstream_cache_status"
+
}
+
+
namespace_label = "vhost"
+
metrics_override = { prefix = "nginx" }
+
}
+
```
+
+
+
```bash
+
systemctl start prometheus-nginxlog-exporter.service
+
```
+
+2
links/Cargo.toml
···
[dependencies]
anyhow = "1.0.95"
fluent-uri = "0.3.2"
nom = "7.1.3"
thiserror = "2.0.9"
tinyjson = "2.5.1"
···
[dependencies]
anyhow = "1.0.95"
+
dasl = "0.2.0"
fluent-uri = "0.3.2"
nom = "7.1.3"
+
serde = { version = "1.0.228", features = ["derive"] }
thiserror = "2.0.9"
tinyjson = "2.5.1"
+3 -2
links/src/lib.rs
···
use fluent_uri::Uri;
pub mod at_uri;
pub mod did;
···
pub use record::collect_links;
-
#[derive(Debug, Clone, Ord, Eq, PartialOrd, PartialEq)]
pub enum Link {
AtUri(String),
Uri(String),
···
}
}
-
#[derive(Debug, PartialEq)]
pub struct CollectedLink {
pub path: String,
pub target: Link,
···
use fluent_uri::Uri;
+
use serde::{Deserialize, Serialize};
pub mod at_uri;
pub mod did;
···
pub use record::collect_links;
+
#[derive(Debug, Clone, Ord, Eq, PartialOrd, PartialEq, Serialize, Deserialize)]
pub enum Link {
AtUri(String),
Uri(String),
···
}
}
+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CollectedLink {
pub path: String,
pub target: Link,
+41
links/src/record.rs
···
use tinyjson::JsonValue;
use crate::{parse_any_link, CollectedLink};
···
}
}
pub fn collect_links(v: &JsonValue) -> Vec<CollectedLink> {
let mut found = vec![];
walk_record("", v, &mut found);
found
}
···
+
use dasl::drisl::Value as DrislValue;
use tinyjson::JsonValue;
use crate::{parse_any_link, CollectedLink};
···
}
}
+
pub fn walk_drisl(path: &str, v: &DrislValue, found: &mut Vec<CollectedLink>) {
+
match v {
+
DrislValue::Map(o) => {
+
for (key, child) in o {
+
walk_drisl(&format!("{path}.{key}"), child, found)
+
}
+
}
+
DrislValue::Array(a) => {
+
for child in a {
+
let child_p = match child {
+
DrislValue::Map(o) => {
+
if let Some(DrislValue::Text(t)) = o.get("$type") {
+
format!("{path}[{t}]")
+
} else {
+
format!("{path}[]")
+
}
+
}
+
_ => format!("{path}[]"),
+
};
+
walk_drisl(&child_p, child, found)
+
}
+
}
+
DrislValue::Text(s) => {
+
if let Some(link) = parse_any_link(s) {
+
found.push(CollectedLink {
+
path: path.to_string(),
+
target: link,
+
});
+
}
+
}
+
_ => {}
+
}
+
}
+
pub fn collect_links(v: &JsonValue) -> Vec<CollectedLink> {
let mut found = vec![];
walk_record("", v, &mut found);
+
found
+
}
+
+
pub fn collect_links_drisl(v: &DrislValue) -> Vec<CollectedLink> {
+
let mut found = vec![];
+
walk_drisl("", v, &mut found);
found
}
+1
pocket/.gitignore
···
···
+
prefs.sqlite3*
+19
pocket/Cargo.toml
···
···
+
[package]
+
name = "pocket"
+
version = "0.1.0"
+
edition = "2024"
+
+
[dependencies]
+
atrium-crypto = "0.1.2"
+
clap = { version = "4.5.41", features = ["derive"] }
+
jwt-compact = { git = "https://github.com/fatfingers23/jwt-compact.git", features = ["es256k"] }
+
log = "0.4.27"
+
poem = { version = "3.1.12", features = ["acme", "static-files"] }
+
poem-openapi = { version = "5.1.16", features = ["scalar"] }
+
reqwest = { version = "0.12.22", features = ["json"] }
+
rusqlite = "0.37.0"
+
serde = { version = "1.0.219", features = ["derive"] }
+
serde_json = { version = "1.0.141" }
+
thiserror = "2.0.16"
+
tokio = { version = "1.47.0", features = ["full"] }
+
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
+17
pocket/api-description.md
···
···
+
_A pocket dimension to stash a bit of non-public user data._
+
+
+
# Pocket: user preference storage
+
+
This API leverages atproto service proxying to offer a bit of per-user per-app non-public data storage.
+
Perfect for things like application preferences that might be better left out of the public PDS data.
+
+
The intent is to use oauth scopes to isolate storage on a per-application basis, and to allow easy data migration from a community hosted instance to your own if you end up needing that.
+
+
+
### Current status
+
+
> [!important]
+
> Pocket is currently in a **v0, pre-release state**. There is one production instance and you can use it! Expect short downtimes for restarts as development progresses and occaisional data loss until it's stable.
+
+
ATProto might end up adding a similar feature to [PDSs](https://atproto.com/guides/glossary#pds-personal-data-server). If/when that happens, you should use it instead of this!
+7
pocket/src/lib.rs
···
···
+
mod server;
+
mod storage;
+
mod token;
+
+
pub use server::serve;
+
pub use storage::Storage;
+
pub use token::TokenVerifier;
+34
pocket/src/main.rs
···
···
+
use clap::Parser;
+
use pocket::{Storage, serve};
+
use std::path::PathBuf;
+
+
/// Slingshot record edge cache
+
#[derive(Parser, Debug, Clone)]
+
#[command(version, about, long_about = None)]
+
struct Args {
+
/// path to the sqlite db file
+
#[arg(long)]
+
db: Option<PathBuf>,
+
/// just initialize the db and exit
+
#[arg(long, action)]
+
init_db: bool,
+
/// the domain for serving a did doc (unused if running behind reflector)
+
#[arg(long)]
+
domain: Option<String>,
+
}
+
+
#[tokio::main]
+
async fn main() {
+
tracing_subscriber::fmt::init();
+
log::info!("๐Ÿ‘– hi");
+
let args = Args::parse();
+
let domain = args.domain.unwrap_or("bad-example.com".into());
+
let db_path = args.db.unwrap_or("prefs.sqlite3".into());
+
if args.init_db {
+
Storage::init(&db_path).unwrap();
+
log::info!("๐Ÿ‘– initialized db at {db_path:?}. bye")
+
} else {
+
let storage = Storage::connect(db_path).unwrap();
+
serve(&domain, storage).await
+
}
+
}
+265
pocket/src/server.rs
···
···
+
use crate::{Storage, TokenVerifier};
+
use poem::{
+
Endpoint, EndpointExt, Route, Server,
+
endpoint::{StaticFileEndpoint, make_sync},
+
http::Method,
+
listener::TcpListener,
+
middleware::{CatchPanic, Cors, Tracing},
+
};
+
use poem_openapi::{
+
ApiResponse, ContactObject, ExternalDocumentObject, Object, OpenApi, OpenApiService,
+
SecurityScheme, Tags,
+
auth::Bearer,
+
payload::{Json, PlainText},
+
types::Example,
+
};
+
use serde::Serialize;
+
use serde_json::{Value, json};
+
use std::sync::{Arc, Mutex};
+
+
#[derive(Debug, SecurityScheme)]
+
#[oai(ty = "bearer")]
+
struct XrpcAuth(Bearer);
+
+
#[derive(Tags)]
+
enum ApiTags {
+
/// Custom pocket APIs
+
#[oai(rename = "Pocket APIs")]
+
Pocket,
+
}
+
+
#[derive(Object)]
+
#[oai(example = true)]
+
struct XrpcErrorResponseObject {
+
/// Should correspond an error `name` in the lexicon errors array
+
error: String,
+
/// Human-readable description and possibly additonal context
+
message: String,
+
}
+
impl Example for XrpcErrorResponseObject {
+
fn example() -> Self {
+
Self {
+
error: "PreferencesNotFound".to_string(),
+
message: "No preferences were found for this user".to_string(),
+
}
+
}
+
}
+
type XrpcError = Json<XrpcErrorResponseObject>;
+
fn xrpc_error(error: impl AsRef<str>, message: impl AsRef<str>) -> XrpcError {
+
Json(XrpcErrorResponseObject {
+
error: error.as_ref().to_string(),
+
message: message.as_ref().to_string(),
+
})
+
}
+
+
#[derive(Debug, Object)]
+
#[oai(example = true)]
+
struct BskyPrefsObject {
+
/// at-uri for this record
+
preferences: Value,
+
}
+
impl Example for BskyPrefsObject {
+
fn example() -> Self {
+
Self {
+
preferences: json!({
+
"hello": "world",
+
}),
+
}
+
}
+
}
+
+
#[derive(ApiResponse)]
+
enum GetBskyPrefsResponse {
+
/// Record found
+
#[oai(status = 200)]
+
Ok(Json<BskyPrefsObject>),
+
/// Bad request or no preferences to return
+
#[oai(status = 400)]
+
BadRequest(XrpcError),
+
}
+
+
#[derive(ApiResponse)]
+
enum PutBskyPrefsResponse {
+
/// Record found
+
#[oai(status = 200)]
+
Ok(PlainText<String>),
+
/// Bad request or no preferences to return
+
#[oai(status = 400)]
+
BadRequest(XrpcError),
+
// /// Server errors
+
// #[oai(status = 500)]
+
// ServerError(XrpcError),
+
}
+
+
struct Xrpc {
+
verifier: TokenVerifier,
+
storage: Arc<Mutex<Storage>>,
+
}
+
+
#[OpenApi]
+
impl Xrpc {
+
/// com.bad-example.pocket.getPreferences
+
///
+
/// get stored preferencess
+
#[oai(
+
path = "/com.bad-example.pocket.getPreferences",
+
method = "get",
+
tag = "ApiTags::Pocket"
+
)]
+
async fn pocket_get_prefs(&self, XrpcAuth(auth): XrpcAuth) -> GetBskyPrefsResponse {
+
let (did, aud) = match self
+
.verifier
+
.verify("com.bad-example.pocket.getPreferences", &auth.token)
+
.await
+
{
+
Ok(d) => d,
+
Err(e) => return GetBskyPrefsResponse::BadRequest(xrpc_error("boooo", e.to_string())),
+
};
+
log::info!("verified did: {did}/{aud}");
+
+
let storage = self.storage.clone();
+
+
let Ok(Ok(res)) = tokio::task::spawn_blocking(move || {
+
storage
+
.lock()
+
.unwrap()
+
.get(&did, &aud)
+
.inspect_err(|e| log::error!("failed to get prefs: {e}"))
+
})
+
.await
+
else {
+
return GetBskyPrefsResponse::BadRequest(xrpc_error("boooo", "failed to get from db"));
+
};
+
+
let Some(serialized) = res else {
+
return GetBskyPrefsResponse::BadRequest(xrpc_error(
+
"NotFound",
+
"could not find prefs for u",
+
));
+
};
+
+
let preferences = match serde_json::from_str(&serialized) {
+
Ok(v) => v,
+
Err(e) => {
+
log::error!("failed to deserialize prefs: {e}");
+
return GetBskyPrefsResponse::BadRequest(xrpc_error(
+
"boooo",
+
"failed to deserialize prefs",
+
));
+
}
+
};
+
+
GetBskyPrefsResponse::Ok(Json(BskyPrefsObject { preferences }))
+
}
+
+
/// com.bad-example.pocket.putPreferences
+
///
+
/// store bluesky prefs
+
#[oai(
+
path = "/com.bad-example.pocket.putPreferences",
+
method = "post",
+
tag = "ApiTags::Pocket"
+
)]
+
async fn pocket_put_prefs(
+
&self,
+
XrpcAuth(auth): XrpcAuth,
+
Json(prefs): Json<BskyPrefsObject>,
+
) -> PutBskyPrefsResponse {
+
let (did, aud) = match self
+
.verifier
+
.verify("com.bad-example.pocket.putPreferences", &auth.token)
+
.await
+
{
+
Ok(d) => d,
+
Err(e) => return PutBskyPrefsResponse::BadRequest(xrpc_error("boooo", e.to_string())),
+
};
+
log::info!("verified did: {did}/{aud}");
+
log::warn!("received prefs: {prefs:?}");
+
+
let storage = self.storage.clone();
+
let serialized = prefs.preferences.to_string();
+
+
let Ok(Ok(())) = tokio::task::spawn_blocking(move || {
+
storage
+
.lock()
+
.unwrap()
+
.put(&did, &aud, &serialized)
+
.inspect_err(|e| log::error!("failed to insert prefs: {e}"))
+
})
+
.await
+
else {
+
return PutBskyPrefsResponse::BadRequest(xrpc_error("boooo", "failed to put to db"));
+
};
+
+
PutBskyPrefsResponse::Ok(PlainText("saved.".to_string()))
+
}
+
}
+
+
#[derive(Debug, Clone, Serialize)]
+
#[serde(rename_all = "camelCase")]
+
struct AppViewService {
+
id: String,
+
r#type: String,
+
service_endpoint: String,
+
}
+
#[derive(Debug, Clone, Serialize)]
+
struct AppViewDoc {
+
id: String,
+
service: [AppViewService; 2],
+
}
+
/// Serve a did document for did:web for this to be an xrpc appview
+
fn get_did_doc(domain: &str) -> impl Endpoint + use<> {
+
let doc = poem::web::Json(AppViewDoc {
+
id: format!("did:web:{domain}"),
+
service: [
+
AppViewService {
+
id: "#pocket_prefs".to_string(),
+
r#type: "PocketPreferences".to_string(),
+
service_endpoint: format!("https://{domain}"),
+
},
+
AppViewService {
+
id: "#bsky_appview".to_string(),
+
r#type: "BlueskyAppview".to_string(),
+
service_endpoint: format!("https://{domain}"),
+
},
+
],
+
});
+
make_sync(move |_| doc.clone())
+
}
+
+
pub async fn serve(domain: &str, storage: Storage) -> () {
+
let verifier = TokenVerifier::default();
+
let api_service = OpenApiService::new(
+
Xrpc {
+
verifier,
+
storage: Arc::new(Mutex::new(storage)),
+
},
+
"Pocket",
+
env!("CARGO_PKG_VERSION"),
+
)
+
.server(domain)
+
.url_prefix("/xrpc")
+
.contact(
+
ContactObject::new()
+
.name("@microcosm.blue")
+
.url("https://bsky.app/profile/microcosm.blue"),
+
)
+
.description(include_str!("../api-description.md"))
+
.external_document(ExternalDocumentObject::new("https://microcosm.blue/pocket"));
+
+
let app = Route::new()
+
.nest("/openapi", api_service.spec_endpoint())
+
.nest("/xrpc/", api_service)
+
.at("/.well-known/did.json", get_did_doc(domain))
+
.at("/", StaticFileEndpoint::new("./static/index.html"))
+
.with(
+
Cors::new()
+
.allow_method(Method::GET)
+
.allow_method(Method::POST),
+
)
+
.with(CatchPanic::new())
+
.with(Tracing);
+
+
let listener = TcpListener::bind("127.0.0.1:3000");
+
Server::new(listener).name("pocket").run(app).await.unwrap();
+
}
+50
pocket/src/storage.rs
···
···
+
use rusqlite::{Connection, OptionalExtension, Result};
+
use std::path::Path;
+
+
pub struct Storage {
+
con: Connection,
+
}
+
+
impl Storage {
+
pub fn connect(path: impl AsRef<Path>) -> Result<Self> {
+
let con = Connection::open(path)?;
+
con.pragma_update(None, "journal_mode", "WAL")?;
+
con.pragma_update(None, "synchronous", "NORMAL")?;
+
con.pragma_update(None, "busy_timeout", "100")?;
+
con.pragma_update(None, "foreign_keys", "ON")?;
+
Ok(Self { con })
+
}
+
pub fn init(path: impl AsRef<Path>) -> Result<Self> {
+
let me = Self::connect(path)?;
+
me.con.execute(
+
r#"
+
create table prefs (
+
actor text not null,
+
aud text not null,
+
pref text not null,
+
primary key (actor, aud)
+
) strict"#,
+
(),
+
)?;
+
Ok(me)
+
}
+
pub fn put(&self, actor: &str, aud: &str, pref: &str) -> Result<()> {
+
self.con.execute(
+
r#"insert into prefs (actor, aud, pref)
+
values (?1, ?2, ?3)
+
on conflict do update set pref = excluded.pref"#,
+
[actor, aud, pref],
+
)?;
+
Ok(())
+
}
+
pub fn get(&self, actor: &str, aud: &str) -> Result<Option<String>> {
+
self.con
+
.query_one(
+
r#"select pref from prefs
+
where actor = ?1 and aud = ?2"#,
+
[actor, aud],
+
|row| row.get(0),
+
)
+
.optional()
+
}
+
}
+143
pocket/src/token.rs
···
···
+
use atrium_crypto::did::parse_multikey;
+
use atrium_crypto::verify::Verifier;
+
use jwt_compact::UntrustedToken;
+
use serde::Deserialize;
+
use std::collections::HashMap;
+
use std::time::Duration;
+
use thiserror::Error;
+
+
#[derive(Debug, Deserialize)]
+
struct MiniDoc {
+
signing_key: String,
+
did: String,
+
}
+
+
#[derive(Error, Debug)]
+
pub enum VerifyError {
+
#[error("The cross-service authorization token failed verification: {0}")]
+
VerificationFailed(&'static str),
+
#[error("Error trying to resolve the DID to a signing key, retry in a moment: {0}")]
+
ResolutionFailed(&'static str),
+
}
+
+
pub struct TokenVerifier {
+
client: reqwest::Client,
+
}
+
+
impl TokenVerifier {
+
pub fn new() -> Self {
+
let client = reqwest::Client::builder()
+
.user_agent(format!(
+
"microcosm pocket v{} (dev: @bad-example.com)",
+
env!("CARGO_PKG_VERSION")
+
))
+
.no_proxy()
+
.timeout(Duration::from_secs(12)) // slingshot timeout is 10s
+
.build()
+
.unwrap();
+
Self { client }
+
}
+
+
pub async fn verify(
+
&self,
+
expected_lxm: &str,
+
token: &str,
+
) -> Result<(String, String), VerifyError> {
+
let untrusted = UntrustedToken::new(token).unwrap();
+
+
// danger! unfortunately we need to decode the DID from the jwt body before we have a public key to verify the jwt with
+
let Ok(untrusted_claims) =
+
untrusted.deserialize_claims_unchecked::<HashMap<String, String>>()
+
else {
+
return Err(VerifyError::VerificationFailed(
+
"could not deserialize jtw claims",
+
));
+
};
+
+
// get the (untrusted!) claimed DID
+
let Some(untrusted_did) = untrusted_claims.custom.get("iss") else {
+
return Err(VerifyError::VerificationFailed(
+
"jwt must include the user's did in `iss`",
+
));
+
};
+
+
// bail if it's not even a user-ish did
+
if !untrusted_did.starts_with("did:") {
+
return Err(VerifyError::VerificationFailed("iss should be a did"));
+
}
+
if untrusted_did.contains("#") {
+
return Err(VerifyError::VerificationFailed(
+
"iss should be a user did without a service identifier",
+
));
+
}
+
+
let endpoint =
+
"https://slingshot.microcosm.blue/xrpc/com.bad-example.identity.resolveMiniDoc";
+
let doc: MiniDoc = self
+
.client
+
.get(format!("{endpoint}?identifier={untrusted_did}"))
+
.send()
+
.await
+
.map_err(|_| VerifyError::ResolutionFailed("failed to fetch minidoc"))?
+
.error_for_status()
+
.map_err(|_| VerifyError::ResolutionFailed("non-ok response for minidoc"))?
+
.json()
+
.await
+
.map_err(|_| VerifyError::ResolutionFailed("failed to parse json to minidoc"))?;
+
+
// sanity check before we go ahead with this signing key
+
if doc.did != *untrusted_did {
+
return Err(VerifyError::VerificationFailed(
+
"wtf, resolveMiniDoc returned a doc for a different DID, slingshot bug",
+
));
+
}
+
+
let Ok((alg, public_key)) = parse_multikey(&doc.signing_key) else {
+
return Err(VerifyError::VerificationFailed(
+
"could not parse signing key form minidoc",
+
));
+
};
+
+
// i _guess_ we've successfully bootstrapped the verification of the jwt unless this fails
+
if let Err(e) = Verifier::default().verify(
+
alg,
+
&public_key,
+
&untrusted.signed_data,
+
untrusted.signature_bytes(),
+
) {
+
log::warn!("jwt verification failed: {e}");
+
return Err(VerifyError::VerificationFailed(
+
"jwt signature verification failed",
+
));
+
}
+
+
// past this point we're should have established trust. crossing ts and dotting is.
+
let did = &untrusted_did;
+
let claims = &untrusted_claims;
+
+
let Some(aud) = claims.custom.get("aud") else {
+
return Err(VerifyError::VerificationFailed("missing aud"));
+
};
+
let Some(mut aud) = aud.strip_prefix("did:web:") else {
+
return Err(VerifyError::VerificationFailed("expected a did:web aud"));
+
};
+
if let Some((aud_without_hash, _)) = aud.split_once("#") {
+
log::warn!("aud claim is missing service id fragment: {aud:?}");
+
aud = aud_without_hash;
+
}
+
let Some(lxm) = claims.custom.get("lxm") else {
+
return Err(VerifyError::VerificationFailed("missing lxm"));
+
};
+
if lxm != expected_lxm {
+
return Err(VerifyError::VerificationFailed("wrong lxm"));
+
}
+
+
Ok((did.to_string(), aud.to_string()))
+
}
+
}
+
+
impl Default for TokenVerifier {
+
fn default() -> Self {
+
Self::new()
+
}
+
}
+67
pocket/static/index.html
···
···
+
<!doctype html>
+
<html lang="en">
+
<head>
+
<meta charset="utf-8" />
+
<title>Pocket: atproto user preference storage</title>
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
+
<meta name="description" content="API Documentation for Pocket, a simple user-preference storage system for atproto" />
+
<style>
+
:root {
+
--scalar-small: 13px;
+
}
+
.scalar-app .markdown .markdown-alert {
+
font-size: var(--scalar-small);
+
}
+
.sidebar-heading-link-title {
+
line-height: 1.2;
+
}
+
.custom-header {
+
height: 42px;
+
background-color: #221828;
+
box-shadow: inset 0 -1px 0 var(--scalar-border-color);
+
color: var(--scalar-color-1);
+
font-size: var(--scalar-font-size-3);
+
font-family: 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;
+
padding: 0 18px;
+
justify-content: space-between;
+
}
+
.custom-header,
+
.custom-header nav {
+
display: flex;
+
align-items: center;
+
gap: 18px;
+
}
+
.custom-header a:hover {
+
color: var(--scalar-color-2);
+
}
+
+
.light-mode .custom-header {
+
background-color: thistle;
+
}
+
</style>
+
</head>
+
<body>
+
<header class="custom-header scalar-app">
+
<p>
+
TODO: thing
+
</p>
+
<nav>
+
<b>a <a href="https://microcosm.blue">microcosm</a> project</b>
+
<a href="https://bsky.app/profile/microcosm.blue">@microcosm.blue</a>
+
<a href="https://github.com/at-microcosm">github</a>
+
</nav>
+
</header>
+
+
<script id="api-reference" type="application/json" data-url="/openapi"></script>
+
+
<script>
+
var configuration = {
+
theme: 'purple',
+
hideModels: true,
+
}
+
document.getElementById('api-reference').dataset.configuration = JSON.stringify(configuration)
+
</script>
+
+
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
+
</body>
+
</html>
+8
quasar/Cargo.toml
···
···
+
[package]
+
name = "quasar"
+
version = "0.1.0"
+
edition = "2024"
+
+
[dependencies]
+
clap = { version = "4.5.46", features = ["derive"] }
+
fjall = "2.11.2"
+3
quasar/readme.md
···
···
+
# quasar
+
+
indexed replay and fan-out for event stream services (wip)
+3
quasar/src/lib.rs
···
···
+
mod storage;
+
+
pub use storage::Storage;
+3
quasar/src/main.rs
···
···
+
fn main() {
+
println!("Hello, world!");
+
}
+4
quasar/src/storage.rs
···
···
+
+
pub trait Storage {
+
+
}
+57 -129
readme.md
···
-
microcosm: links
-
================
-
-
this repo contains libraries and apps for working with cross-record references in at-protocol.
-
-
App: [Constellation](./constellation/)
-
--------------------------------------------
-
A global atproto backlink index โœจ
-
- Self hostable: handles the full write throughput of the global atproto firehose on a raspberry pi 4b + single SSD
-
- Storage efficient: less than 2GB/day disk consumption indexing all references in all lexicons and all non-atproto URLs
-
- Handles record deletion, account de/re-activation, and account deletion, ensuring accurate link counts and respecting users data choices
-
- Simple JSON API
-
All social interactions in atproto tend to be represented by links (or references) between PDS records. This index can answer questions like "how many likes does a bsky post have", "who follows an account", "what are all the comments on a [frontpage](https://frontpage.fyi/) post", and more.
-
- **status**: works! api is unstable and likely to change, and no known instances have a full network backfill yet.
-
- source: [./constellation/](./constellation/)
-
- public instance: [constellation.microcosm.blue](https://constellation.microcosm.blue/)
-
-
_note: the public instance currently runs on a little raspberry pi in my house, feel free to use it! it comes with only with best-effort uptime, no commitment to not breaking the api for now, and possible rate-limiting. if you want to be nice you can put your project name and bsky username (or email) in your user-agent header for api requests._
-
-
-
App: Spacedust
-
--------------
-
-
A notification subscription service ๐Ÿ’ซ
-
-
using the same "link source" concept as [constellation](./constellation/), offer webhook notifications for new references created to records
-
-
- **status**: in design
-
-
-
Library: [links](./links/)
------------------------------------
-
A rust crate (not published on crates.io yet) for optimistically parsing links out of arbitrary atproto PDS records, and potentially canonicalizing them
-
-
- **status**: unstable, might remain an internal lib for constellation (and spacedust, soon)
-
-
-
-
---
-
-
-
old notes follow, ignore
-
------------------------
-
-
-
as far as i can tell, atproto lexicons today don't follow much of a convention for referencing across documents: sometimes it's a StrongRef, sometimes it's a DID, sometimes it's a bare at-uri. lexicon authors choose any old link-sounding key name for the key in their document.
-
-
it's pretty messy so embrace the mess: atproto wants to be part of the web, so this library will also extract URLs and other URIs if you want it to. all the links.
-
-
-
why
-
---
-
-
the atproto firehose that bluesky sprays at you will contain raw _contents_ from peoples' pdses. these are isolated, decontextualized updates. it's very easy to build some kinds of interesting downstream apps off of this feed.
-
-
- bluesky posts (firesky, deletions, )
-
- blueksy post stats (emojis, )
-
- trending keywords ()
-
-
but bringing almost kind of _context_ into your project requires a big step up in complexity and potentially cost: you're entering "appview" territory. _how many likes does a post have? who follows this account?_
-
-
you own your atproto data: it's kept in your personal data repository (PDS) and noone else can write to it. when someone likes your post, they create a "like" record in their _own_ pds, and that like belongs to _them_, not to you/your post.
-
-
in the firehose you'll see a `app.bsky.feed.post` record created, with no details about who has liked it. then you'll see separate `app.bsky.feed.like` records show up for each like that comes in on that post, with no context about the post except a random-looking reference to it. storing these in order to do so is up to you!
-
-
**so, why**
-
-
everything is links, and they're a mess, but they all kinda work the same, so maybe some tooling can bring down that big step in complexity from firehose raw-content apps -> apps requiring any social context.
-
-
everything is links:
-
-
- likes
-
- follows
-
- blocks
-
- reposts
-
- quotes
-
-
some low-level things you could make from links:
-
-
- notification streams (part of ucosm)
-
- a global reverse index (part of ucosm)
-
-
i think that making these low-level services as easy to use as jetstream could open up pathways for building more atproto apps that operate at full scale with interesting features for reasonable effort at low cost to operate.
-
extracting links
-
---------------
-
- low-level: pass a &str of a field value and get a parsed link back
-
- med-level: pass a &str of record in json form and get a list of parsed links + json paths back. (todo: should also handle dag-cbor prob?)
-
- high-ish level: pass the json record and maybe apply some pre-loaded rules based on known lexicons to get the best result.
-
for now, a link is only considered if it matches for the entire value of the record's field -- links embedded in text content are not included. note that urls in bluesky posts _will_ still be extracted, since they are broken out into facets.
-
resolving / canonicalizing links
-
--------------------------------
-
### at-uris
-
every at-uri has at least two equivalent forms, one with a `DID`, and one with an account handle. the at-uri spec [illustrates this by example](https://atproto.com/specs/at-uri-scheme):
-
- `at://did:plc:44ybard66vv44zksje25o7dz/app.bsky.feed.post/3jwdwj2ctlk26`
-
- `at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26`
-
some applications, like a reverse link index, may wish to canonicalize at-uris to a single form. the `DID`-form is stable as an account changes its handle and probably the right choice to canonicalize to, but maybe some apps would actually perfer to canonicalise to handles?
-
hopefully atrium will make it easy to resolve at-uris.
-
### urls
-
canonicalizing URLs is more annoying but also a bit more established. lots of details.
-
- do we have to deal with punycode?
-
- follow redirects (todo: only permanent ones, or all?)
-
- check for rel=canonical http header and possibly follow it
-
- check link rel=canonical meta tag and possibly follow it
-
- do we need to check site maps??
-
- do we have to care at all about AMP?
-
- do we want anything to do with url shorteners??
-
- how do multilingual sites affect this?
-
- do we have to care about `script type="application/ld+json"` ???
-
ugh. is there a crate for this.
-
### relative uris?
-
-
links might be relative, in which case they might need to be made absolute before being useful. is that a concern for this library, or up to the user? (seems like we might not have context here to determine its absolute)
-
-
-
### canonicalizing
-
-
there should be a few async functions available to canonicalize already-parsed links.
-
-
- what happens if a link can't be resolved?
-
---
-
- using `tinyjson` because it's nice -- maybe should switch to serde_json to share deps with atrium?
-
- would use atrium for parsing at-uris, but it's not in there. there's a did-only version in the non-lib commands.rs. its identifier parser is strict to did + handle, which makes sense, but for our purposes we might want to allow unknown methods too?
-
- rsky-syntax has an aturi
-
- adenosyne also
-
- might come back to these
-
-------
-
rocks
-
```bash
-
ROCKSDB_LIB_DIR=/nix/store/z2chn0hsik0clridr8mlprx1cngh1g3c-rocksdb-9.7.3/lib/ cargo build
-
```
···
+
microcosm HTTP APIs + rust crates
+
=================================
+
[![@microcosm.blue: bluesky](https://img.shields.io/badge/@microcosm.blue-bluesky-blue)](https://bsky.app/profile/microcosm.blue)
+
[![microcosm discord: join](https://img.shields.io/badge/microcosm_discord-join-purple)](https://discord.gg/tcDfe4PGVB)
+
[![github sponsors: support](https://img.shields.io/badge/github_sponsors-support-pink)](https://github.com/sponsors/uniphil/)
+
[![ko-fi: support](https://img.shields.io/badge/ko--fi-support-pink)](https://ko-fi.com/bad_example)
+
Welcome! Documentation is under active development. If you like reading API docs, you'll probably hit the ground running!
+
Tutorials, how-to guides, and client SDK libraries are all in the works for gentler on-ramps, but are not quite ready yet. But don't let that stop you! Hop in the [microcosm discord](https://discord.gg/tcDfe4PGVB), or post questions and tag [@bad-example.com](https://bsky.app/profile/bad-example.com) on Bluesky if you get stuck anywhere.
+
> [!tip]
+
> This repository's primary home is moving to tangled: [@microcosm.blue/microcosm-rs](https://tangled.sh/@microcosm.blue/microcosm-rs). It will continue to be mirrored on [github](https://github.com/at-microcosm/microcosm-rs) for the forseeable future, and it's fine to open issues or pulls in either place!
+
๐ŸŒŒ [Constellation](./constellation/)
------------------------------------
+
A global atproto interactions backlink index as a simple JSON API. Works with every lexicon, runs on a raspberry pi, consumes less than 2GiB of disk per day. Handles record deletion, account de/re-activation, and account deletion, ensuring accurate link counts while respecting users' data choices.
+
- Source: [./constellation/](./constellation/)
+
- [Public instance/API docs](https://constellation.microcosm.blue/)
+
- Status: used in production. APIs will change but backwards compatibility will be maintained as long as needed.
+
๐ŸŽ‡ [Spacedust](./spacedust/)
+
----------------------------
+
A global atproto interactions firehose. Extracts all at-uris, DIDs, and URLs from every lexicon in the firehose, and exposes them over a websocket modelled after [jetstream](github.com/bluesky-social/jetstream).
+
- Source: [./spacedust/](./spacedust/)
+
- [Public instance/API docs](https://spacedust.microcosm.blue/)
+
- Status: v0: the basics work and the APIs are in place! missing cursor replay, forward link storage, and delete event link hydration.
+
### Demos:
+
- [Spacedust notifications](https://notifications.microcosm.blue/): web push notifications for _every_ atproto app
+
- [Zero-Bluesky real-time interaction-updating post embed](https://bsky.bad-example.com/zero-bluesky-realtime-embed/)
+
๐Ÿ›ฐ๏ธ [Slingshot](./slingshot)
+
---------------------------
+
A fast, eager, production-grade edge cache for atproto records and identities. Pre-caches all records from the firehose and maintains a longer-term cache of requested records on disk.
+
- Source: [./slingshot/](./slingshot/)
+
- [Public instance/API docs](https://slingshot.microcosm.blue/)
+
- Status: v0: most XRPC APIs are working. cache storage is being reworked.
+
๐Ÿ›ธ [UFOs API](./ufos)
+
---------------------
+
Timeseries stats and sample records for every [collection](https://atproto.com/guides/glossary#collection) ever seen in the atproto firehose. Unique users are counted in hyperloglog sketches enabling arbitrary cardinality aggregation across time buckets and/or NSIDs.
+
- Source: [./ufos/](./ufos/)
+
- [Public instance/API docs](https://ufos-api.microcosm.blue/)
+
- Status: Used in production. It has APIs and they work! Needs improvement on indexing; needs more indexes and some more APIs to the data exposed.
+
> [!tip]
+
> See also: [UFOs atproto explorer](https://ufos.microcosm.blue/) built on UFOs API. ([source](github.com/at-microcosm/spacedust-utils))
+
๐Ÿ’ซ [Links](./links)
+
-------------------
+
Rust library for parsing and extracting links (at-uris, DIDs, and URLs) from atproto records.
+
- Source: [./links/](./links/)
+
- Status: not yet published to crates.io; needs some rework
+
๐Ÿ›ฉ๏ธ [Jetstream](./jetstream)
+
---------------------------
+
A low-overhead jetstream client with cursor handling and automatic reconnect.
+
- Source: [./links/](./links/)
+
- Status: used in multiple apps in production, but not yet published to crates.io; some rework planned
+
> [!tip]
+
> See also: [Rocketman](https://github.com/teal-fm/cadet/tree/main/rocketman), another excellent rust jetstream client which shares some lineage and _is_ published on crates.io.
+
๐Ÿ”ญ Deprecated: [Who am I](./who-am-i)
+
-------------------------------------
+
An identity bridge for microcosm demos, that kinda worked. Fixing its problems is about equivalent to reinventing a lot of OIDC, so it's being retired.
+
- Source: [./who-am-i/](./who-am-i/)
+
- Status: ready for retirement.
+
> [!warning]
+
> `who-am-i` is still in use for the Spacedust Notifications demo, but that will hopefully be migrated to use atproto oauth directly instead.
+12
reflector/Cargo.toml
···
···
+
[package]
+
name = "reflector"
+
version = "0.1.0"
+
edition = "2024"
+
+
[dependencies]
+
clap = { version = "4.5.47", features = ["derive"] }
+
log = "0.4.28"
+
poem = "3.1.12"
+
serde = { version = "1.0.219", features = ["derive"] }
+
tokio = "1.47.1"
+
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
+9
reflector/readme.md
···
···
+
# reflector
+
+
a tiny did:web service server that maps subdomains to a single service endpoint
+
+
receiving requests from multiple subdomains is left as a problem for the reverse proxy to solve, since acme wildcard certificates (ie. letsencrypt) require the most complicated and involved challenge type (DNS).
+
+
caddy [has good support for](https://caddyserver.com/docs/caddyfile/patterns#wildcard-certificates) configuring the wildcard DNS challenge with various DNS providers, and also supports [on-demand](https://caddyserver.com/docs/automatic-https#using-on-demand-tls) provisioning via the simpler methods.
+
+
if you only need a small fixed number of subdomains, you can also use certbot or otherwise individually configure them in your reverse proxy.
+112
reflector/src/main.rs
···
···
+
use clap::Parser;
+
use poem::{
+
EndpointExt, Response, Route, Server, get, handler,
+
http::StatusCode,
+
listener::TcpListener,
+
middleware::{AddData, Tracing},
+
web::{Data, Json, Query, TypedHeader, headers::Host},
+
};
+
use serde::{Deserialize, Serialize};
+
+
#[handler]
+
fn hello() -> String {
+
"ษนoส‡ษ”วส…โ…Žวษน".to_string()
+
}
+
+
#[derive(Debug, Serialize)]
+
struct DidDoc {
+
id: String,
+
service: [DidService; 1],
+
}
+
+
#[derive(Debug, Clone, Serialize)]
+
#[serde(rename_all = "camelCase")]
+
struct DidService {
+
id: String,
+
r#type: String,
+
service_endpoint: String,
+
}
+
+
#[handler]
+
fn did_doc(TypedHeader(host): TypedHeader<Host>, service: Data<&DidService>) -> Json<DidDoc> {
+
Json(DidDoc {
+
id: format!("did:web:{}", host.hostname()),
+
service: [service.clone()],
+
})
+
}
+
+
#[derive(Deserialize)]
+
struct AskQuery {
+
domain: String,
+
}
+
#[handler]
+
fn ask_caddy(
+
Data(parent): Data<&Option<String>>,
+
Query(AskQuery { domain }): Query<AskQuery>,
+
) -> Response {
+
if let Some(parent) = parent
+
&& let Some(prefix) = domain.strip_suffix(&format!(".{parent}"))
+
&& !prefix.contains('.')
+
{
+
// no sub-sub-domains allowed
+
return Response::builder().body("ok");
+
};
+
Response::builder()
+
.status(StatusCode::FORBIDDEN)
+
.body("nope")
+
}
+
+
/// Slingshot record edge cache
+
#[derive(Parser, Debug, Clone)]
+
#[command(version, about, long_about = None)]
+
struct Args {
+
/// The DID document service ID to serve
+
///
+
/// must start with a '#', like `#bsky_appview'
+
#[arg(long)]
+
id: String,
+
/// Service type
+
///
+
/// Not sure exactly what its requirements are. 'BlueskyAppview' for example
+
#[arg(long)]
+
r#type: String,
+
/// The HTTPS endpoint for the service
+
#[arg(long)]
+
service_endpoint: String,
+
/// The parent domain; requests should come from subdomains of this
+
#[arg(long)]
+
domain: Option<String>,
+
}
+
+
impl From<Args> for DidService {
+
fn from(a: Args) -> Self {
+
Self {
+
id: a.id,
+
r#type: a.r#type,
+
service_endpoint: a.service_endpoint,
+
}
+
}
+
}
+
+
#[tokio::main(flavor = "current_thread")]
+
async fn main() {
+
tracing_subscriber::fmt::init();
+
log::info!("ษนoส‡ษ”วส…โ…Žวษน");
+
+
let args = Args::parse();
+
let domain = args.domain.clone();
+
let service: DidService = args.into();
+
+
Server::new(TcpListener::bind("0.0.0.0:3001"))
+
.run(
+
Route::new()
+
.at("/", get(hello))
+
.at("/.well-known/did.json", get(did_doc))
+
.at("/ask", get(ask_caddy))
+
.with(AddData::new(service))
+
.with(AddData::new(domain))
+
.with(Tracing),
+
)
+
.await
+
.unwrap()
+
}
+6 -5
slingshot/Cargo.toml
···
edition = "2024"
[dependencies]
-
atrium-api = { version = "0.25.4", default-features = false }
-
atrium-common = "0.1.2"
-
atrium-identity = "0.1.5"
-
atrium-oauth = "0.1.3"
clap = { version = "4.5.41", features = ["derive"] }
ctrlc = "3.4.7"
foyer = { version = "0.18.0", features = ["serde"] }
hickory-resolver = "0.25.2"
jetstream = { path = "../jetstream", features = ["metrics"] }
log = "0.4.27"
metrics = "0.24.2"
metrics-exporter-prometheus = { version = "0.17.1", features = ["http-listener"] }
-
poem = { version = "3.1.12", features = ["acme"] }
poem-openapi = { version = "5.1.16", features = ["scalar"] }
reqwest = { version = "0.12.22", features = ["json"] }
rustls = "0.23.31"
···
edition = "2024"
[dependencies]
+
atrium-api = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace", default-features = false }
+
atrium-common = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace" }
+
atrium-identity = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace" }
+
atrium-oauth = { git = "https://github.com/uniphil/atrium.git", branch = "fix/resolve-handle-https-accept-whitespace" }
clap = { version = "4.5.41", features = ["derive"] }
ctrlc = "3.4.7"
foyer = { version = "0.18.0", features = ["serde"] }
hickory-resolver = "0.25.2"
jetstream = { path = "../jetstream", features = ["metrics"] }
+
links = { path = "../links" }
log = "0.4.27"
metrics = "0.24.2"
metrics-exporter-prometheus = { version = "0.17.1", features = ["http-listener"] }
+
poem = { version = "3.1.12", features = ["acme", "static-files"] }
poem-openapi = { version = "5.1.16", features = ["scalar"] }
reqwest = { version = "0.12.22", features = ["json"] }
rustls = "0.23.31"
+93
slingshot/api-description.md
···
···
+
_A [gravitational slingshot](https://en.wikipedia.org/wiki/Gravity_assist) makes use of the gravity and relative movements of celestial bodies to accelerate a spacecraft and change its trajectory._
+
+
+
# Slingshot: edge record cache
+
+
Applications in [ATProtocol](https://atproto.com/) store data in users' own [PDS](https://atproto.com/guides/self-hosting) (Personal Data Server), which are distributed across thousands of independently-run servers all over the world. Trying to access this data poses challenges for client applications:
+
+
- A PDS might be far away with long network latency
+
- or may be on an unreliable connection
+
- or overloaded when you need it, or offline, orโ€ฆ
+
+
Large projects like [Bluesky](https://bsky.app/) control their performance and reliability by syncing all app-relevant data from PDSs into first-party databases. But for new apps, building out this additional data infrastructure adds significant effort and complexity up front.
+
+
**Slingshot is a fast, eager, production-grade cache of data in the [ATmosphere](https://atproto.com/)**, offering performance and reliability without custom infrastructure.
+
+
+
### Current status
+
+
> [!important]
+
> Slingshot is currently in a **v0, pre-release state**. There is one production instance and you can use it! Expect short downtimes for restarts as development progresses and lower cache hit-rates as the internal storage caches are adjusted and reset.
+
+
The core APIs will not change, since they are standard third-party `com.atproto` query APIs from ATProtocol.
+
+
+
## Eager caching
+
+
In many cases, Slingshot can cache the data you need *before* first request!
+
+
Slingshot subscribes to the global [Firehose](https://atproto.com/specs/sync#firehose) of data updates. It keeps a short-term rolling indexed window of *all* data, and automatically promotes content likely to be requested to its longer-term main cache. _(automatic promotion is still a work in progress)_
+
+
When there is a cache miss, Slingshot can often still accelerate record fetching, since it keeps a large cache of resolved identities: it can usually request from the correct PDS without extra lookups.
+
+
+
## Precise invalidation
+
+
The fireshose includes **update** and **delete** events, which Slingshot uses to ensure stale and deleted data is removed within a very short window. Additonally, identity and account-level events can trigger rapid cleanup of data for deactivated and deleted accounts. _(some of this is still a work in progress)_
+
+
+
## Low-trust
+
+
The "AT" in ATProtocol [stands for _Authenticated Transfer_](https://atproto.com/guides/glossary#at-protocol): all data is cryptographically signed, which makes it possible to broadcast data through third parties and trust that it's real _without_ having to directly contact the originating server.
+
+
Two core standard query APIs are supported to balance convenience and trust. They both fetch [records](https://atproto.com/guides/glossary#record):
+
+
### [`com.atproto.repo.getRecord`](#tag/comatproto-queries/get/xrpc/com.atproto.repo.getRecord)
+
+
- convenient `JSON` response format
+
- cannot be proven authentic
+
+
### [`com.atproto.sync.getRecord`](#tag/comatproto-queries/get/xrpc/com.atproto.sync.getRecord)
+
+
- [`DAG-CBOR`](https://atproto.com/specs/data-model)-encoded response requires extra libraries to decode, but
+
- includes a cryptographic proof of authenticity!
+
+
_(work on this endpoint is in progress)_
+
+
+
## Service proxying
+
+
Clients can proxy atproto queries through their own PDS with [Service Proxying](https://atproto.com/specs/xrpc#service-proxying), and this is supported by Slingshot. The Slingshot instance must be started the `--domain` argument specified.
+
+
Service-proxied requests can specify a Slingshot instance via the `atproto-proxy` header:
+
+
```http
+
GET /xrpc/com.bad-example.identity.resolveMiniDoc?identifier=bad-example.com
+
Host: <your pds>
+
atproto-proxy: did:web:<slingshot domain>#slingshot
+
```
+
+
Where `<your pds>` is the user's own PDS host, and `<slingshot domain>` is the domain that the slingshot instance is deployed at (eg. `slingshot.microcosm.blue`). See the [Service Proxying](https://atproto.com/specs/xrpc#service-proxying) docs for more.
+
+
> [!tip]
+
> Service proxying is supported but completely optional. All APIs are directly accessible over the public internet, and GeoDNS helps route users to the closest instance to them for the lowest possible latency. (_note: deploying multiple slingshot instances with GeoDNS is still TODO_)
+
+
+
## Ergonomic APIs
+
+
- Slingshot also offers variants of the `getRecord` endpoints that accept a full `at-uri` as a parameter, to save clients from needing to parse and validate all parts of a record location.
+
+
- Bi-directionally verifying identity endpoints, so you can directly exchange atproto [`handle`](https://atproto.com/guides/glossary#handle)s for [`DID`](https://atproto.com/guides/glossary#did-decentralized-id)s without extra steps, plus a convenient [Mini-Doc](#tag/slingshot-specific-queries/get/xrpc/com.bad-example.identity.resolveMiniDoc) verified identity summary.
+
+
+
## Part of microcosm
+
+
[Microcosm](https://www.microcosm.blue/) is a collection of services and independent community-run infrastructure for ATProtocol.
+
+
Slingshot excels when combined with _shallow indexing_ services, which offer fast queries of global data relationships but with only references to the data records. Microcosm has a few!
+
+
- [๐ŸŒŒ Constellation](https://constellation.microcosm.blue/), a global backlink index (all social interactions in atproto are links!)
+
- [๐ŸŽ‡ Spacedust](https://spacedust.microcosm.blue/), a firehose of all social interactions
+
+
> [!success]
+
> All microcosm projects are [open source](https://tangled.sh/@bad-example.com/microcosm-links). **You can help sustain Slingshot** and all of microcosm by becoming a [Github sponsor](https://github.com/sponsors/uniphil/) or a [Ko-fi supporter](https://ko-fi.com/bad_example)!
+10
slingshot/src/error.rs
···
}
#[derive(Debug, Error)]
pub enum MainTaskError {
#[error(transparent)]
ConsumerTaskError(#[from] ConsumerError),
···
ServerTaskError(#[from] ServerError),
#[error(transparent)]
IdentityTaskError(#[from] IdentityError),
}
#[derive(Debug, Error)]
···
}
#[derive(Debug, Error)]
+
pub enum HealthCheckError {
+
#[error("failed to send checkin: {0}")]
+
HealthCheckError(#[from] reqwest::Error),
+
}
+
+
#[derive(Debug, Error)]
pub enum MainTaskError {
#[error(transparent)]
ConsumerTaskError(#[from] ConsumerError),
···
ServerTaskError(#[from] ServerError),
#[error(transparent)]
IdentityTaskError(#[from] IdentityError),
+
#[error(transparent)]
+
HealthCheckError(#[from] HealthCheckError),
+
#[error("firehose cache failed to close: {0}")]
+
FirehoseCacheCloseError(foyer::Error),
}
#[derive(Debug, Error)]
+5 -1
slingshot/src/firehose_cache.rs
···
.memory(64 * 2_usize.pow(20))
.with_weighter(|k: &String, v| k.len() + std::mem::size_of_val(v))
.storage(Engine::large())
-
.with_device_options(DirectFsDeviceOptions::new(cache_dir))
.build()
.await
.map_err(|e| format!("foyer setup error: {e:?}"))?;
···
.memory(64 * 2_usize.pow(20))
.with_weighter(|k: &String, v| k.len() + std::mem::size_of_val(v))
.storage(Engine::large())
+
.with_device_options(
+
DirectFsDeviceOptions::new(cache_dir)
+
.with_capacity(2_usize.pow(30)) // TODO: configurable (1GB to have something)
+
.with_file_size(16 * 2_usize.pow(20)), // note: this does limit the max cached item size, warning jumbo records
+
)
.build()
.await
.map_err(|e| format!("foyer setup error: {e:?}"))?;
+32
slingshot/src/healthcheck.rs
···
···
+
use crate::error::HealthCheckError;
+
use reqwest::Client;
+
use std::time::Duration;
+
use tokio::time::sleep;
+
use tokio_util::sync::CancellationToken;
+
+
pub async fn healthcheck(
+
endpoint: String,
+
shutdown: CancellationToken,
+
) -> Result<(), HealthCheckError> {
+
let client = Client::builder()
+
.user_agent(format!(
+
"microcosm slingshot v{} (dev: @bad-example.com)",
+
env!("CARGO_PKG_VERSION")
+
))
+
.no_proxy()
+
.timeout(Duration::from_secs(10))
+
.build()?;
+
+
loop {
+
tokio::select! {
+
res = client.get(&endpoint).send() => {
+
let _ = res
+
.and_then(|r| r.error_for_status())
+
.inspect_err(|e| log::error!("failed to send healthcheck: {e}"));
+
},
+
_ = shutdown.cancelled() => break,
+
}
+
sleep(Duration::from_secs(51)).await;
+
}
+
Ok(())
+
}
+27 -12
slingshot/src/identity.rs
···
/// 3. DID -> handle resolution: for bidirectional handle validation and in case we want to offer this
use std::time::Duration;
use tokio::sync::Mutex;
use crate::error::IdentityError;
use atrium_api::{
···
///
/// partial because the handle is not verified
#[derive(Debug, Clone, Serialize, Deserialize)]
-
struct PartialMiniDoc {
/// an atproto handle (**unverified**)
///
/// the first valid atproto handle from the did doc's aka
-
unverified_handle: Handle,
/// the did's atproto pds url (TODO: type this?)
///
/// note: atrium *does* actually parse it into a URI, it just doesn't return
/// that for some reason
-
pds: String,
/// for now we're just pulling this straight from the did doc
///
/// would be nice to type and validate it
···
/// this is the publicKeyMultibase from the did doc.
/// legacy key encoding not supported.
/// `id`, `type`, and `controller` must be checked, but aren't stored.
-
signing_key: String,
}
impl TryFrom<DidDocument> for PartialMiniDoc {
···
.with_name("identity")
.memory(16 * 2_usize.pow(20))
.with_weighter(|k, v| std::mem::size_of_val(k) + std::mem::size_of_val(v))
-
.storage(Engine::large())
-
.with_device_options(DirectFsDeviceOptions::new(cache_dir))
.build()
.await?;
···
Ok(Some(did))
}
-
/// Resolve (and verify!) a DID to a pds url
///
/// This *also* incidentally resolves and verifies the handle, which might
/// make it slower than expected
···
Err(atrium_identity::Error::NotFound) => {
Ok(IdentityVal(UtcDateTime::now(), IdentityData::NotFound))
}
-
Err(other) => Err(foyer::Error::Other(Box::new(
-
IdentityError::ResolutionFailed(other),
-
))),
}
}
})
···
}
/// Fetch (and cache) a partial mini doc from a did
-
async fn did_to_partial_mini_doc(
&self,
did: &Did,
) -> Result<Option<PartialMiniDoc>, IdentityError> {
···
}
/// run the refresh queue consumer
-
pub async fn run_refresher(&self) -> Result<(), IdentityError> {
let _guard = self
.refresher
.try_lock()
.expect("there to only be one refresher running");
loop {
let Some(task_key) = self.peek_refresh().await else {
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
continue;
···
/// 3. DID -> handle resolution: for bidirectional handle validation and in case we want to offer this
use std::time::Duration;
use tokio::sync::Mutex;
+
use tokio_util::sync::CancellationToken;
use crate::error::IdentityError;
use atrium_api::{
···
///
/// partial because the handle is not verified
#[derive(Debug, Clone, Serialize, Deserialize)]
+
pub struct PartialMiniDoc {
/// an atproto handle (**unverified**)
///
/// the first valid atproto handle from the did doc's aka
+
pub unverified_handle: Handle,
/// the did's atproto pds url (TODO: type this?)
///
/// note: atrium *does* actually parse it into a URI, it just doesn't return
/// that for some reason
+
pub pds: String,
/// for now we're just pulling this straight from the did doc
///
/// would be nice to type and validate it
···
/// this is the publicKeyMultibase from the did doc.
/// legacy key encoding not supported.
/// `id`, `type`, and `controller` must be checked, but aren't stored.
+
pub signing_key: String,
}
impl TryFrom<DidDocument> for PartialMiniDoc {
···
.with_name("identity")
.memory(16 * 2_usize.pow(20))
.with_weighter(|k, v| std::mem::size_of_val(k) + std::mem::size_of_val(v))
+
.storage(Engine::small())
+
.with_device_options(
+
DirectFsDeviceOptions::new(cache_dir)
+
.with_capacity(2_usize.pow(30)) // TODO: configurable (1GB to have something)
+
.with_file_size(2_usize.pow(20)), // note: this does limit the max cached item size, warning jumbo records
+
)
.build()
.await?;
···
Ok(Some(did))
}
+
/// Resolve a DID to a pds url
///
/// This *also* incidentally resolves and verifies the handle, which might
/// make it slower than expected
···
Err(atrium_identity::Error::NotFound) => {
Ok(IdentityVal(UtcDateTime::now(), IdentityData::NotFound))
}
+
Err(other) => Err(foyer::Error::Other(Box::new({
+
log::debug!("other error resolving handle: {other:?}");
+
IdentityError::ResolutionFailed(other)
+
}))),
}
}
})
···
}
/// Fetch (and cache) a partial mini doc from a did
+
pub async fn did_to_partial_mini_doc(
&self,
did: &Did,
) -> Result<Option<PartialMiniDoc>, IdentityError> {
···
}
/// run the refresh queue consumer
+
pub async fn run_refresher(&self, shutdown: CancellationToken) -> Result<(), IdentityError> {
let _guard = self
.refresher
.try_lock()
.expect("there to only be one refresher running");
loop {
+
if shutdown.is_cancelled() {
+
log::info!("identity refresher: exiting for shutdown: closing cache...");
+
if let Err(e) = self.cache.close().await {
+
log::error!("cache close errored: {e}");
+
} else {
+
log::info!("identity cache closed.")
+
}
+
return Ok(());
+
}
let Some(task_key) = self.peek_refresh().await else {
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
continue;
+2
slingshot/src/lib.rs
···
mod consumer;
pub mod error;
mod firehose_cache;
mod identity;
mod record;
mod server;
pub use consumer::consume;
pub use firehose_cache::firehose_cache;
pub use identity::Identity;
pub use record::{CachedRecord, ErrorResponseObject, Repo};
pub use server::serve;
···
mod consumer;
pub mod error;
mod firehose_cache;
+
mod healthcheck;
mod identity;
mod record;
mod server;
pub use consumer::consume;
pub use firehose_cache::firehose_cache;
+
pub use healthcheck::healthcheck;
pub use identity::Identity;
pub use record::{CachedRecord, ErrorResponseObject, Repo};
pub use server::serve;
+34 -6
slingshot/src/main.rs
···
// use foyer::HybridCache;
// use foyer::{Engine, DirectFsDeviceOptions, HybridCacheBuilder};
use metrics_exporter_prometheus::PrometheusBuilder;
-
use slingshot::{Identity, Repo, consume, error::MainTaskError, firehose_cache, serve};
use std::path::PathBuf;
use clap::Parser;
···
/// - an HTTPS certs will be automatically configured with Acme/letsencrypt
/// - TODO: a rate-limiter will be installed
#[arg(long)]
-
host: Option<String>,
/// a location to cache acme https certs
///
/// only used if --host is specified. omitting requires re-requesting certs
···
/// recommended in production, but mind the file permissions.
#[arg(long)]
certs: Option<PathBuf>,
}
#[tokio::main]
···
.map_err(|e| format!("identity setup failed: {e:?}"))?;
log::info!("identity service ready.");
let identity_refresher = identity.clone();
tasks.spawn(async move {
-
identity_refresher.run_refresher().await?;
Ok(())
});
···
server_cache_handle,
identity,
repo,
-
args.host,
args.certs,
server_shutdown,
)
···
});
let consumer_shutdown = shutdown.clone();
tasks.spawn(async move {
consume(
args.jetstream,
None,
args.jetstream_no_zstd,
consumer_shutdown,
-
cache,
)
.await?;
Ok(())
});
tokio::select! {
_ = shutdown.cancelled() => log::warn!("shutdown requested"),
Some(r) = tasks.join_next() => {
···
}
}
tokio::select! {
_ = async {
while let Some(completed) = tasks.join_next().await {
log::info!("shutdown: task completed: {completed:?}");
}
} => {},
-
_ = tokio::time::sleep(std::time::Duration::from_secs(3)) => {
log::info!("shutdown: not all tasks completed on time. aborting...");
tasks.shutdown().await;
},
···
// use foyer::HybridCache;
// use foyer::{Engine, DirectFsDeviceOptions, HybridCacheBuilder};
use metrics_exporter_prometheus::PrometheusBuilder;
+
use slingshot::{
+
Identity, Repo, consume, error::MainTaskError, firehose_cache, healthcheck, serve,
+
};
use std::path::PathBuf;
use clap::Parser;
···
/// - an HTTPS certs will be automatically configured with Acme/letsencrypt
/// - TODO: a rate-limiter will be installed
#[arg(long)]
+
domain: Option<String>,
+
/// email address for letsencrypt contact
+
///
+
/// recommended in production, i guess?
+
#[arg(long)]
+
acme_contact: Option<String>,
/// a location to cache acme https certs
///
/// only used if --host is specified. omitting requires re-requesting certs
···
/// recommended in production, but mind the file permissions.
#[arg(long)]
certs: Option<PathBuf>,
+
/// an web address to send healtcheck pings to every ~51s or so
+
#[arg(long)]
+
healthcheck: Option<String>,
}
#[tokio::main]
···
.map_err(|e| format!("identity setup failed: {e:?}"))?;
log::info!("identity service ready.");
let identity_refresher = identity.clone();
+
let identity_shutdown = shutdown.clone();
tasks.spawn(async move {
+
identity_refresher.run_refresher(identity_shutdown).await?;
Ok(())
});
···
server_cache_handle,
identity,
repo,
+
args.domain,
+
args.acme_contact,
args.certs,
server_shutdown,
)
···
});
let consumer_shutdown = shutdown.clone();
+
let consumer_cache = cache.clone();
tasks.spawn(async move {
consume(
args.jetstream,
None,
args.jetstream_no_zstd,
consumer_shutdown,
+
consumer_cache,
)
.await?;
Ok(())
});
+
if let Some(hc) = args.healthcheck {
+
let healthcheck_shutdown = shutdown.clone();
+
tasks.spawn(async move {
+
healthcheck(hc, healthcheck_shutdown).await?;
+
Ok(())
+
});
+
}
+
tokio::select! {
_ = shutdown.cancelled() => log::warn!("shutdown requested"),
Some(r) = tasks.join_next() => {
···
}
}
+
tasks.spawn(async move {
+
cache
+
.close()
+
.await
+
.map_err(MainTaskError::FirehoseCacheCloseError)
+
});
+
tokio::select! {
_ = async {
while let Some(completed) = tasks.join_next().await {
log::info!("shutdown: task completed: {completed:?}");
}
} => {},
+
_ = tokio::time::sleep(std::time::Duration::from_secs(30)) => {
log::info!("shutdown: not all tasks completed on time. aborting...");
tasks.shutdown().await;
},
+426 -46
slingshot/src/server.rs
···
};
use atrium_api::types::string::{Cid, Did, Handle, Nsid, RecordKey};
use foyer::HybridCache;
use serde::Serialize;
use std::path::PathBuf;
use std::str::FromStr;
···
use poem::{
Endpoint, EndpointExt, Route, Server,
-
endpoint::make_sync,
http::Method,
listener::{
Listener, TcpListener,
acme::{AutoCert, LETS_ENCRYPT_PRODUCTION},
},
-
middleware::{Cors, Tracing},
};
use poem_openapi::{
-
ApiResponse, Object, OpenApi, OpenApiService, param::Query, payload::Json, types::Example,
};
fn example_did() -> String {
"did:plc:hdhoaan3xa3jiuq4fg4mefid".to_string()
}
···
fn example_rkey() -> String {
"3lv4ouczo2b2a".to_string()
}
#[derive(Object)]
#[oai(example = true)]
···
})
}
-
fn bad_request_handler(err: poem::Error) -> GetRecordResponse {
GetRecordResponse::BadRequest(Json(XrpcErrorResponseObject {
error: "InvalidRequest".to_string(),
message: format!("Bad request, here's some info that maybe should not be exposed: {err}"),
}))
}
#[derive(Object)]
#[oai(example = true)]
struct FoundRecordResponseObject {
···
impl Example for FoundRecordResponseObject {
fn example() -> Self {
Self {
-
uri: format!(
-
"at://{}/{}/{}",
-
example_did(),
-
example_collection(),
-
example_rkey()
-
),
cid: Some("bafyreialv3mzvvxaoyrfrwoer3xmabbmdchvrbyhayd7bga47qjbycy74e".to_string()),
value: serde_json::json!({
"$type": "app.bsky.feed.like",
···
}
#[derive(ApiResponse)]
-
#[oai(bad_request_handler = "bad_request_handler")]
enum GetRecordResponse {
/// Record found
#[oai(status = 200)]
···
ServerError(XrpcError),
}
struct Xrpc {
cache: HybridCache<String, CachedRecord>,
identity: Identity,
repo: Arc<Repo>,
}
#[OpenApi]
impl Xrpc {
/// com.atproto.repo.getRecord
///
/// Get a single record from a repository. Does not require auth.
///
-
/// See also the [canonical `com.atproto` XRPC documentation](https://docs.bsky.app/docs/api/com-atproto-repo-get-record)
-
/// that this endpoint aims to be compatible with.
-
#[oai(path = "/com.atproto.repo.getRecord", method = "get")]
async fn get_record(
&self,
/// The DID or handle of the repo
···
///
/// If not specified, then return the most recent version.
///
-
/// If specified and a newer version of the record exists, returns 404 not
-
/// found. That is: slingshot only retains the most recent version of a
-
/// record. (TODO: verify bsky behaviour for mismatched/old CID)
Query(cid): Query<Option<String>>,
) -> GetRecordResponse {
let did = match Did::new(repo.clone()) {
Ok(did) => did,
Err(_) => {
···
"repo was not a valid DID or handle",
));
};
-
if let Ok(res) = self.identity.handle_to_did(handle).await {
-
if let Some(did) = res {
-
did
-
} else {
-
return GetRecordResponse::BadRequest(xrpc_error(
-
"InvalidRequest",
-
"Could not resolve handle repo to a DID",
));
}
-
} else {
-
return GetRecordResponse::ServerError(xrpc_error(
-
"ResolutionFailed",
-
"errored while trying to resolve handle to DID",
-
));
}
}
};
···
///
/// - PDS proxying offers a level of client IP anonymity from slingshot
/// - slingshot *may* implement more generous per-user rate-limits for proxied requests in the future
-
fn get_did_doc(host: &str) -> impl Endpoint + use<> {
let doc = poem::web::Json(AppViewDoc {
-
id: format!("did:web:{host}"),
service: [AppViewService {
id: "#slingshot".to_string(),
r#type: "SlingshotRecordProxy".to_string(),
-
service_endpoint: format!("https://{host}"),
}],
});
make_sync(move |_| doc.clone())
···
cache: HybridCache<String, CachedRecord>,
identity: Identity,
repo: Repo,
-
host: Option<String>,
certs: Option<PathBuf>,
-
_shutdown: CancellationToken,
) -> Result<(), ServerError> {
let repo = Arc::new(repo);
let api_service = OpenApiService::new(
···
"Slingshot",
env!("CARGO_PKG_VERSION"),
)
-
.server("http://localhost:3000")
-
.url_prefix("/xrpc");
let mut app = Route::new()
-
.nest("/", api_service.scalar())
-
.nest("/openapi.json", api_service.spec_endpoint())
.nest("/xrpc/", api_service);
-
if let Some(host) = host {
rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.expect("alskfjalksdjf");
-
app = app.at("/.well-known/did.json", get_did_doc(&host));
let mut auto_cert = AutoCert::builder()
.directory_url(LETS_ENCRYPT_PRODUCTION)
-
.domain(&host);
if let Some(certs) = certs {
-
auto_cert = auto_cert.cache_path(certs)
}
let auto_cert = auto_cert.build().map_err(ServerError::AcmeBuildError)?;
-
run(TcpListener::bind("0.0.0.0:443").acme(auto_cert), app).await
} else {
-
run(TcpListener::bind("127.0.0.1:3000"), app).await
}
}
-
async fn run<L>(listener: L, app: Route) -> Result<(), ServerError>
where
L: Listener + 'static,
{
···
.allow_methods([Method::GET])
.allow_credentials(false),
)
.with(Tracing);
Server::new(listener)
.name("slingshot")
-
.run(app)
.await
.map_err(ServerError::ServerExited)
}
···
};
use atrium_api::types::string::{Cid, Did, Handle, Nsid, RecordKey};
use foyer::HybridCache;
+
use links::at_uri::parse_at_uri as normalize_at_uri;
use serde::Serialize;
use std::path::PathBuf;
use std::str::FromStr;
···
use poem::{
Endpoint, EndpointExt, Route, Server,
+
endpoint::{StaticFileEndpoint, make_sync},
http::Method,
listener::{
Listener, TcpListener,
acme::{AutoCert, LETS_ENCRYPT_PRODUCTION},
},
+
middleware::{CatchPanic, Cors, Tracing},
};
use poem_openapi::{
+
ApiResponse, ContactObject, ExternalDocumentObject, Object, OpenApi, OpenApiService, Tags,
+
param::Query, payload::Json, types::Example,
};
+
fn example_handle() -> String {
+
"bad-example.com".to_string()
+
}
fn example_did() -> String {
"did:plc:hdhoaan3xa3jiuq4fg4mefid".to_string()
}
···
fn example_rkey() -> String {
"3lv4ouczo2b2a".to_string()
}
+
fn example_uri() -> String {
+
format!(
+
"at://{}/{}/{}",
+
example_did(),
+
example_collection(),
+
example_rkey()
+
)
+
}
+
fn example_pds() -> String {
+
"https://porcini.us-east.host.bsky.network".to_string()
+
}
+
fn example_signing_key() -> String {
+
"zQ3shpq1g134o7HGDb86CtQFxnHqzx5pZWknrVX2Waum3fF6j".to_string()
+
}
#[derive(Object)]
#[oai(example = true)]
···
})
}
+
fn bad_request_handler_get_record(err: poem::Error) -> GetRecordResponse {
GetRecordResponse::BadRequest(Json(XrpcErrorResponseObject {
error: "InvalidRequest".to_string(),
message: format!("Bad request, here's some info that maybe should not be exposed: {err}"),
}))
}
+
fn bad_request_handler_resolve_mini(err: poem::Error) -> ResolveMiniIDResponse {
+
ResolveMiniIDResponse::BadRequest(Json(XrpcErrorResponseObject {
+
error: "InvalidRequest".to_string(),
+
message: format!("Bad request, here's some info that maybe should not be exposed: {err}"),
+
}))
+
}
+
+
fn bad_request_handler_resolve_handle(err: poem::Error) -> JustDidResponse {
+
JustDidResponse::BadRequest(Json(XrpcErrorResponseObject {
+
error: "InvalidRequest".to_string(),
+
message: format!("Bad request, here's some info that maybe should not be exposed: {err}"),
+
}))
+
}
+
#[derive(Object)]
#[oai(example = true)]
struct FoundRecordResponseObject {
···
impl Example for FoundRecordResponseObject {
fn example() -> Self {
Self {
+
uri: example_uri(),
cid: Some("bafyreialv3mzvvxaoyrfrwoer3xmabbmdchvrbyhayd7bga47qjbycy74e".to_string()),
value: serde_json::json!({
"$type": "app.bsky.feed.like",
···
}
#[derive(ApiResponse)]
+
#[oai(bad_request_handler = "bad_request_handler_get_record")]
enum GetRecordResponse {
/// Record found
#[oai(status = 200)]
···
ServerError(XrpcError),
}
+
#[derive(Object)]
+
#[oai(example = true)]
+
struct MiniDocResponseObject {
+
/// DID, bi-directionally verified if a handle was provided in the query.
+
did: String,
+
/// The validated handle of the account or `handle.invalid` if the handle
+
/// did not bi-directionally match the DID document.
+
handle: String,
+
/// The identity's PDS URL
+
pds: String,
+
/// The atproto signing key publicKeyMultibase
+
///
+
/// Legacy key encoding not supported. the key is returned directly; `id`,
+
/// `type`, and `controller` are omitted.
+
signing_key: String,
+
}
+
impl Example for MiniDocResponseObject {
+
fn example() -> Self {
+
Self {
+
did: example_did(),
+
handle: example_handle(),
+
pds: example_pds(),
+
signing_key: example_signing_key(),
+
}
+
}
+
}
+
+
#[derive(ApiResponse)]
+
#[oai(bad_request_handler = "bad_request_handler_resolve_mini")]
+
enum ResolveMiniIDResponse {
+
/// Identity resolved
+
#[oai(status = 200)]
+
Ok(Json<MiniDocResponseObject>),
+
/// Bad request or identity not resolved
+
#[oai(status = 400)]
+
BadRequest(XrpcError),
+
}
+
+
#[derive(Object)]
+
#[oai(example = true)]
+
struct FoundDidResponseObject {
+
/// the DID, bi-directionally verified if using Slingshot
+
did: String,
+
}
+
impl Example for FoundDidResponseObject {
+
fn example() -> Self {
+
Self { did: example_did() }
+
}
+
}
+
+
#[derive(ApiResponse)]
+
#[oai(bad_request_handler = "bad_request_handler_resolve_handle")]
+
enum JustDidResponse {
+
/// Resolution succeeded
+
#[oai(status = 200)]
+
Ok(Json<FoundDidResponseObject>),
+
/// Bad request, failed to resolve, or failed to verify
+
///
+
/// `error` will be one of `InvalidRequest`, `HandleNotFound`.
+
#[oai(status = 400)]
+
BadRequest(XrpcError),
+
/// Something went wrong trying to complete the request
+
#[oai(status = 500)]
+
ServerError(XrpcError),
+
}
+
struct Xrpc {
cache: HybridCache<String, CachedRecord>,
identity: Identity,
repo: Arc<Repo>,
}
+
#[derive(Tags)]
+
enum ApiTags {
+
/// Core ATProtocol-compatible APIs.
+
///
+
/// > [!tip]
+
/// > Upstream documentation is available at
+
/// > https://docs.bsky.app/docs/category/http-reference
+
///
+
/// These queries are usually executed directly against the PDS containing
+
/// the data being requested. Slingshot offers a caching view of the same
+
/// contents with better expected performance and reliability.
+
#[oai(rename = "com.atproto.* queries")]
+
ComAtproto,
+
/// Additional and improved APIs.
+
///
+
/// These APIs offer small tweaks to the core ATProtocol APIs, with more
+
/// more convenient [request parameters](#tag/slingshot-specific-queries/GET/xrpc/com.bad-example.repo.getUriRecord)
+
/// or [response formats](#tag/slingshot-specific-queries/GET/xrpc/com.bad-example.identity.resolveMiniDoc).
+
///
+
/// > [!important]
+
/// > At the moment, these are namespaced under the `com.bad-example.*` NSID
+
/// > prefix, but as they stabilize they may be migrated to an org namespace
+
/// > like `blue.microcosm.*`. Support for asliasing to `com.bad-example.*`
+
/// > will be maintained as long as it's in use.
+
#[oai(rename = "slingshot-specific queries")]
+
Custom,
+
}
+
#[OpenApi]
impl Xrpc {
/// com.atproto.repo.getRecord
///
/// Get a single record from a repository. Does not require auth.
///
+
/// > [!tip]
+
/// > See also the [canonical `com.atproto` XRPC documentation](https://docs.bsky.app/docs/api/com-atproto-repo-get-record)
+
/// > that this endpoint aims to be compatible with.
+
#[oai(
+
path = "/com.atproto.repo.getRecord",
+
method = "get",
+
tag = "ApiTags::ComAtproto"
+
)]
async fn get_record(
&self,
/// The DID or handle of the repo
···
///
/// If not specified, then return the most recent version.
///
+
/// If a stale `CID` is specified and a newer version of the record
+
/// exists, Slingshot returns a `NotFound` error. That is: Slingshot
+
/// only retains the most recent version of a record.
Query(cid): Query<Option<String>>,
) -> GetRecordResponse {
+
self.get_record_impl(repo, collection, rkey, cid).await
+
}
+
+
/// com.bad-example.repo.getUriRecord
+
///
+
/// Ergonomic complement to [`com.atproto.repo.getRecord`](https://docs.bsky.app/docs/api/com-atproto-repo-get-record)
+
/// which accepts an `at-uri` instead of individual repo/collection/rkey params
+
#[oai(
+
path = "/com.bad-example.repo.getUriRecord",
+
method = "get",
+
tag = "ApiTags::Custom"
+
)]
+
async fn get_uri_record(
+
&self,
+
/// The at-uri of the record
+
///
+
/// The identifier can be a DID or an atproto handle, and the collection
+
/// and rkey segments must be present.
+
#[oai(example = "example_uri")]
+
Query(at_uri): Query<String>,
+
/// Optional: the CID of the version of the record.
+
///
+
/// If not specified, then return the most recent version.
+
///
+
/// > [!tip]
+
/// > If specified and a newer version of the record exists, returns 404 not
+
/// > found. That is: slingshot only retains the most recent version of a
+
/// > record.
+
Query(cid): Query<Option<String>>,
+
) -> GetRecordResponse {
+
let bad_at_uri = || {
+
GetRecordResponse::BadRequest(xrpc_error(
+
"InvalidRequest",
+
"at-uri does not appear to be valid",
+
))
+
};
+
+
let Some(normalized) = normalize_at_uri(&at_uri) else {
+
return bad_at_uri();
+
};
+
+
// TODO: move this to links
+
let Some(rest) = normalized.strip_prefix("at://") else {
+
return bad_at_uri();
+
};
+
let Some((repo, rest)) = rest.split_once('/') else {
+
return bad_at_uri();
+
};
+
let Some((collection, rest)) = rest.split_once('/') else {
+
return bad_at_uri();
+
};
+
let rkey = if let Some((rkey, _rest)) = rest.split_once('?') {
+
rkey
+
} else {
+
rest
+
};
+
+
self.get_record_impl(
+
repo.to_string(),
+
collection.to_string(),
+
rkey.to_string(),
+
cid,
+
)
+
.await
+
}
+
+
/// com.atproto.identity.resolveHandle
+
///
+
/// Resolves an atproto [`handle`](https://atproto.com/guides/glossary#handle)
+
/// (hostname) to a [`DID`](https://atproto.com/guides/glossary#did-decentralized-id).
+
///
+
/// > [!tip]
+
/// > Compatibility note: Slingshot will **always bi-directionally verify
+
/// > against the DID document**, which is optional according to the
+
/// > authoritative lexicon.
+
///
+
/// > [!tip]
+
/// > See the [canonical `com.atproto` XRPC documentation](https://docs.bsky.app/docs/api/com-atproto-identity-resolve-handle)
+
/// > that this endpoint aims to be compatible with.
+
#[oai(
+
path = "/com.atproto.identity.resolveHandle",
+
method = "get",
+
tag = "ApiTags::ComAtproto"
+
)]
+
async fn resolve_handle(
+
&self,
+
/// The handle to resolve.
+
#[oai(example = "example_handle")]
+
Query(handle): Query<String>,
+
) -> JustDidResponse {
+
let Ok(handle) = Handle::new(handle) else {
+
return JustDidResponse::BadRequest(xrpc_error("InvalidRequest", "not a valid handle"));
+
};
+
+
let Ok(alleged_did) = self.identity.handle_to_did(handle.clone()).await else {
+
return JustDidResponse::ServerError(xrpc_error("Failed", "Could not resolve handle"));
+
};
+
+
let Some(alleged_did) = alleged_did else {
+
return JustDidResponse::BadRequest(xrpc_error(
+
"HandleNotFound",
+
"Could not resolve handle to a DID",
+
));
+
};
+
+
let Ok(partial_doc) = self.identity.did_to_partial_mini_doc(&alleged_did).await else {
+
return JustDidResponse::ServerError(xrpc_error("Failed", "Could not fetch DID doc"));
+
};
+
+
let Some(partial_doc) = partial_doc else {
+
return JustDidResponse::BadRequest(xrpc_error(
+
"HandleNotFound",
+
"Resolved handle but could not find DID doc for the DID",
+
));
+
};
+
+
if partial_doc.unverified_handle != handle {
+
return JustDidResponse::BadRequest(xrpc_error(
+
"HandleNotFound",
+
"Resolved handle failed bi-directional validation",
+
));
+
}
+
+
JustDidResponse::Ok(Json(FoundDidResponseObject {
+
did: alleged_did.to_string(),
+
}))
+
}
+
+
/// com.bad-example.identity.resolveMiniDoc
+
///
+
/// Like [com.atproto.identity.resolveIdentity](https://docs.bsky.app/docs/api/com-atproto-identity-resolve-identity)
+
/// but instead of the full `didDoc` it returns an atproto-relevant subset.
+
#[oai(
+
path = "/com.bad-example.identity.resolveMiniDoc",
+
method = "get",
+
tag = "ApiTags::Custom"
+
)]
+
async fn resolve_mini_id(
+
&self,
+
/// Handle or DID to resolve
+
#[oai(example = "example_handle")]
+
Query(identifier): Query<String>,
+
) -> ResolveMiniIDResponse {
+
let invalid = |reason: &'static str| {
+
ResolveMiniIDResponse::BadRequest(xrpc_error("InvalidRequest", reason))
+
};
+
+
let mut unverified_handle = None;
+
let did = match Did::new(identifier.clone()) {
+
Ok(did) => did,
+
Err(_) => {
+
let Ok(alleged_handle) = Handle::new(identifier) else {
+
return invalid("identifier was not a valid DID or handle");
+
};
+
+
match self.identity.handle_to_did(alleged_handle.clone()).await {
+
Ok(res) => {
+
if let Some(did) = res {
+
// we did it joe
+
unverified_handle = Some(alleged_handle);
+
did
+
} else {
+
return invalid("Could not resolve handle identifier to a DID");
+
}
+
}
+
Err(e) => {
+
log::debug!("failed to resolve handle: {e}");
+
// TODO: ServerError not BadRequest
+
return invalid("errored while trying to resolve handle to DID");
+
}
+
}
+
}
+
};
+
let Ok(partial_doc) = self.identity.did_to_partial_mini_doc(&did).await else {
+
return invalid("failed to get DID doc");
+
};
+
let Some(partial_doc) = partial_doc else {
+
return invalid("failed to find DID doc");
+
};
+
+
// ok so here's where we're at:
+
// โœ… we have a DID
+
// โœ… we have a partial doc
+
// ๐Ÿ”ถ if we have a handle, it's from the `identifier` (user-input)
+
// -> then we just need to compare to the partial doc to confirm
+
// -> else we need to resolve the DID doc's to a handle and check
+
let handle = if let Some(h) = unverified_handle {
+
if h == partial_doc.unverified_handle {
+
h.to_string()
+
} else {
+
"handle.invalid".to_string()
+
}
+
} else {
+
let Ok(handle_did) = self
+
.identity
+
.handle_to_did(partial_doc.unverified_handle.clone())
+
.await
+
else {
+
return invalid("failed to get did doc's handle");
+
};
+
let Some(handle_did) = handle_did else {
+
return invalid("failed to resolve did doc's handle");
+
};
+
if handle_did == did {
+
partial_doc.unverified_handle.to_string()
+
} else {
+
"handle.invalid".to_string()
+
}
+
};
+
+
ResolveMiniIDResponse::Ok(Json(MiniDocResponseObject {
+
did: did.to_string(),
+
handle,
+
pds: partial_doc.pds,
+
signing_key: partial_doc.signing_key,
+
}))
+
}
+
+
async fn get_record_impl(
+
&self,
+
repo: String,
+
collection: String,
+
rkey: String,
+
cid: Option<String>,
+
) -> GetRecordResponse {
let did = match Did::new(repo.clone()) {
Ok(did) => did,
Err(_) => {
···
"repo was not a valid DID or handle",
));
};
+
match self.identity.handle_to_did(handle).await {
+
Ok(res) => {
+
if let Some(did) = res {
+
did
+
} else {
+
return GetRecordResponse::BadRequest(xrpc_error(
+
"InvalidRequest",
+
"Could not resolve handle repo to a DID",
+
));
+
}
+
}
+
Err(e) => {
+
log::debug!("handle resolution failed: {e}");
+
return GetRecordResponse::ServerError(xrpc_error(
+
"ResolutionFailed",
+
"errored while trying to resolve handle to DID",
));
}
}
}
};
···
///
/// - PDS proxying offers a level of client IP anonymity from slingshot
/// - slingshot *may* implement more generous per-user rate-limits for proxied requests in the future
+
fn get_did_doc(domain: &str) -> impl Endpoint + use<> {
let doc = poem::web::Json(AppViewDoc {
+
id: format!("did:web:{domain}"),
service: [AppViewService {
id: "#slingshot".to_string(),
r#type: "SlingshotRecordProxy".to_string(),
+
service_endpoint: format!("https://{domain}"),
}],
});
make_sync(move |_| doc.clone())
···
cache: HybridCache<String, CachedRecord>,
identity: Identity,
repo: Repo,
+
domain: Option<String>,
+
acme_contact: Option<String>,
certs: Option<PathBuf>,
+
shutdown: CancellationToken,
) -> Result<(), ServerError> {
let repo = Arc::new(repo);
let api_service = OpenApiService::new(
···
"Slingshot",
env!("CARGO_PKG_VERSION"),
)
+
.server(if let Some(ref h) = domain {
+
format!("https://{h}")
+
} else {
+
"http://localhost:3000".to_string()
+
})
+
.url_prefix("/xrpc")
+
.contact(
+
ContactObject::new()
+
.name("@microcosm.blue")
+
.url("https://bsky.app/profile/microcosm.blue"),
+
)
+
.description(include_str!("../api-description.md"))
+
.external_document(ExternalDocumentObject::new(
+
"https://microcosm.blue/slingshot",
+
));
let mut app = Route::new()
+
.at("/", StaticFileEndpoint::new("./static/index.html"))
+
.nest("/openapi", api_service.spec_endpoint())
.nest("/xrpc/", api_service);
+
if let Some(domain) = domain {
rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.expect("alskfjalksdjf");
+
app = app.at("/.well-known/did.json", get_did_doc(&domain));
let mut auto_cert = AutoCert::builder()
.directory_url(LETS_ENCRYPT_PRODUCTION)
+
.domain(&domain);
+
if let Some(contact) = acme_contact {
+
auto_cert = auto_cert.contact(contact);
+
}
if let Some(certs) = certs {
+
auto_cert = auto_cert.cache_path(certs);
}
let auto_cert = auto_cert.build().map_err(ServerError::AcmeBuildError)?;
+
run(
+
TcpListener::bind("0.0.0.0:443").acme(auto_cert),
+
app,
+
shutdown,
+
)
+
.await
} else {
+
run(TcpListener::bind("127.0.0.1:3000"), app, shutdown).await
}
}
+
async fn run<L>(listener: L, app: Route, shutdown: CancellationToken) -> Result<(), ServerError>
where
L: Listener + 'static,
{
···
.allow_methods([Method::GET])
.allow_credentials(false),
)
+
.with(CatchPanic::new())
.with(Tracing);
Server::new(listener)
.name("slingshot")
+
.run_with_graceful_shutdown(app, shutdown.cancelled(), None)
.await
.map_err(ServerError::ServerExited)
+
.inspect(|()| log::info!("server ended. goodbye."))
}
+67
slingshot/static/index.html
···
···
+
<!doctype html>
+
<html lang="en">
+
<head>
+
<meta charset="utf-8" />
+
<title>Slingshot: atproto edge record cache</title>
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
+
<meta name="description" content="API Documentation for Slingshot, a firehose-listening atproto edge record and identity cache." />
+
<style>
+
:root {
+
--scalar-small: 13px;
+
}
+
.scalar-app .markdown .markdown-alert {
+
font-size: var(--scalar-small);
+
}
+
.sidebar-heading-link-title {
+
line-height: 1.2;
+
}
+
.custom-header {
+
height: 42px;
+
background-color: #221828;
+
box-shadow: inset 0 -1px 0 var(--scalar-border-color);
+
color: var(--scalar-color-1);
+
font-size: var(--scalar-font-size-3);
+
font-family: 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;
+
padding: 0 18px;
+
justify-content: space-between;
+
}
+
.custom-header,
+
.custom-header nav {
+
display: flex;
+
align-items: center;
+
gap: 18px;
+
}
+
.custom-header a:hover {
+
color: var(--scalar-color-2);
+
}
+
+
.light-mode .custom-header {
+
background-color: thistle;
+
}
+
</style>
+
</head>
+
<body>
+
<header class="custom-header scalar-app">
+
<p>
+
TODO: thing
+
</p>
+
<nav>
+
<b>a <a href="https://microcosm.blue">microcosm</a> project</b>
+
<a href="https://bsky.app/profile/microcosm.blue">@microcosm.blue</a>
+
<a href="https://github.com/at-microcosm">github</a>
+
</nav>
+
</header>
+
+
<script id="api-reference" type="application/json" data-url="/openapi"></script>
+
+
<script>
+
var configuration = {
+
theme: 'purple',
+
hideModels: true,
+
}
+
document.getElementById('api-reference').dataset.configuration = JSON.stringify(configuration)
+
</script>
+
+
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
+
</body>
+
</html>
+8
spacedust/Cargo.toml
···
edition = "2024"
[dependencies]
async-trait = "0.1.88"
clap = { version = "4.5.40", features = ["derive"] }
ctrlc = "3.4.7"
dropshot = "0.16.2"
env_logger = "0.11.8"
futures = "0.3.31"
http = "1.3.1"
jetstream = { path = "../jetstream", features = ["metrics"] }
links = { path = "../links" }
log = "0.4.27"
metrics = "0.24.2"
metrics-exporter-prometheus = { version = "0.17.1", features = ["http-listener"] }
rand = "0.9.1"
schemars = "0.8.22"
semver = "1.0.26"
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
serde_qs = "1.0.0-rc.3"
thiserror = "2.0.12"
···
edition = "2024"
[dependencies]
+
anyhow = "1.0.100"
+
async-channel = "2.5.0"
async-trait = "0.1.88"
clap = { version = "4.5.40", features = ["derive"] }
ctrlc = "3.4.7"
+
dasl = "0.2.0"
dropshot = "0.16.2"
env_logger = "0.11.8"
+
fjall = "3.0.0-pre.0"
futures = "0.3.31"
http = "1.3.1"
+
ipld-core = { version = "0.4.2", features = ["serde"] }
jetstream = { path = "../jetstream", features = ["metrics"] }
links = { path = "../links" }
log = "0.4.27"
metrics = "0.24.2"
metrics-exporter-prometheus = { version = "0.17.1", features = ["http-listener"] }
rand = "0.9.1"
+
repo-stream = "0.2.2"
+
reqwest = { version = "0.12.24", features = ["json", "stream"] }
schemars = "0.8.22"
semver = "1.0.26"
serde = { version = "1.0.219", features = ["derive"] }
+
serde_ipld_dagcbor = "0.6.4"
serde_json = "1.0.140"
serde_qs = "1.0.0-rc.3"
thiserror = "2.0.12"
+21
spacedust/src/bin/import_car_file.rs
···
···
+
use clap::Parser;
+
use std::path::PathBuf;
+
+
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
+
+
#[derive(Debug, Parser)]
+
struct Args {
+
#[arg()]
+
file: PathBuf,
+
}
+
+
#[tokio::main]
+
async fn main() -> Result<()> {
+
env_logger::init();
+
+
let Args { file } = Args::parse();
+
+
let _reader = tokio::fs::File::open(file).await?;
+
+
Ok(())
+
}
+258
spacedust/src/bin/import_scraped.rs
···
···
+
use clap::Parser;
+
use links::CollectedLink;
+
use repo_stream::{
+
DiskBuilder, DiskStore, Driver, DriverBuilder, Processable, drive::DriverBuilderWithProcessor,
+
drive::NeedDisk,
+
};
+
use std::path::PathBuf;
+
use std::sync::{
+
Arc,
+
atomic::{AtomicUsize, Ordering},
+
};
+
use tokio::{io::AsyncRead, task::JoinSet};
+
+
type Result<T> = anyhow::Result<T>; //std::result::Result<T, Box<dyn std::error::Error>>;
+
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+
struct CollectedProcessed(CollectedLink);
+
+
impl Processable for CollectedProcessed {
+
fn get_size(&self) -> usize {
+
self.0.path.capacity() + self.0.target.as_str().len()
+
}
+
}
+
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+
struct ErrString(String);
+
+
impl Processable for ErrString {
+
fn get_size(&self) -> usize {
+
self.0.capacity()
+
}
+
}
+
+
type Processed = std::result::Result<Vec<CollectedProcessed>, ErrString>;
+
+
/// hacky for now: put errors in strings ๐Ÿคทโ€โ™€๏ธ
+
fn process(block: Vec<u8>) -> Processed {
+
let value: dasl::drisl::Value = dasl::drisl::from_slice(&block)
+
.map_err(|e| ErrString(format!("failed to parse block with drisl: {e:?}")))?;
+
let links = links::record::collect_links_drisl(&value)
+
.into_iter()
+
.map(CollectedProcessed)
+
.collect();
+
Ok(links)
+
}
+
+
#[derive(Debug, Parser)]
+
struct Args {
+
#[arg(long)]
+
cars_folder: PathBuf,
+
#[arg(long)]
+
mem_workers: usize,
+
#[arg(long)]
+
disk_workers: usize,
+
#[arg(long)]
+
disk_folder: PathBuf,
+
}
+
+
async fn get_cars(
+
cars_folder: PathBuf,
+
tx: async_channel::Sender<tokio::io::BufReader<tokio::fs::File>>,
+
) -> Result<()> {
+
let mut dir = tokio::fs::read_dir(cars_folder).await?;
+
while let Some(entry) = dir.next_entry().await? {
+
if !entry.file_type().await?.is_file() {
+
continue;
+
}
+
let reader = tokio::fs::File::open(&entry.path()).await?;
+
let reader = tokio::io::BufReader::new(reader);
+
tx.send(reader).await?;
+
}
+
Ok(())
+
}
+
+
async fn drive_mem<R: AsyncRead + Unpin + Send + Sync + 'static>(
+
f: R,
+
builder: &DriverBuilderWithProcessor<Processed>,
+
disk_tx: &async_channel::Sender<NeedDisk<R, Processed>>,
+
) -> Result<Option<(usize, usize)>> {
+
let mut n = 0;
+
let mut n_records = 0;
+
match builder.load_car(f).await? {
+
Driver::Memory(_commit, mut driver) => {
+
while let Some(chunk) = driver.next_chunk(512).await? {
+
n_records += chunk.len();
+
for (_key, links) in chunk {
+
match links {
+
Ok(links) => n += links.len(),
+
Err(e) => eprintln!("wat: {e:?}"),
+
}
+
}
+
}
+
Ok(Some((n, n_records)))
+
}
+
Driver::Disk(need_disk) => {
+
disk_tx.send(need_disk).await?;
+
Ok(None)
+
}
+
}
+
}
+
+
async fn mem_worker<R: AsyncRead + Unpin + Send + Sync + 'static>(
+
car_rx: async_channel::Receiver<R>,
+
disk_tx: async_channel::Sender<NeedDisk<R, Processed>>,
+
n: Arc<AtomicUsize>,
+
n_records: Arc<AtomicUsize>,
+
) -> Result<()> {
+
let builder = DriverBuilder::new()
+
.with_block_processor(process) // don't care just counting records
+
.with_mem_limit_mb(128);
+
while let Ok(f) = car_rx.recv().await {
+
let driven = match drive_mem(f, &builder, &disk_tx).await {
+
Ok(d) => d,
+
Err(e) => {
+
eprintln!("failed to drive mem: {e:?}. skipping...");
+
continue;
+
}
+
};
+
if let Some((drove, recs)) = driven {
+
n.fetch_add(drove, Ordering::Relaxed);
+
n_records.fetch_add(recs, Ordering::Relaxed);
+
}
+
}
+
Ok(())
+
}
+
+
async fn drive_disk<R: AsyncRead + Unpin>(
+
needed: NeedDisk<R, Processed>,
+
store: DiskStore,
+
) -> Result<(usize, usize, DiskStore)> {
+
let (_commit, mut driver) = needed.finish_loading(store).await?;
+
let mut n = 0;
+
let mut n_records = 0;
+
while let Some(chunk) = driver.next_chunk(512).await? {
+
n_records += chunk.len();
+
for (_key, links) in chunk {
+
match links {
+
Ok(links) => n += links.len(),
+
Err(e) => eprintln!("wat: {e:?}"),
+
}
+
}
+
}
+
let store = driver.reset_store().await?;
+
Ok((n, n_records, store))
+
}
+
+
async fn disk_worker<R: AsyncRead + Unpin>(
+
worker_id: usize,
+
disk_rx: async_channel::Receiver<NeedDisk<R, Processed>>,
+
folder: PathBuf,
+
n: Arc<AtomicUsize>,
+
n_records: Arc<AtomicUsize>,
+
disk_workers_active: Arc<AtomicUsize>,
+
) -> Result<()> {
+
let mut file = folder;
+
file.push(format!("disk-worker-{worker_id}.sqlite"));
+
let builder = DiskBuilder::new().with_cache_size_mb(128);
+
let mut store = builder.open(file.clone()).await?;
+
while let Ok(needed) = disk_rx.recv().await {
+
let active = disk_workers_active.fetch_add(1, Ordering::AcqRel);
+
println!("-> disk workers active: {}", active + 1);
+
let (drove, records) = match drive_disk(needed, store).await {
+
Ok((d, r, s)) => {
+
store = s;
+
(d, r)
+
}
+
Err(e) => {
+
eprintln!("failed to drive disk: {e:?}. skipping...");
+
store = builder.open(file.clone()).await?;
+
continue;
+
}
+
};
+
n.fetch_add(drove, Ordering::Relaxed);
+
n_records.fetch_add(records, Ordering::Relaxed);
+
let were_active = disk_workers_active.fetch_sub(1, Ordering::AcqRel);
+
println!("<- disk workers active: {}", were_active - 1);
+
}
+
Ok(())
+
}
+
+
#[tokio::main]
+
async fn main() -> Result<()> {
+
env_logger::init();
+
+
let Args {
+
cars_folder,
+
disk_folder,
+
disk_workers,
+
mem_workers,
+
} = Args::parse();
+
+
let mut set = JoinSet::<Result<()>>::new();
+
+
let (cars_tx, cars_rx) = async_channel::bounded(2);
+
set.spawn(get_cars(cars_folder, cars_tx));
+
+
let n: Arc<AtomicUsize> = Arc::new(0.into());
+
let n_records: Arc<AtomicUsize> = Arc::new(0.into());
+
let disk_workers_active: Arc<AtomicUsize> = Arc::new(0.into());
+
+
set.spawn({
+
let n = n.clone();
+
let n_records = n_records.clone();
+
let mut interval = tokio::time::interval(std::time::Duration::from_secs(10));
+
async move {
+
let mut last_n = n.load(Ordering::Relaxed);
+
let mut last_n_records = n.load(Ordering::Relaxed);
+
loop {
+
interval.tick().await;
+
let n = n.load(Ordering::Relaxed);
+
let n_records = n_records.load(Ordering::Relaxed);
+
let diff_n = n - last_n;
+
let diff_records = n_records - last_n_records;
+
println!("rate: {} rec/sec; {} n/sec", diff_records / 10, diff_n / 10);
+
if n_records > 0 && diff_records == 0 {
+
println!("zero encountered, stopping rate calculation polling.");
+
break Ok(());
+
}
+
last_n = n;
+
last_n_records = n_records;
+
}
+
}
+
});
+
+
let (needs_disk_tx, needs_disk_rx) = async_channel::bounded(disk_workers);
+
+
for _ in 0..mem_workers {
+
set.spawn(mem_worker(
+
cars_rx.clone(),
+
needs_disk_tx.clone(),
+
n.clone(),
+
n_records.clone(),
+
));
+
}
+
drop(cars_rx);
+
drop(needs_disk_tx);
+
+
tokio::fs::create_dir_all(disk_folder.clone()).await?;
+
for id in 0..disk_workers {
+
set.spawn(disk_worker(
+
id,
+
needs_disk_rx.clone(),
+
disk_folder.clone(),
+
n.clone(),
+
n_records.clone(),
+
disk_workers_active.clone(),
+
));
+
}
+
drop(needs_disk_rx);
+
+
while let Some(res) = set.join_next().await {
+
println!("task from set joined: {res:?}");
+
}
+
+
eprintln!("total records processed: {n_records:?}; total n: {n:?}");
+
+
Ok(())
+
}
+137
spacedust/src/bin/scrape_pds.rs
···
···
+
use clap::Parser;
+
use reqwest::Url;
+
use serde::Deserialize;
+
use std::path::PathBuf;
+
use tokio::io::AsyncWriteExt;
+
use tokio::{sync::mpsc, time};
+
+
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
+
+
use futures::StreamExt;
+
+
#[derive(Debug, Parser)]
+
struct Args {
+
#[arg(long)]
+
pds: Url,
+
#[arg(long)]
+
throttle_ms: u64, // 100ms per pds?
+
#[arg(long)]
+
folder: PathBuf,
+
}
+
+
async fn download_repo(
+
client: &reqwest::Client,
+
mut pds: Url,
+
did: String,
+
mut path: PathBuf,
+
) -> Result<()> {
+
path.push(format!("{did}.car"));
+
let f = tokio::fs::File::create(path).await?;
+
let mut w = tokio::io::BufWriter::new(f);
+
+
pds.set_path("/xrpc/com.atproto.sync.getRepo");
+
pds.set_query(Some(&format!("did={did}")));
+
let mut byte_stream = client.get(pds).send().await?.bytes_stream();
+
+
while let Some(stuff) = byte_stream.next().await {
+
tokio::io::copy(&mut stuff?.as_ref(), &mut w).await?;
+
}
+
w.flush().await?;
+
+
Ok(())
+
}
+
+
#[derive(Debug, Deserialize)]
+
struct RepoInfo {
+
did: String,
+
active: bool,
+
}
+
+
#[derive(Debug, Deserialize)]
+
struct ListReposResponse {
+
cursor: Option<String>,
+
repos: Vec<RepoInfo>,
+
}
+
+
fn get_pds_dids(client: reqwest::Client, mut pds: Url) -> mpsc::Receiver<String> {
+
let (tx, rx) = mpsc::channel(2);
+
tokio::task::spawn(async move {
+
pds.set_path("/xrpc/com.atproto.sync.listRepos");
+
let mut cursor = None;
+
+
loop {
+
if let Some(c) = cursor {
+
pds.set_query(Some(&format!("cursor={c}")));
+
}
+
let res: ListReposResponse = client
+
.get(pds.clone())
+
.send()
+
.await
+
.expect("to send request")
+
.error_for_status()
+
.expect("to be ok")
+
.json()
+
.await
+
.expect("json response");
+
for repo in res.repos {
+
if repo.active {
+
tx.send(repo.did)
+
.await
+
.expect("to be able to send on the channel");
+
}
+
}
+
cursor = res.cursor;
+
if cursor.is_none() {
+
break;
+
}
+
}
+
});
+
rx
+
}
+
+
#[tokio::main]
+
async fn main() -> Result<()> {
+
env_logger::init();
+
+
let Args {
+
pds,
+
throttle_ms,
+
folder,
+
} = Args::parse();
+
+
tokio::fs::create_dir_all(folder.clone()).await?;
+
+
let client = reqwest::Client::builder()
+
.user_agent("microcosm/spacedust-testing")
+
.build()?;
+
+
let mut dids = get_pds_dids(client.clone(), pds.clone());
+
+
let mut interval = time::interval(time::Duration::from_millis(throttle_ms));
+
let mut oks = 0;
+
let mut single_fails = 0;
+
let mut double_fails = 0;
+
+
while let Some(did) = dids.recv().await {
+
interval.tick().await;
+
println!("did: {did:?}");
+
if let Err(e) = download_repo(&client, pds.clone(), did.clone(), folder.clone()).await {
+
single_fails += 1;
+
eprintln!("failed to download repo for did: {did:?}: {e:?}. retrying in a moment...");
+
tokio::time::sleep(time::Duration::from_secs(3)).await;
+
interval.reset();
+
if let Err(e) = download_repo(&client, pds.clone(), did.clone(), folder.clone()).await {
+
double_fails += 1;
+
eprintln!("failed again: {e:?}. moving on in a moment...");
+
tokio::time::sleep(time::Duration::from_secs(1)).await;
+
continue;
+
}
+
}
+
oks += 1;
+
println!(" -> done. did: {did:?}");
+
}
+
+
eprintln!("got {oks} repos. single fails: {single_fails}; doubles: {double_fails}.");
+
+
Ok(())
+
}
+1
spacedust/src/lib.rs
···
pub mod error;
pub mod removable_delay_queue;
pub mod server;
pub mod subscriber;
use jetstream::events::CommitEvent;
···
pub mod error;
pub mod removable_delay_queue;
pub mod server;
+
pub mod storage;
pub mod subscriber;
use jetstream::events::CommitEvent;
spacedust/src/storage/car/drive.rs

This is a binary file and will not be displayed.

+1
spacedust/src/storage/car/mod.rs
···
···
+
spacedust/src/storage/car/walk.rs

This is a binary file and will not be displayed.

+9
spacedust/src/storage/fjall/mod.rs
···
···
+
use crate::storage::Storage;
+
+
pub struct FjallStorage {}
+
+
impl Storage for FjallStorage {
+
fn import_car() {
+
todo!()
+
}
+
}
+6
spacedust/src/storage/mod.rs
···
···
+
pub mod car;
+
pub mod fjall;
+
+
pub trait Storage {
+
fn import_car() {}
+
}
+5 -5
spacedust/src/subscriber.rs
···
loop {
tokio::select! {
l = receiver.recv() => match l {
-
Ok(link) => if self.filter(&link.properties) {
-
if let Err(e) = ws_sender.send(link.message.clone()).await {
-
log::warn!("failed to send link, dropping subscriber: {e:?}");
-
break;
-
}
},
Err(RecvError::Closed) => self.shutdown.cancel(),
Err(RecvError::Lagged(n)) => {
···
loop {
tokio::select! {
l = receiver.recv() => match l {
+
Ok(link) => if self.filter(&link.properties)
+
&& let Err(e) = ws_sender.send(link.message.clone()).await
+
{
+
log::warn!("failed to send link, dropping subscriber: {e:?}");
+
break;
},
Err(RecvError::Closed) => self.shutdown.cancel(),
Err(RecvError::Lagged(n)) => {
+1 -1
ufos/Cargo.toml
···
clap = { version = "4.5.31", features = ["derive"] }
dropshot = "0.16.0"
env_logger = "0.11.7"
-
fjall = { version = "2.8.0", features = ["lz4"] }
getrandom = "0.3.3"
http = "1.3.1"
jetstream = { path = "../jetstream", features = ["metrics"] }
···
clap = { version = "4.5.31", features = ["derive"] }
dropshot = "0.16.0"
env_logger = "0.11.7"
+
fjall = { git = "https://github.com/fjall-rs/fjall.git", features = ["lz4"] }
getrandom = "0.3.3"
http = "1.3.1"
jetstream = { path = "../jetstream", features = ["metrics"] }
+42 -10
ufos/src/main.rs
···
use metrics_exporter_prometheus::PrometheusBuilder;
use std::path::PathBuf;
use std::time::{Duration, SystemTime};
use ufos::consumer;
use ufos::file_consumer;
use ufos::server;
···
Ok(())
}
-
async fn go<B: StoreBackground>(
args: Args,
read_store: impl StoreReader + 'static + Clone,
mut write_store: impl StoreWriter<B> + 'static,
cursor: Option<Cursor>,
sketch_secret: SketchSecretPrefix,
) -> anyhow::Result<()> {
println!("starting server with storage...");
let serving = server::serve(read_store.clone());
if args.pause_writer {
log::info!("not starting jetstream or the write loop.");
-
serving.await.map_err(|e| anyhow::anyhow!(e))?;
return Ok(());
}
···
let rolling = write_store
.background_tasks(args.reroll)?
.run(args.backfill);
-
let consuming = write_store.receive_batches(batches);
-
let stating = do_update_stuff(read_store);
install_metrics_server()?;
-
tokio::select! {
-
z = serving => log::warn!("serve task ended: {z:?}"),
-
z = rolling => log::warn!("rollup task ended: {z:?}"),
-
z = consuming => log::warn!("consuming task ended: {z:?}"),
-
z = stating => log::warn!("status task ended: {z:?}"),
-
};
println!("bye!");
···
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);
loop {
interval.tick().await;
match read_store.get_consumer_info().await {
Err(e) => log::warn!("failed to get jetstream consumer info: {e:?}"),
Ok(ConsumerInfo::Jetstream {
···
use metrics_exporter_prometheus::PrometheusBuilder;
use std::path::PathBuf;
use std::time::{Duration, SystemTime};
+
use tokio::task::JoinSet;
use ufos::consumer;
use ufos::file_consumer;
use ufos::server;
···
Ok(())
}
+
async fn go<B: StoreBackground + 'static>(
args: Args,
read_store: impl StoreReader + 'static + Clone,
mut write_store: impl StoreWriter<B> + 'static,
cursor: Option<Cursor>,
sketch_secret: SketchSecretPrefix,
) -> anyhow::Result<()> {
+
let mut whatever_tasks: JoinSet<anyhow::Result<()>> = JoinSet::new();
+
let mut consumer_tasks: JoinSet<anyhow::Result<()>> = JoinSet::new();
+
println!("starting server with storage...");
let serving = server::serve(read_store.clone());
+
whatever_tasks.spawn(async move {
+
serving.await.map_err(|e| {
+
log::warn!("server ended: {e}");
+
anyhow::anyhow!(e)
+
})
+
});
if args.pause_writer {
log::info!("not starting jetstream or the write loop.");
+
for t in whatever_tasks.join_all().await {
+
if let Err(e) = t {
+
return Err(anyhow::anyhow!(e));
+
}
+
}
return Ok(());
}
···
let rolling = write_store
.background_tasks(args.reroll)?
.run(args.backfill);
+
whatever_tasks.spawn(async move {
+
rolling
+
.await
+
.inspect_err(|e| log::warn!("rollup ended: {e}"))?;
+
Ok(())
+
});
+
consumer_tasks.spawn(async move {
+
write_store
+
.receive_batches(batches)
+
.await
+
.inspect_err(|e| log::warn!("consumer ended: {e}"))?;
+
Ok(())
+
});
+
+
whatever_tasks.spawn(async move {
+
do_update_stuff(read_store).await;
+
log::warn!("status task ended");
+
Ok(())
+
});
install_metrics_server()?;
+
for (i, t) in consumer_tasks.join_all().await.iter().enumerate() {
+
log::warn!("task {i} done: {t:?}");
+
}
+
+
println!("consumer tasks all completed, killing the others");
+
whatever_tasks.shutdown().await;
println!("bye!");
···
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);
loop {
interval.tick().await;
+
read_store.update_metrics();
match read_store.get_consumer_info().await {
Err(e) => log::warn!("failed to get jetstream consumer info: {e:?}"),
Ok(ConsumerInfo::Jetstream {
+11 -1
ufos/src/storage.rs
···
Unit::Microseconds,
"batches that took more than 3s to insert"
);
while let Some(event_batch) = batches.recv().await {
let token = CancellationToken::new();
let cancelled = token.clone();
···
let mut me = self.clone();
move || {
let _guard = token.drop_guard();
-
me.insert_batch(event_batch)
}
})
.await??;
···
#[async_trait]
pub trait StoreReader: Send + Sync {
fn name(&self) -> String;
async fn get_storage_stats(&self) -> StorageResult<serde_json::Value>;
···
Unit::Microseconds,
"batches that took more than 3s to insert"
);
+
describe_histogram!(
+
"storage_batch_insert_time",
+
Unit::Microseconds,
+
"total time to insert one commit batch"
+
);
while let Some(event_batch) = batches.recv().await {
let token = CancellationToken::new();
let cancelled = token.clone();
···
let mut me = self.clone();
move || {
let _guard = token.drop_guard();
+
let t0 = Instant::now();
+
let r = me.insert_batch(event_batch);
+
histogram!("storage_batch_insert_time").record(t0.elapsed().as_micros() as f64);
+
r
}
})
.await??;
···
#[async_trait]
pub trait StoreReader: Send + Sync {
fn name(&self) -> String;
+
+
fn update_metrics(&self) {}
async fn get_storage_stats(&self) -> StorageResult<serde_json::Value>;
+104 -20
ufos/src/storage_fjall.rs
···
Batch as FjallBatch, Config, Keyspace, PartitionCreateOptions, PartitionHandle, Snapshot,
};
use jetstream::events::Cursor;
-
use metrics::{counter, describe_counter, describe_histogram, histogram, Unit};
use std::collections::{HashMap, HashSet};
use std::iter::Peekable;
use std::ops::Bound;
···
feeds: feeds.clone(),
records: records.clone(),
rollups: rollups.clone(),
};
let writer = FjallWriter {
bg_taken: Arc::new(AtomicBool::new(false)),
keyspace,
···
rollups,
queues,
};
Ok((reader, writer, js_cursor, sketch_secret))
}
}
···
feeds: PartitionHandle,
records: PartitionHandle,
rollups: PartitionHandle,
}
/// An iterator that knows how to skip over deleted/invalidated records
···
type CollectionSerieses = HashMap<Nsid, Vec<CountsValue>>;
impl FjallReader {
fn get_storage_stats(&self) -> StorageResult<serde_json::Value> {
let rollup_cursor =
get_static_neu::<NewRollupCursorKey, NewRollupCursorValue>(&self.global)?
···
fn name(&self) -> String {
"fjall storage v2".into()
}
async fn get_storage_stats(&self) -> StorageResult<serde_json::Value> {
let s = self.clone();
tokio::task::spawn_blocking(move || FjallReader::get_storage_stats(&s)).await?
···
}
impl FjallWriter {
fn rollup_delete_account(
&mut self,
cursor: Cursor,
···
AllTimeRecordsKey::new(new_creates_count.into(), &nsid).to_db_bytes()?,
),
};
-
batch.remove(&self.rollups, &old_k); // TODO: when fjall gets weak delete, this will hopefully work way better
batch.insert(&self.rollups, &new_k, "");
}
···
AllTimeDidsKey::new(new_dids_estimate.into(), &nsid).to_db_bytes()?,
),
};
-
batch.remove(&self.rollups, &old_k); // TODO: when fjall gets weak delete, this will hopefully work way better
batch.insert(&self.rollups, &new_k, "");
}
···
insert_batch_static_neu::<NewRollupCursorKey>(&mut batch, &self.global, last_cursor)?;
batch.commit()?;
Ok((cursors_advanced, dirty_nsids))
}
···
if self.bg_taken.swap(true, Ordering::SeqCst) {
return Err(StorageError::BackgroundAlreadyStarted);
}
-
describe_histogram!(
-
"storage_trim_dirty_nsids",
-
Unit::Count,
-
"number of NSIDs trimmed"
-
);
-
describe_histogram!(
-
"storage_trim_duration",
-
Unit::Microseconds,
-
"how long it took to trim the dirty NSIDs"
-
);
-
describe_counter!(
-
"storage_trim_removed",
-
Unit::Count,
-
"how many records were removed during trim"
-
);
if reroll {
log::info!("reroll: resetting rollup cursor...");
insert_static_neu::<NewRollupCursorKey>(&self.global, Cursor::from_start())?;
···
latest.to_db_bytes()?,
);
batch.commit()?;
Ok(())
}
···
candidate_new_feed_lower_cursor = Some(feed_key.cursor());
}
-
self.feeds.remove(&location_key_bytes)?;
self.feeds.remove(key_bytes)?;
records_deleted += 1;
}
···
batch.remove(&self.records, key_bytes);
records_deleted += 1;
if batch.len() >= MAX_BATCHED_ACCOUNT_DELETE_RECORDS {
batch.commit()?;
batch = self.keyspace.batch();
}
}
batch.commit()?;
Ok(records_deleted)
}
···
histogram!("storage_trim_dirty_nsids").record(completed.len() as f64);
histogram!("storage_trim_duration").record(dt.as_micros() as f64);
counter!("storage_trim_removed", "dangling" => "true").increment(total_danglers as u64);
-
counter!("storage_trim_removed", "dangling" => "false").increment((total_deleted - total_danglers) as u64);
for c in completed {
dirty_nsids.remove(&c);
}
···
Batch as FjallBatch, Config, Keyspace, PartitionCreateOptions, PartitionHandle, Snapshot,
};
use jetstream::events::Cursor;
+
use lsm_tree::AbstractTree;
+
use metrics::{
+
counter, describe_counter, describe_gauge, describe_histogram, gauge, histogram, Unit,
+
};
use std::collections::{HashMap, HashSet};
use std::iter::Peekable;
use std::ops::Bound;
···
feeds: feeds.clone(),
records: records.clone(),
rollups: rollups.clone(),
+
queues: queues.clone(),
};
+
reader.describe_metrics();
let writer = FjallWriter {
bg_taken: Arc::new(AtomicBool::new(false)),
keyspace,
···
rollups,
queues,
};
+
writer.describe_metrics();
Ok((reader, writer, js_cursor, sketch_secret))
}
}
···
feeds: PartitionHandle,
records: PartitionHandle,
rollups: PartitionHandle,
+
queues: PartitionHandle,
}
/// An iterator that knows how to skip over deleted/invalidated records
···
type CollectionSerieses = HashMap<Nsid, Vec<CountsValue>>;
impl FjallReader {
+
fn describe_metrics(&self) {
+
describe_gauge!(
+
"storage_fjall_l0_run_count",
+
Unit::Count,
+
"number of L0 runs in a partition"
+
);
+
describe_gauge!(
+
"storage_fjall_keyspace_disk_space",
+
Unit::Bytes,
+
"total storage used according to fjall"
+
);
+
describe_gauge!(
+
"storage_fjall_journal_count",
+
Unit::Count,
+
"total keyspace journals according to fjall"
+
);
+
describe_gauge!(
+
"storage_fjall_keyspace_sequence",
+
Unit::Count,
+
"fjall keyspace sequence"
+
);
+
}
+
fn get_storage_stats(&self) -> StorageResult<serde_json::Value> {
let rollup_cursor =
get_static_neu::<NewRollupCursorKey, NewRollupCursorValue>(&self.global)?
···
fn name(&self) -> String {
"fjall storage v2".into()
}
+
fn update_metrics(&self) {
+
gauge!("storage_fjall_l0_run_count", "partition" => "global")
+
.set(self.global.tree.l0_run_count() as f64);
+
gauge!("storage_fjall_l0_run_count", "partition" => "feeds")
+
.set(self.feeds.tree.l0_run_count() as f64);
+
gauge!("storage_fjall_l0_run_count", "partition" => "records")
+
.set(self.records.tree.l0_run_count() as f64);
+
gauge!("storage_fjall_l0_run_count", "partition" => "rollups")
+
.set(self.rollups.tree.l0_run_count() as f64);
+
gauge!("storage_fjall_l0_run_count", "partition" => "queues")
+
.set(self.queues.tree.l0_run_count() as f64);
+
gauge!("storage_fjall_keyspace_disk_space").set(self.keyspace.disk_space() as f64);
+
gauge!("storage_fjall_journal_count").set(self.keyspace.journal_count() as f64);
+
gauge!("storage_fjall_keyspace_sequence").set(self.keyspace.instant() as f64);
+
}
async fn get_storage_stats(&self) -> StorageResult<serde_json::Value> {
let s = self.clone();
tokio::task::spawn_blocking(move || FjallReader::get_storage_stats(&s)).await?
···
}
impl FjallWriter {
+
fn describe_metrics(&self) {
+
describe_histogram!(
+
"storage_insert_batch_db_batch_items",
+
Unit::Count,
+
"how many items are in the fjall batch for batched inserts"
+
);
+
describe_histogram!(
+
"storage_rollup_counts_db_batch_items",
+
Unit::Count,
+
"how many items are in the fjall batch for a timlies rollup"
+
);
+
describe_counter!(
+
"storage_delete_account_partial_commits",
+
Unit::Count,
+
"fjall checkpoint commits for cleaning up accounts with too many records"
+
);
+
describe_counter!(
+
"storage_delete_account_completions",
+
Unit::Count,
+
"total count of account deletes handled"
+
);
+
describe_counter!(
+
"storage_delete_account_records_deleted",
+
Unit::Count,
+
"total records deleted when handling account deletes"
+
);
+
describe_histogram!(
+
"storage_trim_dirty_nsids",
+
Unit::Count,
+
"number of NSIDs trimmed"
+
);
+
describe_histogram!(
+
"storage_trim_duration",
+
Unit::Microseconds,
+
"how long it took to trim the dirty NSIDs"
+
);
+
describe_counter!(
+
"storage_trim_removed",
+
Unit::Count,
+
"how many records were removed during trim"
+
);
+
}
fn rollup_delete_account(
&mut self,
cursor: Cursor,
···
AllTimeRecordsKey::new(new_creates_count.into(), &nsid).to_db_bytes()?,
),
};
+
// remove_weak is allowed here because the secondary ranking index only ever inserts once at a key
+
batch.remove_weak(&self.rollups, &old_k);
batch.insert(&self.rollups, &new_k, "");
}
···
AllTimeDidsKey::new(new_dids_estimate.into(), &nsid).to_db_bytes()?,
),
};
+
// remove_weak is allowed here because the secondary ranking index only ever inserts once at a key
+
batch.remove_weak(&self.rollups, &old_k);
batch.insert(&self.rollups, &new_k, "");
}
···
insert_batch_static_neu::<NewRollupCursorKey>(&mut batch, &self.global, last_cursor)?;
+
histogram!("storage_rollup_counts_db_batch_items").record(batch.len() as f64);
batch.commit()?;
Ok((cursors_advanced, dirty_nsids))
}
···
if self.bg_taken.swap(true, Ordering::SeqCst) {
return Err(StorageError::BackgroundAlreadyStarted);
}
if reroll {
log::info!("reroll: resetting rollup cursor...");
insert_static_neu::<NewRollupCursorKey>(&self.global, Cursor::from_start())?;
···
latest.to_db_bytes()?,
);
+
histogram!("storage_insert_batch_db_batch_items").record(batch.len() as f64);
batch.commit()?;
Ok(())
}
···
candidate_new_feed_lower_cursor = Some(feed_key.cursor());
}
+
self.records.remove(&location_key_bytes)?;
self.feeds.remove(key_bytes)?;
records_deleted += 1;
}
···
batch.remove(&self.records, key_bytes);
records_deleted += 1;
if batch.len() >= MAX_BATCHED_ACCOUNT_DELETE_RECORDS {
+
counter!("storage_delete_account_partial_commits").increment(1);
batch.commit()?;
batch = self.keyspace.batch();
}
}
+
counter!("storage_delete_account_completions").increment(1);
+
counter!("storage_delete_account_records_deleted").increment(records_deleted as u64);
batch.commit()?;
Ok(records_deleted)
}
···
histogram!("storage_trim_dirty_nsids").record(completed.len() as f64);
histogram!("storage_trim_duration").record(dt.as_micros() as f64);
counter!("storage_trim_removed", "dangling" => "true").increment(total_danglers as u64);
+
if total_deleted >= total_danglers {
+
counter!("storage_trim_removed", "dangling" => "false").increment((total_deleted - total_danglers) as u64);
+
} else {
+
// TODO: probably think through what's happening here
+
log::warn!("weird trim case: more danglers than deleted? metric will be missing for dangling=false. deleted={total_deleted} danglers={total_danglers}");
+
}
for c in completed {
dirty_nsids.remove(&c);
}
-196
ufos ops (move to micro-ops).md
···
-
ufos ops
-
-
btrfs snapshots: snapper
-
-
```bash
-
sudo apt install snapper
-
sudo snapper -c ufos-db create-config /mnt/ufos-db
-
-
# edit /etc/snapper/configs/ufos-db
-
# change
-
TIMELINE_MIN_AGE="1800"
-
TIMELINE_LIMIT_HOURLY="10"
-
TIMELINE_LIMIT_DAILY="10"
-
TIMELINE_LIMIT_WEEKLY="0"
-
TIMELINE_LIMIT_MONTHLY="10"
-
TIMELINE_LIMIT_YEARLY="10"
-
# to
-
TIMELINE_MIN_AGE="1800"
-
TIMELINE_LIMIT_HOURLY="22"
-
TIMELINE_LIMIT_DAILY="4"
-
TIMELINE_LIMIT_WEEKLY="0"
-
TIMELINE_LIMIT_MONTHLY="0"
-
TIMELINE_LIMIT_YEARLY="0"
-
```
-
-
this should be enough?
-
-
list snapshots:
-
-
```bash
-
sudo snapper -c ufos-db list
-
```
-
-
systemd
-
-
create file: `/etc/systemd/system/ufos.service`
-
-
```ini
-
[Unit]
-
Description=UFOs-API
-
After=network.target
-
-
[Service]
-
User=pi
-
WorkingDirectory=/home/pi/
-
ExecStart=/home/pi/ufos --jetstream us-west-2 --data /mnt/ufos-db/
-
Environment="RUST_LOG=info"
-
LimitNOFILE=16384
-
Restart=always
-
-
[Install]
-
WantedBy=multi-user.target
-
```
-
-
then
-
-
```bash
-
sudo systemctl daemon-reload
-
sudo systemctl enable ufos
-
sudo systemctl start ufos
-
```
-
-
monitor with
-
-
```bash
-
journalctl -u ufos -f
-
```
-
-
make sure a backup dir exists
-
-
```bash
-
mkdir /home/pi/backup
-
```
-
-
mount the NAS
-
-
```bash
-
sudo mount.cifs "//truenas.local/folks data" /home/pi/backup -o user=phil,uid=pi
-
```
-
-
manual rsync
-
-
```bash
-
sudo rsync -ahP --delete /mnt/ufos-db/.snapshots/1/snapshot/ backup/ufos/
-
```
-
-
backup script sketch
-
-
```bash
-
NUM=$(sudo snapper --csvout -c ufos-db list --type single --columns number | tail -n1)
-
sudo rsync -ahP --delete "/mnt/ufos-db/.snapshots/${NUM}/snapshot/" backup/ufos/
-
```
-
-
just crontab it?
-
-
`sudo crontab -e`
-
```bash
-
0 1/6 * * * rsync -ahP --delete "/mnt/ufos-db/.snapshots/$(sudo snapper --csvout -c ufos-db list --columns number | tail -n1)/snapshot/" backup/ufos/
-
```
-
-
^^ try once initial backup is done
-
-
-
--columns subvolume,number
-
-
subvolume
-
number
-
-
-
-
-
gateway: follow constellation for nginx->prom thing
-
-
config at `/etc/prometheus-nginxlog-exporter.hcl`
-
-
before: `/etc/prometheus-nginxlog-exporter.hcl`
-
-
```hcl
-
listen {
-
port = 4044
-
}
-
-
namespace "nginx" {
-
source = {
-
files = [
-
"/var/log/nginx/constellation-access.log"
-
]
-
}
-
-
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
-
-
labels {
-
app = "constellation"
-
}
-
-
relabel "cache_status" {
-
from = "upstream_cache_status"
-
}
-
}
-
```
-
-
after:
-
-
```hcl
-
listen {
-
port = 4044
-
}
-
-
namespace "constellation" {
-
source = {
-
files = [
-
"/var/log/nginx/constellation-access.log"
-
]
-
}
-
-
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
-
-
labels {
-
app = "constellation"
-
}
-
-
relabel "cache_status" {
-
from = "upstream_cache_status"
-
}
-
-
namespace_label = "vhost"
-
metrics_override = { prefix = "nginx" }
-
}
-
-
namespace "ufos" {
-
source = {
-
files = [
-
"/var/log/nginx/ufos-access.log"
-
]
-
}
-
-
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $upstream_cache_status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\""
-
-
labels {
-
app = "ufos"
-
}
-
-
relabel "cache_status" {
-
from = "upstream_cache_status"
-
}
-
-
namespace_label = "vhost"
-
metrics_override = { prefix = "nginx" }
-
}
-
```
-
-
-
```bash
-
systemctl start prometheus-nginxlog-exporter.service
-
```
-
···
+4 -4
who-am-i/src/server.rs
···
Some(parent_host),
);
}
-
if let Some(ref app) = params.app {
-
if !allowed_hosts.contains(app) {
-
return err("Login is not allowed for this app", false, Some(app));
-
}
}
let parent_origin = url.origin().ascii_serialization();
if parent_origin == "null" {
···
Some(parent_host),
);
}
+
if let Some(ref app) = params.app
+
&& !allowed_hosts.contains(app)
+
{
+
return err("Login is not allowed for this app", false, Some(app));
}
let parent_origin = url.origin().ascii_serialization();
if parent_origin == "null" {