From fa2b76e43bfbb7b7517fd4f8790ac1a6800512de Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Tue, 30 Jul 2024 14:58:19 -0400 Subject: [PATCH] chore: Bump eventsource client This new version of the client potentially exposes some additional connection information. We don't need it for the SDK at this point, but it's good to keep these two repositories in sync. --- launchdarkly-server-sdk/Cargo.toml | 2 +- launchdarkly-server-sdk/src/data_source.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/launchdarkly-server-sdk/Cargo.toml b/launchdarkly-server-sdk/Cargo.toml index 809194a..fb8b07e 100644 --- a/launchdarkly-server-sdk/Cargo.toml +++ b/launchdarkly-server-sdk/Cargo.toml @@ -17,7 +17,7 @@ exclude = [ chrono = "0.4.19" crossbeam-channel = "0.5.1" data-encoding = "2.3.2" -eventsource-client = { version = "0.12.2", default-features = false } +eventsource-client = { version = "0.13.0", default-features = false } futures = "0.3.12" lazy_static = "1.4.0" log = "0.4.14" diff --git a/launchdarkly-server-sdk/src/data_source.rs b/launchdarkly-server-sdk/src/data_source.rs index ce19a34..9129533 100644 --- a/launchdarkly-server-sdk/src/data_source.rs +++ b/launchdarkly-server-sdk/src/data_source.rs @@ -131,18 +131,22 @@ impl DataSource for StreamingDataSource { event = event_stream.next() => { let event = match event { Some(Ok(event)) => match event { + es::SSE::Connected(_) => { + debug!("data source connected"); + continue; + }, es::SSE::Comment(str)=> { debug!("data source got a comment: {}", str); continue; }, es::SSE::Event(ev) => ev, }, - Some(Err(es::Error::UnexpectedResponse(status_code))) => { - match is_http_error_recoverable(status_code.as_u16()) { + Some(Err(es::Error::UnexpectedResponse(response, _))) => { + match is_http_error_recoverable(response.status()) { true => continue, _ => { notify_init.call_once(|| (init_complete)(false)); - warn!("Returned unrecoverable failure. Unexpected response {:?}", status_code); + warn!("Returned unrecoverable failure. Unexpected response {}", response.status()); break } }