-
Notifications
You must be signed in to change notification settings - Fork 177
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
Let ProgramStorage::external be async #1291
Conversation
1ee3fbf
to
e307d29
Compare
e307d29
to
6f6c1f4
Compare
crates/core/src/host/disk_storage.rs
Outdated
|
||
fs::rename(tmp, path).await?; | ||
} | ||
Err(e) if e.kind() == io::ErrorKind::AlreadyExists => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this even possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it was causing errors in CI - all the tests upload the same module simultaneously, I think.
@@ -46,37 +48,57 @@ type HostCell = Arc<AsyncRwLock<Option<Host>>>; | |||
/// The registry of all running hosts. | |||
type Hosts = Arc<Mutex<IntMap<u64, HostCell>>>; | |||
|
|||
type ExternalStorage = dyn Fn(&Hash) -> anyhow::Result<Option<AnyBytes>> + Send + Sync + 'static; | |||
type SameDbStorage = dyn Fn(&RelationalDB, &Hash) -> anyhow::Result<Option<AnyBytes>> + Send + Sync + 'static; | |||
#[async_trait] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need async_trait
still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - it lets the future borrow from the ExternalStorage, rather than having to be 'static
debug!("lookup program {}", program_hash); | ||
match self { | ||
ProgramStorage::External(external) => external.lookup(program_hash).await, | ||
ProgramStorage::SameDb(f) => f(db, program_hash), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if this should be spawn blocking, just in case the same thread has a tx open…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, probably - but we can cross that when we get to actually using it.
@@ -89,7 +111,7 @@ pub struct HostController { | |||
/// The directory to create database instances in. | |||
/// | |||
/// For example: | |||
/// | |||
///> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, nothing
@@ -1,34 +0,0 @@ | |||
use crate::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
Description of Changes
Also: remove sled object_db. Merging that in from #1245.
Expected complexity level and risk
1