packages feed

launchdarkly-server-sdk 4.3.0 → 4.4.0

raw patch · 6 files changed

+43/−6 lines, 6 filesdep +zlibPVP ok

version bump matches the API change (PVP)

Dependencies added: zlib

API changes (from Hackage documentation)

+ LaunchDarkly.Server.Config: configSetCompressEvents :: Bool -> Config -> Config

Files

CHANGELOG.md view
@@ -2,6 +2,20 @@  All notable changes to the LaunchDarkly Haskell Server-side SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org). +## [4.4.0](https://github.com/launchdarkly/haskell-server-sdk/compare/4.3.0...4.4.0) (2024-12-05)++This release introduces the ability to enable compression of event payloads. When enabled, the SDK will compress events before sending them to the LaunchDarkly servers. This can reduce the bandwidth required to send events, which can be useful in high-traffic environments to reduce egress traffic costs.++> [!IMPORTANT]+> Relay Proxy users **MUST** upgrade to version 8.9 or higher prior to enabling this option to prevent loss of event data.+>+> However, enabling this feature is **NOT** required when using the Relay Proxy as it will manage compression automatically.+++### Features++* Add option to enable compression of event payloads ([#91](https://github.com/launchdarkly/haskell-server-sdk/issues/91)) ([cb21081](https://github.com/launchdarkly/haskell-server-sdk/commit/cb2108103c5210d08b7976e9ad4d3357c332b783))+ ## [4.3.0](https://github.com/launchdarkly/haskell-server-sdk/compare/4.2.0...4.3.0) (2024-10-24)  
launchdarkly-server-sdk.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.37.0.+-- This file has been generated from package.yaml by hpack version 0.35.1. -- -- see: https://github.com/sol/hpack  name:           launchdarkly-server-sdk-version:        4.3.0+version:        4.4.0 synopsis:       Server-side SDK for integrating with LaunchDarkly description:    Please see the README on GitHub at <https://github.com/launchdarkly/haskell-server-sdk#readme> category:       Web@@ -126,6 +126,7 @@     , unordered-containers >=0.2.10.0 && <0.3     , uuid >=1.3.13 && <1.4     , yaml >=0.11.5.0 && <0.12+    , zlib >=0.6.2.2 && <0.7   default-language: Haskell2010  test-suite haskell-server-sdk-test@@ -237,4 +238,5 @@     , unordered-containers >=0.2.10.0 && <0.3     , uuid >=1.3.13 && <1.4     , yaml >=0.11.5.0 && <0.12+    , zlib >=0.6.2.2 && <0.7   default-language: Haskell2010
src/LaunchDarkly/Server/Client/Internal.hs view
@@ -21,7 +21,7 @@  -- | The version string for this library. clientVersion :: Text-clientVersion = "4.3.0" -- x-release-please-version+clientVersion = "4.4.0" -- x-release-please-version  -- | -- Client is the LaunchDarkly client. Client instances are thread-safe.
src/LaunchDarkly/Server/Config.hs view
@@ -17,6 +17,7 @@     , configSetContextKeyLRUCapacity     , configSetUserKeyLRUCapacity     , configSetEventsCapacity+    , configSetCompressEvents     , configSetLogger     , configSetManager     , configSetSendEvents@@ -53,6 +54,7 @@         , baseURI = "https://sdk.launchdarkly.com"         , streamURI = "https://stream.launchdarkly.com"         , eventsURI = "https://events.launchdarkly.com"+        , compressEvents = False         , storeBackend = Nothing         , storeTTLSeconds = 10         , streaming = True@@ -168,6 +170,16 @@ -- buffer is flushed, events will be discarded. configSetEventsCapacity :: Natural -> Config -> Config configSetEventsCapacity = setField @"eventsCapacity"++-- |+-- 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.+--+-- Customers not using the relay proxy are strongly encouraged to enable this+-- feature to reduce egress bandwidth cost.+configSetCompressEvents :: Bool -> Config -> Config+configSetCompressEvents = setField @"compressEvents"  -- | Set the logger to be used by the client. configSetLogger :: (LoggingT IO () -> IO ()) -> Config -> Config
src/LaunchDarkly/Server/Config/Internal.hs view
@@ -41,6 +41,7 @@     , pollIntervalSeconds :: !Natural     , contextKeyLRUCapacity :: !Natural     , eventsCapacity :: !Natural+    , compressEvents :: !Bool     , logger :: !(LoggingT IO () -> IO ())     , sendEvents :: !Bool     , offline :: !Bool
src/LaunchDarkly/Server/Network/Eventing.hs view
@@ -1,5 +1,6 @@ module LaunchDarkly.Server.Network.Eventing (eventThread) where +import qualified Codec.Compression.GZip as GZip import Control.Concurrent (killThread, myThreadId) import Control.Concurrent.MVar (modifyMVar_, readMVar, swapMVar, takeMVar) import Control.Monad (forever, unless, void, when)@@ -59,7 +60,11 @@  eventThread :: (MonadIO m, MonadLogger m, MonadMask m) => Manager -> Client -> ClientContext -> m () eventThread manager client clientContext = do-    let state = getField @"events" client; config = getField @"config" client; httpConfig = httpConfiguration clientContext+    let+        state = getField @"events" client+        config = getField @"config" client+        compressEvents = getField @"compressEvents" config+        httpConfig = httpConfiguration clientContext     rngRef <- liftIO $ newStdGen >>= newIORef     req <- (liftIO $ prepareRequest httpConfig $ (T.unpack $ getField @"eventsURI" config) ++ "/bulk") >>= pure . setEventHeaders     void $ tryAuthorized client $ forever $ do@@ -69,12 +74,15 @@             payloadId <- liftIO $ atomicModifyIORef' rngRef (swap . random)             let                 encoded = encode events'+                payload = if compressEvents then GZip.compress encoded else encoded                 thisReq =                     req-                        { requestBody = RequestBodyLBS encoded+                        { requestBody = RequestBodyLBS payload                         , requestHeaders =                             (requestHeaders req)-                                & \l -> addToAL l "X-LaunchDarkly-Payload-ID" (UUID.toASCIIBytes payloadId)+                                & \l ->+                                    addToAL l "X-LaunchDarkly-Payload-ID" (UUID.toASCIIBytes payloadId)+                                        & \l -> if compressEvents then addToAL l "Content-Encoding" "gzip" else l                         }             (success, serverTime) <- processSend manager thisReq             $(logDebug) $ T.append "sending events: " $ decodeUtf8 $ L.toStrict encoded