Skip to content

Commit

Permalink
Add vergen revision to local_backend (#33677)
Browse files Browse the repository at this point in the history
Add vergen revision to local_backend
Add commit timestamp

GitOrigin-RevId: b1f80550c790acbd65d89b6b584cfce47876230d
  • Loading branch information
nipunn1313 authored and Convex, Inc. committed Jan 28, 2025
1 parent 6c52ebd commit 5e01fc1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ tungstenite = { version = "0.21.0", features = [ "url", "native-tls-vendored" ]
url = "2.5.4"
urlencoding = "2.1.3"
uuid = { version = "1.6", features = [ "serde", "v4" ] }
vergen = { version = "8.1.0" }
walkdir = "2"
xorf = { git = "https://github.com/sujayakar/xorf.git", rev = "62a32de47bb3ad8b34d6d4feac034a24be2c881a" }

Expand Down
4 changes: 4 additions & 0 deletions crates/local_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,9 @@ usage_tracking = { path = "../../crates/usage_tracking", features = [
value = { path = "../../crates/value", features = ["testing"] }
vector = { path = "../../crates/vector", features = ["testing"] }

[build-dependencies]
anyhow = { workspace = true }
vergen = { workspace = true, features = ["git", "gitcl"] }

[lints]
workspace = true
18 changes: 18 additions & 0 deletions crates/local_backend/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::env;

use vergen::EmitBuilder;

fn main() -> anyhow::Result<()> {
// recompile when there's a new git hash for /rev endpoint.
if cfg!(not(debug_assertions)) || env::var("FORCE_EMIT").is_ok() {
// Emit git sha
EmitBuilder::builder()
.git_sha(false)
.git_commit_timestamp()
.emit()?;
} else {
println!("cargo:rustc-env=VERGEN_GIT_SHA=dev");
println!("cargo:rustc-env=VERGEN_GIT_COMMIT_TIMESTAMP=0000-00-00T00:00:00.000000000Z");
}
Ok(())
}
9 changes: 7 additions & 2 deletions crates/local_backend/src/beacon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use database::Database;
use model::database_globals::DatabaseGlobalsModel;
use runtime::prod::ProdRuntime;

const COMPILED_REVISION: &str = env!("VERGEN_GIT_SHA");
const COMMIT_TIMESTAMP: &str = env!("VERGEN_GIT_COMMIT_TIMESTAMP");
const INITIAL_BACKOFF: Duration = Duration::from_secs(1);
const MAX_BACKOFF: Duration = Duration::from_secs(900); // 15 minutes

Expand All @@ -36,9 +38,12 @@ pub async fn start_beacon(runtime: ProdRuntime, database: Database<ProdRuntime>)

// For now, just log the beacon info since endpoint is TBD
tracing::info!(
"Beacon: document_id={:?}, database_version={}",
"Beacon: document_id={:?}, database_version={}, compiled_revision={}, \
commit_timestamp={}",
globals.id(),
globals.version
globals.version,
COMPILED_REVISION,
COMMIT_TIMESTAMP,
);
Ok::<(), anyhow::Error>(())
}
Expand Down

0 comments on commit 5e01fc1

Please sign in to comment.