Skip to content

Commit acd068e

Browse files
authored
Add close to credential storage (#5283)
* Add close method to credential storage * wip
1 parent caa17d9 commit acd068e

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

common/credential-storage/src/backends/sqlite.rs

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ impl SqliteEcashTicketbookManager {
2323
SqliteEcashTicketbookManager { connection_pool }
2424
}
2525

26+
/// Closes the connection pool.
27+
pub async fn close(&self) {
28+
self.connection_pool.close().await
29+
}
30+
2631
pub(crate) async fn cleanup_expired(&self, deadline: Date) -> Result<(), sqlx::Error> {
2732
sqlx::query!(
2833
"DELETE FROM ecash_ticketbook WHERE expiration_date <= ?",

common/credential-storage/src/ephemeral_storage.rs

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ impl Debug for EphemeralStorage {
4343
impl Storage for EphemeralStorage {
4444
type StorageError = StorageError;
4545

46+
async fn close(&self) {
47+
// nothing to do here
48+
}
49+
4650
async fn cleanup_expired(&self) -> Result<(), Self::StorageError> {
4751
self.storage_manager.cleanup_expired().await;
4852
Ok(())

common/credential-storage/src/persistent_storage/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ impl PersistentStorage {
8989
impl Storage for PersistentStorage {
9090
type StorageError = StorageError;
9191

92+
async fn close(&self) {
93+
self.storage_manager.close().await
94+
}
95+
9296
/// remove all expired ticketbooks and expiration date signatures
9397
async fn cleanup_expired(&self) -> Result<(), Self::StorageError> {
9498
let ecash_yesterday = ecash_today().date().previous_day().unwrap();

common/credential-storage/src/storage.rs

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use std::error::Error;
2222
pub trait Storage: Send + Sync {
2323
type StorageError: Error;
2424

25+
async fn close(&self);
26+
2527
/// remove all expired ticketbooks and expiration date signatures
2628
async fn cleanup_expired(&self) -> Result<(), Self::StorageError>;
2729

0 commit comments

Comments
 (0)