Skip to content

Commit c307f1d

Browse files
authored
Merge pull request #397 from adorsys/392-use-shared-circuit-breaker-instance-in-mediator
392 use shared circuit breaker instance in mediator
2 parents 26cf24d + 5308be0 commit c307f1d

File tree

23 files changed

+239
-422
lines changed

23 files changed

+239
-422
lines changed

Cargo.lock

Lines changed: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/filesystem/src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use nix::fcntl::{Flock, FlockArg};
22
use std::{
33
fs::OpenOptions,
4-
io::{Error as IoError, ErrorKind, Result as IoResult},
4+
io::{Error as IoError, Result as IoResult},
55
path::Path,
66
};
77

@@ -36,7 +36,7 @@ impl FileSystem for StdFileSystem {
3636
if path.is_file() {
3737
files.push(
3838
path.to_str()
39-
.ok_or(IoError::new(ErrorKind::Other, "InvalidPath"))?
39+
.ok_or(IoError::other("InvalidPath"))?
4040
.to_string(),
4141
)
4242
}
@@ -59,18 +59,14 @@ impl FileSystem for StdFileSystem {
5959

6060
// Acquire an exclusive lock before writing to the file
6161
let file = Flock::lock(file, FlockArg::LockExclusive)
62-
.map_err(|_| IoError::new(ErrorKind::Other, "Error acquiring file lock"))?;
62+
.map_err(|_| IoError::other("Error acquiring file lock"))?;
6363

64-
std::fs::write(path, content).map_err(|_| {
65-
IoError::new(
66-
ErrorKind::Other,
67-
"Error saving base64-encoded image to file",
68-
)
69-
})?;
64+
std::fs::write(path, content)
65+
.map_err(|_| IoError::other("Error saving base64-encoded image to file"))?;
7066

7167
// Release the lock after writing to the file
7268
file.unlock()
73-
.map_err(|_| IoError::new(ErrorKind::Other, "Error releasing file lock"))?;
69+
.map_err(|_| IoError::other("Error releasing file lock"))?;
7470

7571
Ok(())
7672
}

crates/web-plugins/did-endpoint/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ did-utils.workspace = true
1616
filesystem.workspace = true
1717

1818
cfg-if.workspace = true
19-
mongodb.workspace = true
2019
chrono.workspace = true
2120
thiserror.workspace = true
2221
serde_json.workspace = true

crates/web-plugins/did-endpoint/src/web.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ mod tests {
324324
let KeyFormat::Jwk(jwk) = key else {
325325
return None;
326326
};
327-
Some(jwk.clone())
327+
Some(*jwk.clone())
328328
}
329329
}
330330
}

crates/web-plugins/didcomm-messaging/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ tracing.workspace = true
3333
once_cell.workspace = true
3434
serde_json.workspace = true
3535
thiserror.workspace = true
36-
dashmap.workspace = true
3736
http-body-util.workspace = true
3837
tokio = { workspace = true, features = ["full"] }
3938
hyper = { workspace = true, features = ["full"] }

