Skip to content

Commit

Permalink
init api lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Oct 4, 2023
1 parent 261a1fb commit 39d373a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
10 changes: 8 additions & 2 deletions crates/symbolicator-js/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl SourceMapService {
let caches = &services.caches;
let shared_cache = services.shared_cache.clone();
let objects = services.objects.clone();
let download_svc = services.downloader.clone();
let download_svc = services.download_svc.clone();
let sourcefiles_cache = services.sourcefiles_cache.clone();

let bundle_index_cache = BundleIndexCache::new(
Expand All @@ -36,7 +36,13 @@ impl SourceMapService {
download_svc.clone(),
);

let api_lookup = todo!();
let in_memory = &services.config.caches.in_memory;
let api_lookup = Arc::new(SentryLookupApi::new(
download_svc.trusted_client.clone(),
download_svc.runtime.clone(),
download_svc.timeouts,
in_memory,
));

Self {
objects,
Expand Down
6 changes: 4 additions & 2 deletions crates/symbolicator-service/src/services/download/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ impl HostDenyList {
/// rate limits and the concurrency it uses.
#[derive(Debug)]
pub struct DownloadService {
runtime: tokio::runtime::Handle,
timeouts: DownloadTimeouts,
pub runtime: tokio::runtime::Handle,
pub timeouts: DownloadTimeouts,
pub trusted_client: reqwest::Client,
sentry: sentry::SentryDownloader,
http: http::HttpDownloader,
s3: s3::S3Downloader,
Expand All @@ -231,6 +232,7 @@ impl DownloadService {
Arc::new(Self {
runtime: runtime.clone(),
timeouts,
trusted_client: trusted_client.clone(),
sentry: sentry::SentryDownloader::new(trusted_client, runtime, timeouts, in_memory),
http: http::HttpDownloader::new(restricted_client.clone(), timeouts),
s3: s3::S3Downloader::new(timeouts, in_memory.s3_client_capacity),
Expand Down
18 changes: 10 additions & 8 deletions crates/symbolicator-service/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,42 @@ pub use self::symbolication::ScrapingConfig;
pub use fetch_file::fetch_file;

pub struct SharedServices {
pub config: Config,
pub caches: Caches,
pub downloader: Arc<DownloadService>,
pub download_svc: Arc<DownloadService>,
pub shared_cache: SharedCacheRef,
pub objects: ObjectsActor,
pub sourcefiles_cache: Arc<SourceFilesCache>,
}

impl SharedServices {
pub fn new(config: &Config, io_pool: tokio::runtime::Handle) -> Result<Self> {
let caches = Caches::from_config(config).context("failed to create local caches")?;
pub fn new(config: Config, io_pool: tokio::runtime::Handle) -> Result<Self> {
let caches = Caches::from_config(&config).context("failed to create local caches")?;
caches
.clear_tmp(config)
.clear_tmp(&config)
.context("failed to clear tmp caches")?;

let downloader = DownloadService::new(config, io_pool.clone());
let download_svc = DownloadService::new(&config, io_pool.clone());

let shared_cache = SharedCacheService::new(config.shared_cache.clone(), io_pool);

let sourcefiles_cache = Arc::new(SourceFilesCache::new(
caches.sourcefiles.clone(),
shared_cache.clone(),
downloader.clone(),
download_svc.clone(),
));

let objects = ObjectsActor::new(
caches.object_meta.clone(),
caches.objects.clone(),
shared_cache.clone(),
downloader.clone(),
download_svc.clone(),
);

Ok(Self {
config,
caches,
downloader,
download_svc,
shared_cache,
objects,
sourcefiles_cache,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl SymbolicationActor {
let caches = &services.caches;
let shared_cache = services.shared_cache.clone();
let objects = services.objects.clone();
let download_svc = services.downloader.clone();
let download_svc = services.download_svc.clone();
let sourcefiles_cache = services.sourcefiles_cache.clone();

let bitcode = BitcodeService::new(
Expand Down

0 comments on commit 39d373a

Please sign in to comment.