Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalidate CDN caches after build #1825

Merged
merged 9 commits into from
Sep 25, 2022
132 changes: 131 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ tokio = { version = "1.0", features = ["rt-multi-thread"] }
futures-util = "0.3.5"
aws-config = "0.48.0"
aws-sdk-s3 = "0.18.0"
aws-sdk-cloudfront = "0.18.0"
aws-smithy-types-convert = { version = "0.48.0", features = ["convert-chrono"] }
http = "0.2.6"
uuid = "1.1.2"

# Data serialization and deserialization
serde = { version = "1.0", features = ["derive"] }
Expand Down Expand Up @@ -114,6 +116,9 @@ rand = "0.8"
mockito = "0.31.0"
test-case = "2.0.0"
fn-error-context = "0.2.0"
aws-smithy-client = { version = "0.48.0", features = ["test-util"]}
aws-smithy-http = "0.48.0"
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }

[build-dependencies]
time = "0.3"
Expand Down
9 changes: 9 additions & 0 deletions src/bin/cratesfyi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::PathBuf;
use std::sync::Arc;

use anyhow::{anyhow, Context as _, Error, Result};
use docs_rs::cdn::CdnBackend;
use docs_rs::db::{self, add_path_into_database, Pool, PoolClient};
use docs_rs::repositories::RepositoryStatsUpdater;
use docs_rs::utils::{
Expand All @@ -16,6 +17,7 @@ use once_cell::sync::OnceCell;
use sentry_log::SentryLogger;
use structopt::StructOpt;
use strum::VariantNames;
use tokio::runtime::Runtime;

fn main() {
let _sentry_guard = if let Ok(sentry_dsn) = env::var("SENTRY_DSN") {
Expand Down Expand Up @@ -558,23 +560,27 @@ enum DeleteSubcommand {
struct BinContext {
build_queue: OnceCell<Arc<BuildQueue>>,
storage: OnceCell<Arc<Storage>>,
cdn: OnceCell<Arc<CdnBackend>>,
config: OnceCell<Arc<Config>>,
pool: OnceCell<Pool>,
metrics: OnceCell<Arc<Metrics>>,
index: OnceCell<Arc<Index>>,
repository_stats_updater: OnceCell<Arc<RepositoryStatsUpdater>>,
runtime: OnceCell<Arc<Runtime>>,
}

impl BinContext {
fn new() -> Self {
Self {
build_queue: OnceCell::new(),
storage: OnceCell::new(),
cdn: OnceCell::new(),
config: OnceCell::new(),
pool: OnceCell::new(),
metrics: OnceCell::new(),
index: OnceCell::new(),
repository_stats_updater: OnceCell::new(),
runtime: OnceCell::new(),
}
}

Expand Down Expand Up @@ -606,9 +612,12 @@ impl Context for BinContext {
self.pool()?,
self.metrics()?,
self.config()?,
self.runtime()?,
)?;
fn cdn(self) -> CdnBackend = CdnBackend::new(&self.config()?, &self.runtime()?);
fn config(self) -> Config = Config::from_env()?;
fn metrics(self) -> Metrics = Metrics::new()?;
fn runtime(self) -> Runtime = Runtime::new()?;
fn index(self) -> Index = {
let config = self.config()?;
let path = config.registry_index_path.clone();
Expand Down
Loading