Skip to content

feat(peeringdb): add as_set endpoint (13th table) - #49

Merged
digizeph merged 4 commits into
mainfrom
feat/peeringdb-as-set
Oct 5, 2026
Merged

digizeph merged 4 commits into
mainfrom
feat/peeringdb-as-set

Conversation

@digizeph

@digizeph digizeph commented Oct 5, 2026

Copy link
Copy Markdown
Member

PeeringDB publishes /api/as_set as a single {asn: name} map rather than a list of records, so it cannot ride the shared record-list loader; it was the one table the mirror did not cover. This adds it as the thirteenth table, in the library module and in the pg_inserter loader.

peeringdb module:

  • Peeringdb::as_set keeps the published strings verbatim (a value may hold several space-separated names), with get_as_set(asn) to resolve one ASN; Peeringdb::new() now fetches the extra endpoint, new_networks_only() is unchanged.
  • The parser requires exactly one object in data with integer keys and string values; anything else (empty or multi-element data, non-numeric key, non-string value) fails as a PeeringDB data-source error naming the endpoint, so a changed upstream shape fails loudly instead of parsing to an empty table.

Loader (pg_inserter):

  • New peeringdb.as_set table (asn primary key, one text column, data_as_of/source_revision provenance) inside the existing atomic family refresh. It is the one table without id/record columns because the string value is the payload.
  • Docs (README, crate docs, CHANGELOG) updated to the 13-endpoint count.

Verified locally (cargo 1.97.1): cargo fmt --check; cargo clippy --all-features -- -D warnings; cargo test --all-features; cargo test --no-default-features --features pg-inserter-cli --bin pg_inserter; cargo build --no-default-features --features peeringdb; and the ignored live check test_peeringdb_as_set against the real endpoint (it loads only /as_set).

PeeringDB publishes `/api/as_set` as a single `{asn: name}` map rather than
a list of records, so it needs its own parser; it was the one table the
module did not mirror yet. `Peeringdb::as_set` keeps the published strings
verbatim (a value may hold several space-separated names) and `get_as_set`
resolves one ASN. A response that is not one object with integer keys and
string values fails as a PeeringDB data-source error instead of parsing to
an empty table.

`pg_inserter` publishes the map as `peeringdb.as_set` (asn primary key, one
text column, the usual `data_as_of`/`source_revision` provenance) inside the
existing atomic family refresh. It is the one table without `id`/`record`
columns because the string value is the payload. `Peeringdb::new()` now
issues one more API call; `new_networks_only()` is unchanged.

Verified: cargo fmt --check; cargo clippy --all-features -- -D warnings;
cargo test --all-features; cargo test --no-default-features --features
pg-inserter-cli --bin pg_inserter; cargo build --no-default-features
--features peeringdb; and the ignored live check `test_peeringdb_as_set`
against the real endpoint.
@digizeph
digizeph requested a balanced review from Copilot October 5, 2026 16:04
@digizeph
digizeph requested a balanced review from Copilot and removed request for Copilot October 5, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Documentation incorrectly claims complete API and export coverage despite /api/poc being omitted and PeeringDB export remaining unimplemented.

Review effort: Balanced
Findings: 7 Low severity

Open (7)
What changed in this PR

Adds support for PeeringDB’s /api/as_set map in the library and PostgreSQL loader.

Changes:

  • Adds strict AS-set parsing, storage, access, and tests.
  • Adds the peeringdb.as_set snapshot table.
  • Updates endpoint-count documentation.
File Description
src/​peeringdb/​mod.rs Implements AS-set loading and access.
src/​peeringdb/​client.rs Defines the endpoint URL.
src/​lib.rs Updates crate documentation.
src/​bin/​pg_inserter/​peeringdb.rs Adds PostgreSQL table and serialization.
src/​bin/​pg_inserter/​main.rs Updates command documentation.
README.md Updates endpoint and export documentation.
CHANGELOG.md Records the new endpoint support.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread CHANGELOG.md Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread src/bin/pg_inserter/main.rs Resolved
Comment thread src/bin/pg_inserter/peeringdb.rs Resolved
Comment thread src/lib.rs Resolved
PeeringDB also exposes /api/poc, and the peeringdb/irr/rpki exporters are not yet implemented, so scope every coverage claim to the 13 supported endpoints.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread AGENTS.md
│ ├── countries/ # Country code mappings
│ ├── mrt_collectors/ # BGP collector metadata
│ ├── peeringdb/ # PeeringDB API data (all 12 endpoints)
│ ├── peeringdb/ # PeeringDB API data (all 13 endpoints)
@digizeph
digizeph merged commit 7f15aad into main Oct 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants