Skip to content

Commit

Permalink
SidecarVersion message now has version based on CARGO_PKG_VERSION_* e…
Browse files Browse the repository at this point in the history
…nv variables.
  • Loading branch information
Jakub Zajkowski committed Oct 10, 2023
1 parent fb8fec4 commit 1af25f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sidecar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ utoipa = { version = "3.4.4", features = ["rc_schema"]}
utoipa-swagger-ui = { version = "3.1.5" }
warp = { version = "0.3.6", features = ["compression"] }
wheelbuf = "0.2.0"
once_cell = {workspace = true}

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = "0.5"
Expand All @@ -67,7 +68,6 @@ tabled = { version = "0.10.0", features = ["derive", "color"] }
tempfile = "3"
tokio-util = "0.7.8"
pg-embed = { git = "https://github.com/faokunega/pg-embed", tag = "v0.8.0" }
once_cell = {workspace = true}

[package.metadata.deb]
revision = "0"
Expand Down
15 changes: 10 additions & 5 deletions sidecar/src/event_stream_server/http_server.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::str::FromStr;

use super::{
config::Config,
event_indexer::EventIndex,
Expand All @@ -6,6 +8,7 @@ use super::{
use casper_event_types::{sse_data::SseData, Filter};
use casper_types::ProtocolVersion;
use futures::{future, Future, FutureExt};
use once_cell::sync::Lazy;
use tokio::{
select,
sync::{
Expand All @@ -20,7 +23,12 @@ use wheelbuf::WheelBuf;
pub type InboundData = (Option<u32>, SseData, Option<Filter>, Option<String>);
pub type OutboundReceiver =
mpsc::UnboundedReceiver<(Option<EventIndex>, SseData, Option<Filter>, Option<String>)>;

pub static SIDECAR_VERSION: Lazy<ProtocolVersion> = Lazy::new(|| {
let major: u32 = FromStr::from_str(env!("CARGO_PKG_VERSION_MAJOR")).unwrap();
let minor: u32 = FromStr::from_str(env!("CARGO_PKG_VERSION_MINOR")).unwrap();
let patch: u32 = FromStr::from_str(env!("CARGO_PKG_VERSION_PATCH")).unwrap();
ProtocolVersion::from_parts(major, minor, patch)
});
/// Run the HTTP server.
///
/// * `server_with_shutdown` is the actual server as a future which can be gracefully shut down.
Expand Down Expand Up @@ -95,12 +103,9 @@ async fn send_api_version_from_global_state(
async fn send_sidecar_version(
subscriber: &NewSubscriberInfo,
) -> Result<(), SendError<ServerSentEvent>> {
// #TODO this version shouldn't be hardcoded, it should come from the build process
subscriber
.initial_events_sender
.send(ServerSentEvent::sidecar_version_event(
ProtocolVersion::from_parts(1, 1, 0),
))
.send(ServerSentEvent::sidecar_version_event(*SIDECAR_VERSION))
}

async fn handle_incoming_data(
Expand Down

0 comments on commit 1af25f5

Please sign in to comment.