Skip to content

Commit f6d03d9

Browse files
authored
Refactor: Convert Replica and Storage layers to async (#607)
refactor: convert Replica and Storage layers to async
1 parent b988b66 commit f6d03d9

File tree

22 files changed

+2803
-2010
lines changed

22 files changed

+2803
-2010
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ sync = ["server-sync", "server-gcp", "server-aws", "server-local"]
2525
# Support for sync to a server
2626
server-sync = ["encryption", "dep:ureq", "dep:url"]
2727
# Support for sync to GCP
28-
server-gcp = ["cloud", "encryption", "dep:google-cloud-storage", "dep:tokio"]
28+
server-gcp = ["cloud", "encryption", "dep:google-cloud-storage"]
2929
# Support for sync to AWS
30-
server-aws = ["cloud", "encryption", "dep:aws-sdk-s3", "dep:aws-config", "dep:aws-credential-types", "dep:tokio"]
30+
server-aws = ["cloud", "encryption", "dep:aws-sdk-s3", "dep:aws-config", "dep:aws-credential-types"]
3131
# Suppport for sync to another SQLite database on the same machine
3232
server-local = ["storage-sqlite"]
3333
# Support for all task storage backends
3434
storage = ["storage-sqlite"]
3535
# Support for SQLite task storage
36-
storage-sqlite = ["dep:rusqlite"]
36+
storage-sqlite = ["dep:rusqlite", "dep:tokio-rusqlite"]
3737
# (private) Support for sync protocol encryption
3838
encryption = ["dep:ring"]
3939
# (private) Generic support for cloud sync
4040
cloud = []
4141
# static bundling of dependencies
42-
bundled = ["rusqlite/bundled"]
42+
bundled = ["rusqlite/bundled", "tokio-rusqlite/bundled"]
4343
# use native CA roots, instead of bundled
4444
tls-native-roots = ["ureq/native-certs"]
4545

@@ -57,16 +57,18 @@ flate2 = "1"
5757
google-cloud-storage = { version = "0.24.0", default-features = false, features = ["rustls-tls", "auth"], optional = true }
5858
log = "^0.4.17"
5959
ring = { version = "0.17", optional = true }
60-
rusqlite = { version = "0.37", optional = true}
60+
rusqlite = { version = "0.32", optional = true}
6161
serde_json = "^1.0"
6262
serde = { version = "^1.0.147", features = ["derive"] }
6363
strum = "0.27"
6464
strum_macros = "0.27"
65-
tokio = { version = "1", features = ["rt-multi-thread"], optional = true }
65+
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
6666
thiserror = "2.0"
6767
ureq = { version = "^2.12.1", features = ["tls"], optional = true }
6868
uuid = { version = "^1.16.0", features = ["serde", "v4"] }
6969
url = { version = "2", optional = true }
70+
async-trait = "0.1.89"
71+
tokio-rusqlite = { version = "0.6.0", optional = true }
7072

7173
[dev-dependencies]
7274
proptest = "^1.7.0"

src/crate-doc.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Several server implementations are included, and users can define their own impl
3737
# {
3838
# use taskchampion::{storage::AccessMode, ServerConfig, Replica, storage::InMemoryStorage};
3939
# use tempfile::TempDir;
40-
# fn main() -> anyhow::Result<()> {
40+
# #[tokio::main]
41+
# async fn main() -> anyhow::Result<()> {
4142
# let taskdb_dir = TempDir::new()?;
4243
# let taskdb_dir = taskdb_dir.path().to_path_buf();
4344
# let server_dir = TempDir::new()?;
@@ -51,7 +52,7 @@ let server_config = ServerConfig::Local { server_dir };
5152
let mut server = server_config.into_server()?;
5253

5354
// Sync to that server.
54-
replica.sync(&mut server, true)?;
55+
replica.sync(server, true).await?;
5556
#
5657
# Ok(())
5758
# }

src/errors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ other_error!(serde_json::Error);
4141
other_error!(rusqlite::Error);
4242
#[cfg(feature = "storage-sqlite")]
4343
other_error!(crate::storage::sqlite::SqliteError);
44+
#[cfg(feature = "storage-sqlite")]
45+
other_error!(tokio_rusqlite::Error);
4446

4547
#[cfg(feature = "server-gcp")]
4648
other_error!(google_cloud_storage::http::Error);

0 commit comments

Comments
 (0)