crates/web-plugins/didcomm-messaging/did-utils/src/didcore.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub struct VerificationMethod {
167167
pub enum KeyFormat {
168168
Base58(String),
169169
Multibase(String),
170-
Jwk(Jwk),
170+
Jwk(Box<Jwk>),
171171
}
172172

173173
/// Represents a method in a DID Document (authentication, assertion, key agreement, etc.).
@@ -253,7 +253,7 @@ impl VerificationMethod {
253253
}
254254

255255
if s.public_key_jwk.is_some() {
256-
return Ok(Some(KeyFormat::Jwk(s.public_key_jwk.unwrap())));
256+
return Ok(Some(KeyFormat::Jwk(Box::new(s.public_key_jwk.unwrap()))));
257257
}
258258

259259
Ok(None)
@@ -283,7 +283,7 @@ impl VerificationMethod {
283283
}
284284

285285
if s.private_key_jwk.is_some() {
286-
return Ok(Some(KeyFormat::Jwk(s.private_key_jwk.unwrap())));
286+
return Ok(Some(KeyFormat::Jwk(Box::new(s.private_key_jwk.unwrap()))));
287287
}
288288

289289
Ok(None)

crates/web-plugins/didcomm-messaging/did-utils/src/methods/key/method.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ impl DidKey {
218218
controller: format!("did:key:{multibase_value}"),
219219
public_key: Some(match self.key_format {
220220
PublicKeyFormat::Multikey => KeyFormat::Multibase(String::from(multibase_value)),
221-
PublicKeyFormat::Jwk => KeyFormat::Jwk(
221+
PublicKeyFormat::Jwk => KeyFormat::Jwk(Box::new(
222222
alg.build_jwk(raw_public_key_bytes) //
223223
.map_err(|_| DIDResolutionError::InternalError)?,
224-
),
224+
)),
225225
}),
226226
..Default::default()
227227
})
@@ -255,10 +255,10 @@ impl DidKey {
255255
controller: format!("did:key:{multibase_value}"),
256256
public_key: Some(match self.key_format {
257257
PublicKeyFormat::Multikey => KeyFormat::Multibase(encryption_multibase_value),
258-
PublicKeyFormat::Jwk => KeyFormat::Jwk(
258+
PublicKeyFormat::Jwk => KeyFormat::Jwk(Box::new(
259259
alg.build_jwk(encryption_raw_public_key_bytes)
260260
.map_err(|_| DIDResolutionError::InternalError)?,
261-
),
261+
)),
262262
}),
263263
..Default::default()
264264
})

crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl DidPeer {
457457
controller: did.to_string(),
458458
public_key: Some(match self.key_format {
459459
PublicKeyFormat::Multikey => KeyFormat::Multibase(String::from(multikey)),
460-
PublicKeyFormat::Jwk => KeyFormat::Jwk(alg.build_jwk(key).map_err(|_| DIDResolutionError::InternalError)?),
460+
PublicKeyFormat::Jwk => KeyFormat::Jwk(Box::new(alg.build_jwk(key).map_err(|_| DIDResolutionError::InternalError)?)),
461461
}),
462462
..Default::default()
463463
})
@@ -548,7 +548,7 @@ impl DidPeer {
548548
PublicKeyFormat::Multikey => KeyFormat::Multibase(multikey.to_string()),
549549
PublicKeyFormat::Jwk => {
550550
let (alg, key) = decode_multikey(multikey).map_err(|_| DIDPeerMethodError::MalformedPeerDID)?;
551-
KeyFormat::Jwk(alg.build_jwk(&key).map_err(|_| DIDResolutionError::InternalError)?)
551+
KeyFormat::Jwk(Box::new(alg.build_jwk(&key).map_err(|_| DIDResolutionError::InternalError)?))
552552
}
553553
}),
554554
..Default::default()

crates/web-plugins/didcomm-messaging/protocols/basic-message/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ chrono.workspace = true
1515
[dev-dependencies]
1616
did-utils.workspace = true
1717
keystore.workspace = true
18-
dashmap.workspace = true
1918
shared = { workspace = true, features = ["test-utils"] }

crates/web-plugins/didcomm-messaging/protocols/basic-message/src/handler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ mod tests {
1919
use super::*;
2020
use axum::http::StatusCode;
2121
use chrono::Utc;
22-
use dashmap::DashMap;
2322
use did_utils::didcore::Document;
2423
use keystore::Keystore;
2524
use serde_json::json;
2625
use shared::{
26+
breaker::CircuitBreaker,
2727
repository::tests::{MockConnectionRepository, MockMessagesRepository},
2828
state::AppStateRepository,
2929
};
@@ -99,7 +99,7 @@ mod tests {
9999
diddoc,
100100
None,
101101
Some(repository),
102-
DashMap::new(),
102+
CircuitBreaker::new(),
103103
)
104104
.unwrap(),
105105
);

0 commit comments

Comments
 (0)