Skip to content

Commit

Permalink
Switching keystorage-s3 to current-thread
Browse files Browse the repository at this point in the history
When publishing, a compilation issue occurred due to Runtime::new()
requiring rt-multi-thread. That seemed overkill for a user who is
invoking this outside of a tokio context, so the runtime will default to
the current thread runtime.
  • Loading branch information
ecton committed Mar 29, 2022
1 parent 22f561e commit fe02742
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/bonsaidb-keystorage-s3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use bonsaidb_local::{
StorageId,
};
pub use http;
use tokio::runtime::{Handle, Runtime};
use tokio::runtime::{self, Handle, Runtime};

/// S3-compatible [`VaultKeyStorage`] implementor.
#[derive(Default, Debug)]
Expand All @@ -86,7 +86,17 @@ enum Tokio {

impl Default for Tokio {
fn default() -> Self {
Handle::try_current().map_or_else(|_| Self::Runtime(Runtime::new().unwrap()), Self::Handle)
Handle::try_current().map_or_else(
|_| {
Self::Runtime(
runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap(),
)
},
Self::Handle,
)
}
}

Expand Down

0 comments on commit fe02742

Please sign in to comment.