diff options
| author | Ellie Huxtable <ellie@atuin.sh> | 2025-12-18 23:11:47 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-18 23:11:47 -0500 |
| commit | 39ef6e79d71ea0a02022d263b9670eb474d621f4 (patch) | |
| tree | d256493c051e3d9ed9758499a344e01e10638ba8 /crates/atuin-server | |
| parent | feat: add support for read replicas to postgres (#3029) (diff) | |
| download | atuin-39ef6e79d71ea0a02022d263b9670eb474d621f4.zip | |
feat: allow disabling sync v1 (#3030)
It takes up a very large amount of our query time, despite having been
replaced for >1yr now. We will be dropping support for it on atuin hub
Diffstat (limited to 'crates/atuin-server')
| -rw-r--r-- | crates/atuin-server/server.toml | 4 | ||||
| -rw-r--r-- | crates/atuin-server/src/router.rs | 23 | ||||
| -rw-r--r-- | crates/atuin-server/src/settings.rs | 5 |
3 files changed, 24 insertions, 8 deletions
diff --git a/crates/atuin-server/server.toml b/crates/atuin-server/server.toml index 6212de00..f02372d0 100644 --- a/crates/atuin-server/server.toml +++ b/crates/atuin-server/server.toml @@ -37,3 +37,7 @@ # enable = false # cert_path = "" # pkey_path = "" + +## Enable legacy sync v1 routes (history-based sync) +## Set to false to disable and use only the newer record-based sync +# sync_v1_enabled = true diff --git a/crates/atuin-server/src/router.rs b/crates/atuin-server/src/router.rs index 1118ab29..9d4f7d44 100644 --- a/crates/atuin-server/src/router.rs +++ b/crates/atuin-server/src/router.rs @@ -109,15 +109,22 @@ pub struct AppState<DB: Database> { } pub fn router<DB: Database>(database: DB, settings: Settings) -> Router { - let routes = Router::new() + let mut routes = Router::new() .route("/", get(handlers::index)) - .route("/healthz", get(handlers::health::health_check)) - .route("/sync/count", get(handlers::history::count)) - .route("/sync/history", get(handlers::history::list)) - .route("/sync/calendar/:focus", get(handlers::history::calendar)) - .route("/sync/status", get(handlers::status::status)) - .route("/history", post(handlers::history::add)) - .route("/history", delete(handlers::history::delete)) + .route("/healthz", get(handlers::health::health_check)); + + // Sync v1 routes - can be disabled in favor of record-based sync + if settings.sync_v1_enabled { + routes = routes + .route("/sync/count", get(handlers::history::count)) + .route("/sync/history", get(handlers::history::list)) + .route("/sync/calendar/:focus", get(handlers::history::calendar)) + .route("/sync/status", get(handlers::status::status)) + .route("/history", post(handlers::history::add)) + .route("/history", delete(handlers::history::delete)); + } + + let routes = routes .route("/user/:username", get(handlers::user::get)) .route("/account", delete(handlers::user::delete)) .route("/account/password", patch(handlers::user::change_password)) diff --git a/crates/atuin-server/src/settings.rs b/crates/atuin-server/src/settings.rs index 7221d4dd..2c02bcbe 100644 --- a/crates/atuin-server/src/settings.rs +++ b/crates/atuin-server/src/settings.rs @@ -68,6 +68,10 @@ pub struct Settings { pub tls: Tls, pub mail: Mail, + /// Enable legacy sync v1 routes (history-based sync) + /// Set to false to use only the newer record-based sync + pub sync_v1_enabled: bool, + /// Advertise a version that is not what we are _actually_ running /// Many clients compare their version with api.atuin.sh, and if they differ, notify the user /// that an update is available. @@ -109,6 +113,7 @@ impl Settings { .set_default("tls.enable", false)? .set_default("tls.cert_path", "")? .set_default("tls.pkey_path", "")? + .set_default("sync_v1_enabled", true)? .add_source( Environment::with_prefix("atuin") .prefix_separator("_") |
