Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhani-cw committed Mar 14, 2024
2 parents 5f5f31d + d01b589 commit 5680a10
Show file tree
Hide file tree
Showing 10 changed files with 585 additions and 2 deletions.

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

16 changes: 16 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::eth::primitives::BlockNumber;
use crate::eth::primitives::BlockSelection;
#[cfg(feature = "dev")]
use crate::eth::primitives::StoragePointInTime;
use crate::eth::storage::HybridPermanentStorage;
use crate::eth::storage::InMemoryPermanentStorage;
use crate::eth::storage::InMemoryTemporaryStorage;
use crate::eth::storage::PermanentStorage;
Expand Down Expand Up @@ -363,6 +364,9 @@ pub enum StorageKind {

#[strum(serialize = "postgres")]
Postgres { url: String },

#[strum(serialize = "hybrid")]
Hybrid { url: String },
}

impl PermanentStorageConfig {
Expand All @@ -379,6 +383,14 @@ impl PermanentStorageConfig {
};
Arc::new(Postgres::new(config).await?)
}
StorageKind::Hybrid { ref url } => {
let config = PostgresClientConfig {
url: url.to_owned(),
connections: self.perm_connections,
acquire_timeout: Duration::from_millis(self.perm_timeout_millis),
};
Arc::new(HybridPermanentStorage::new(config).await?)
}
};

Ok(Arc::new(StratusStorage::new(temp, perm)))
Expand All @@ -392,6 +404,10 @@ impl FromStr for StorageKind {
match s {
"inmemory" => Ok(Self::InMemory),
s if s.starts_with("postgres://") => Ok(Self::Postgres { url: s.to_string() }),
s if s.starts_with("hybrid://") => {
let s = s.replace("hybrid", "postgres"); //TODO there is a better way to do this
Ok(Self::Hybrid { url: s.to_string() })
}
s => Err(anyhow!("unknown storage: {}", s)),
}
}
Expand Down
Loading

0 comments on commit 5680a10

Please sign in to comment.