Skip to content

Commit

Permalink
Added comment message to all the legacy endpoints whic explains the d…
Browse files Browse the repository at this point in the history
…eprecation and refers to documentation for limitation (#311)

Co-authored-by: Jakub Zajkowski <[email protected]>
  • Loading branch information
zajko and Jakub Zajkowski authored May 28, 2024
1 parent b23de19 commit d82ec86
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 57 deletions.
2 changes: 1 addition & 1 deletion LEGACY_SSE_EMULATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SSE emulation is by default turned off, the instruction on how to enable it is i

**BEFORE YOU ENABLE LEGACY SSE EMULATION** please consider the following:

- The legacy SSE emulation is a temporary solution and can be removed in a future major release.
- The legacy SSE emulation is a temporary solution and can be removed in a future major release. Consider it being _deprecated_.
- The legacy SSE emulation is not a 1:1 mapping of the 2.x events to 1.x events. Some events will be omitted, some will be transformed, some will be passed as is. More details on the limitations of the emulation are explained below.
- The legacy SSE emulation is an additional drain on resources. It will consume more resources than the "native" 2.x SSE API.

Expand Down
13 changes: 12 additions & 1 deletion event_sidecar/src/event_stream_server/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ async fn send_api_version_from_global_state(
.send(ServerSentEvent::initial_event(protocol_version))
}

async fn send_legacy_comment(
subscriber: &NewSubscriberInfo,
) -> Result<(), SendError<ServerSentEvent>> {
subscriber
.initial_events_sender
.send(ServerSentEvent::legacy_comment_event())
}
async fn send_sidecar_version(
subscriber: &NewSubscriberInfo,
) -> Result<(), SendError<ServerSentEvent>> {
Expand All @@ -113,7 +120,8 @@ async fn handle_incoming_data(
trace!("Event stream server received {:?}", data);
let event = ServerSentEvent {
id: maybe_event_index,
data: data.clone(),
comment: None,
data: Some(data.clone()),
inbound_filter,
};
match data {
Expand Down Expand Up @@ -146,6 +154,9 @@ async fn register_new_subscriber(
buffer: &WheelBuf<Vec<(ProtocolVersion, ServerSentEvent)>, (ProtocolVersion, ServerSentEvent)>,
latest_protocol_version: Option<ProtocolVersion>,
) {
if subscriber.enable_legacy_filters {
let _ = send_legacy_comment(&subscriber).await;
}
let _ = send_sidecar_version(&subscriber).await;
let mut observed_events = false;
// If the client supplied a "start_from" index, provide the buffered events.
Expand Down
Loading

0 comments on commit d82ec86

Please sign in to comment.