Skip to main content

Crate cf_colo_hint

Crate cf_colo_hint 

Source
Expand description

Cloudflare colo (data center) to Durable Objects location hint mapping.

This library provides a mapping from Cloudflare edge locations (colos) to the recommended Durable Objects location hints. This is useful when you need to provide location hints for Durable Objects based on incoming request colos.

§Example

use cf_colo_hint::{Colo, LocationHint};

// Parse a colo from the cf-ray header or request metadata
let colo = Colo::from_code("LAX").expect("unknown colo");

// Get the recommended location hint for Durable Objects
if let Some(hint) = colo.location_hint() {
    println!("Use location hint: {}", hint.as_str());
    // Use hint.as_str() when calling the Durable Objects API
}

// You can also work with location hints directly
let hint = LocationHint::WNam;
assert_eq!(hint.as_str(), "wnam");
assert_eq!(hint.name(), "Western North America");

§Data Sources

The colo data comes from:

  • components.json: Cloudflare status page data with colo names and regions
  • where.durableobjects.live.json: Measured latency data for DO region mapping

Run python3 codegen.py to regenerate the Rust code from updated JSON files.

Enums§

Colo
Cloudflare data center (colo) identifier.
LocationHint
Durable Objects location hint.