Skip to content

Commit 36b165f

Browse files
committed
persist: make new cfg API Send + Sync ready
1 parent bde27c5 commit 36b165f

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/persist-client/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ impl Location {
9393
pub async fn open(
9494
&self,
9595
timeout: Duration,
96-
) -> Result<(Arc<dyn BlobMulti>, Arc<dyn Consensus>), ExternalError> {
96+
) -> Result<
97+
(
98+
Arc<dyn BlobMulti + Send + Sync>,
99+
Arc<dyn Consensus + Send + Sync>,
100+
),
101+
ExternalError,
102+
> {
97103
let deadline = Instant::now() + timeout;
98104
debug!(
99105
"Location::open timeout={:?} blob={} consensus={}",

src/persist/src/cfg.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ pub enum BlobMultiConfig {
3232

3333
impl BlobMultiConfig {
3434
/// Opens the associated implementation of [BlobMulti].
35-
pub async fn open(self, deadline: Instant) -> Result<Arc<dyn BlobMulti>, ExternalError> {
35+
pub async fn open(
36+
self,
37+
deadline: Instant,
38+
) -> Result<Arc<dyn BlobMulti + Send + Sync>, ExternalError> {
3639
match self {
3740
BlobMultiConfig::File(config) => FileBlobMulti::open(deadline, config)
3841
.await
39-
.map(|x| Arc::new(x) as Arc<dyn BlobMulti>),
42+
.map(|x| Arc::new(x) as Arc<dyn BlobMulti + Send + Sync>),
4043
BlobMultiConfig::S3(config) => S3BlobMulti::open(deadline, config)
4144
.await
42-
.map(|x| Arc::new(x) as Arc<dyn BlobMulti>),
45+
.map(|x| Arc::new(x) as Arc<dyn BlobMulti + Send + Sync>),
4346
}
4447
}
4548

@@ -100,11 +103,13 @@ pub enum ConsensusConfig {
100103

101104
impl ConsensusConfig {
102105
/// Opens the associated implementation of [Consensus].
103-
pub async fn open(self, _deadline: Instant) -> Result<Arc<dyn Consensus>, ExternalError> {
106+
pub async fn open(
107+
self,
108+
_deadline: Instant,
109+
) -> Result<Arc<dyn Consensus + Send + Sync>, ExternalError> {
104110
match self {
105-
ConsensusConfig::Sqlite(config) => {
106-
SqliteConsensus::open(config).map(|x| Arc::new(x) as Arc<dyn Consensus>)
107-
}
111+
ConsensusConfig::Sqlite(config) => SqliteConsensus::open(config)
112+
.map(|x| Arc::new(x) as Arc<dyn Consensus + Send + Sync>),
108113
}
109114
}
110115

0 commit comments

Comments
 (0)