Skip to content

Commit

Permalink
compress -> event-compression
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 committed Dec 4, 2024
1 parent 02501df commit 156c203
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion contract-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ actix = "0.13.0"
actix-web = "4.2.1"
env_logger = "0.10.0"
log = "0.4.14"
launchdarkly-server-sdk = { path = "../launchdarkly-server-sdk/", default-features = false, features = ["compress"]}
launchdarkly-server-sdk = { path = "../launchdarkly-server-sdk/", default-features = false, features = ["event-compression"]}
serde = { version = "1.0.132", features = ["derive"] }
serde_json = "1.0.73"
futures = "0.3.12"
Expand Down
2 changes: 1 addition & 1 deletion launchdarkly-server-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ reqwest = { version = "0.12.4", features = ["json"] }
[features]
default = ["rustls"]
rustls = ["hyper-rustls/http1", "hyper-rustls/http2", "eventsource-client/rustls"]
compress = ["flate2"]
event-compression = ["flate2"]

[[example]]
name = "print_flags"
Expand Down
2 changes: 1 addition & 1 deletion launchdarkly-server-sdk/src/events/processor_builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl<C> EventProcessorBuilder<C> {
self
}

#[cfg(feature = "compress")]
#[cfg(feature = "event-compression")]
/// Should the event payload sent to LaunchDarkly use gzip compression. By
/// default this is false to prevent backward breaking compatibility issues with
/// older versions of the relay proxy.
Expand Down
14 changes: 7 additions & 7 deletions launchdarkly-server-sdk/src/events/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use chrono::DateTime;
use crossbeam_channel::Sender;
use std::collections::HashMap;

#[cfg(feature = "compress")]
#[cfg(feature = "event-compression")]
use flate2::write::GzEncoder;
#[cfg(feature = "compress")]
#[cfg(feature = "event-compression")]
use flate2::Compression;
#[cfg(feature = "compress")]
#[cfg(feature = "event-compression")]
use std::io::Write;

use futures::future::BoxFuture;
Expand Down Expand Up @@ -44,7 +44,7 @@ pub struct HyperEventSender<C> {
http: hyper::Client<C>,
default_headers: HashMap<&'static str, String>,

// used with compress feature
// used with event-compression feature
#[allow(dead_code)]
compress_events: bool,
}
Expand Down Expand Up @@ -109,7 +109,7 @@ where
serde_json::to_string_pretty(&events).unwrap_or_else(|e| e.to_string())
);

// mut is needed for compress feature
// mut is needed for event-compression feature
#[allow(unused_mut)]
let mut payload = match serde_json::to_vec(&events) {
Ok(json) => json,
Expand All @@ -122,11 +122,11 @@ where
}
};

// mut is needed for compress feature
// mut is needed for event-compression feature
#[allow(unused_mut)]
let mut additional_headers = self.default_headers.clone();

#[cfg(feature = "compress")]
#[cfg(feature = "event-compression")]
if self.compress_events {
let mut e = GzEncoder::new(Vec::new(), Compression::default());
if e.write_all(payload.as_slice()).is_ok() {
Expand Down

0 comments on commit 156c203

Please sign in to comment.