MCPcopy Create free account
hub / github.com/Firstyear/opensuse-proxy-cache / new

Method new

opensuse-proxy-cache/src/main.rs:85–122  ·  view source on GitHub ↗
(
        capacity: usize,
        content_dir: &Path,
        durable_fs: bool,
        client: reqwest::Client,
        prefetch_tx: Sender<PrefetchReq>,
        boot_origin: Url,
        geoip_db: 

Source from the content-addressed store, hash-verified

83
84impl AppState {
85 pub fn new(
86 capacity: usize,
87 content_dir: &Path,
88 durable_fs: bool,
89 client: reqwest::Client,
90 prefetch_tx: Sender<PrefetchReq>,
91 boot_origin: Url,
92 geoip_db: maxminddb::Reader<&'static [u8; 9853267]>,
93 default_backend_provider: Backend,
94 backends: Vec<Backend>,
95 allowed_countries: BTreeSet<String>,
96 daily_quota: Option<usize>,
97 ) -> std::io::Result<Self> {
98 let cache = Cache::new(
99 capacity,
100 content_dir,
101 durable_fs,
102 default_backend_provider,
103 backends,
104 )?;
105
106 let daily_quota = daily_quota.map(|daily_quota| {
107 Mutex::new(Quota {
108 daily_quota,
109 client_track: Default::default(),
110 })
111 });
112
113 Ok(AppState {
114 cache,
115 client,
116 prefetch_tx,
117 boot_origin,
118 geoip_db,
119 allowed_countries,
120 daily_quota,
121 })
122 }
123}
124
125fn normalise_path(req_path: &str) -> PathBuf {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected