Skip to content

Commit 3e58f63

Browse files
committed
Add a binary that uses a Postgres backend
Building of this binary is controlled with features, allowing downstream users to build just the SQLite version and not be concerned with the tokio-postgres dependency tree (which includes links to OpenSSL and other details). The Postgres version is disabled by default. This does not change the binary name for the SQLite build, just to avoid confusion for people upgrading to the new version.
1 parent 6e8c72b commit 3e58f63

File tree

12 files changed

+543
-440
lines changed

12 files changed

+543
-440
lines changed

Cargo.lock

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

server/Cargo.toml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,25 @@ authors = ["Dustin J. Mitchell <dustin@mozilla.com>"]
55
edition = "2021"
66
publish = false
77

8+
[features]
9+
# By default, only build the SQLite backend.
10+
default = ["sqlite"]
11+
sqlite = ["dep:taskchampion-sync-server-storage-sqlite"]
12+
postgres = ["dep:taskchampion-sync-server-storage-postgres"]
13+
14+
[[bin]]
15+
# The simple binary name is the SQLite build.
16+
name = "taskchampion-sync-server"
17+
required-features = ["sqlite"]
18+
19+
[[bin]]
20+
name = "taskchampion-sync-server-postgres"
21+
required-features = ["postgres"]
22+
823
[dependencies]
924
taskchampion-sync-server-core = { path = "../core" }
10-
taskchampion-sync-server-storage-sqlite = { path = "../sqlite" }
25+
taskchampion-sync-server-storage-sqlite = { path = "../sqlite", optional = true }
26+
taskchampion-sync-server-storage-postgres = { path = "../postgres", optional = true }
1127
uuid.workspace = true
1228
actix-web.workspace = true
1329
anyhow.workspace = true

server/src/api/add_snapshot.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ pub(crate) async fn service(
5656

5757
#[cfg(test)]
5858
mod test {
59-
use crate::WebServer;
60-
use crate::{api::CLIENT_ID_HEADER, WebConfig};
59+
use crate::{
60+
api::CLIENT_ID_HEADER,
61+
web::{WebConfig, WebServer},
62+
};
6163
use actix_web::{http::StatusCode, test, App};
6264
use pretty_assertions::assert_eq;
6365
use taskchampion_sync_server_core::{InMemoryStorage, ServerConfig, Storage, NIL_VERSION_ID};

server/src/api/add_version.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ pub(crate) async fn service(
101101

102102
#[cfg(test)]
103103
mod test {
104-
use crate::WebServer;
105-
use crate::{api::CLIENT_ID_HEADER, WebConfig};
104+
use crate::{
105+
api::CLIENT_ID_HEADER,
106+
web::{WebConfig, WebServer},
107+
};
106108
use actix_web::{http::StatusCode, test, App};
107109
use pretty_assertions::assert_eq;
108110
use taskchampion_sync_server_core::{InMemoryStorage, ServerConfig, Storage};

server/src/api/get_child_version.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ pub(crate) async fn service(
4949

5050
#[cfg(test)]
5151
mod test {
52-
use crate::WebServer;
53-
use crate::{api::CLIENT_ID_HEADER, WebConfig};
52+
use crate::{
53+
api::CLIENT_ID_HEADER,
54+
web::{WebConfig, WebServer},
55+
};
5456
use actix_web::{http::StatusCode, test, App};
5557
use pretty_assertions::assert_eq;
5658
use taskchampion_sync_server_core::{InMemoryStorage, ServerConfig, Storage, NIL_VERSION_ID};

server/src/api/get_snapshot.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ pub(crate) async fn service(
3434

3535
#[cfg(test)]
3636
mod test {
37-
use crate::WebServer;
38-
use crate::{api::CLIENT_ID_HEADER, WebConfig};
37+
use crate::{
38+
api::CLIENT_ID_HEADER,
39+
web::{WebConfig, WebServer},
40+
};
3941
use actix_web::{http::StatusCode, test, App};
4042
use chrono::{TimeZone, Utc};
4143
use pretty_assertions::assert_eq;

server/src/api/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use actix_web::{error, web, HttpRequest, Result, Scope};
22
use taskchampion_sync_server_core::{ClientId, Server, ServerError};
33

4-
use crate::WebConfig;
4+
use crate::web::WebConfig;
55

66
mod add_snapshot;
77
mod add_version;
@@ -89,6 +89,7 @@ mod test {
8989
web_config: WebConfig {
9090
client_id_allowlist: None,
9191
create_clients: true,
92+
..WebConfig::default()
9293
},
9394
};
9495
let req = actix_web::test::TestRequest::default()
@@ -106,6 +107,7 @@ mod test {
106107
web_config: WebConfig {
107108
client_id_allowlist: Some([client_id_ok].into()),
108109
create_clients: true,
110+
..WebConfig::default()
109111
},
110112
};
111113
let req = actix_web::test::TestRequest::default()

0 commit comments

Comments
 (0)