Rust

option

Module

[CdnOption]: a balancer option carrying a cache adapter.

Contents

use utopia_cdn::CdnOption;
Rust
pub struct CdnOption

A balancer option that carries a cache adapter, the vendor it talks to, and whether it fronts the platform's own edge network rather than customer-owned custom domains.

Filters read the typed accessors, so a cache::Balancer can narrow its options by provider or edge without string keys.

Rust
use std::sync::Arc;

use utopia_balancer::{Balancer, First};
use utopia_cdn::CdnOption;
use utopia_cdn::cache::Cloudflare;

let mut balancer = Balancer::new(First);
balancer
    .add_option(CdnOption::new(Arc::new(Cloudflare::new("zone", "token")), CdnOption::PROVIDER_CLOUDFLARE, false))
    .add_filter(|option: &CdnOption| !option.is_edge());
assert_eq!(balancer.filtered().len(), 1);
assert_eq!(balancer.filtered()[0].provider(), "cloudflare");
Also implements Debug.