Skip to content

Commit

Permalink
Implementing checking the provider upon startup
Browse files Browse the repository at this point in the history
  • Loading branch information
edmondop committed Oct 21, 2023
1 parent d0e6e63 commit 2b30909
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions arroyo-compiler-service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub async fn main() {
.await
.expect("unable to construct storage provider");

storage.ensure_valid()?;
let last_used = Arc::new(AtomicU64::new(to_millis(SystemTime::now())));

let service = CompileService {
Expand Down
14 changes: 14 additions & 0 deletions arroyo-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ impl StorageProvider {
Self::get_url_with_options(url, HashMap::new()).await
}

pub async fn ensure_valid(storage: &Self) -> Result<(), StorageError> {
let url = match &storage.config {
BackendConfig::S3(_cfg) => "s3://non-existent-bucket/fake_dir",
BackendConfig::GCS(_cfg) => "gs://non-existent-bucket/fake_dir",
BackendConfig::Local(_cfg) => "/usr/bin/non-existing-file",
};
let result = storage.get(url).await;
match result {
Err(StorageError::ObjectStore(object_store::Error::NotFound {path:_, source:_ })) => Ok(()),
Err(err) => Err(err),
other => other.map(|_x| ())
}
}

pub async fn get_url_with_options(
url: &str,
options: HashMap<String, String>,
Expand Down

0 comments on commit 2b30909

Please sign in to comment.