module LaunchDarkly.Server.Config
( Config
, makeConfig
, configSetKey
, configSetBaseURI
, configSetStreamURI
, configSetEventsURI
, configSetStreaming
, configSetAllAttributesPrivate
, configSetPrivateAttributeNames
, configSetFlushIntervalSeconds
, configSetPollIntervalSeconds
, configSetUserKeyLRUCapacity
, configSetInlineUsersInEvents
, configSetEventsCapacity
, configSetLogger
, configSetSendEvents
, configSetOffline
, configSetRequestTimeoutSeconds
, configSetStoreBackend
, configSetStoreTTL
, configSetUseLdd
) where
import Control.Monad.Logger (LoggingT, runStdoutLoggingT)
import Data.Generics.Product (setField)
import Data.Set (Set)
import Data.Text (Text)
import Data.Monoid (mempty)
import GHC.Natural (Natural)
import LaunchDarkly.Server.Config.Internal (Config(..), mapConfig, ConfigI(..))
import LaunchDarkly.Server.Store (StoreInterface)
makeConfig :: Text -> Config
makeConfig :: Text -> Config
makeConfig Text
key = ConfigI -> Config
Config (ConfigI -> Config) -> ConfigI -> Config
forall a b. (a -> b) -> a -> b
$ ConfigI :: Text
-> Text
-> Text
-> Text
-> Maybe StoreInterface
-> Natural
-> Bool
-> Bool
-> Set Text
-> Natural
-> Natural
-> Natural
-> Bool
-> Natural
-> (LoggingT IO () -> IO ())
-> Bool
-> Bool
-> Natural
-> Bool
-> ConfigI
ConfigI
{ $sel:key:ConfigI :: Text
key = Text
key
, $sel:baseURI:ConfigI :: Text
baseURI = Text
"https://app.launchdarkly.com"
, $sel:streamURI:ConfigI :: Text
streamURI = Text
"https://stream.launchdarkly.com"
, $sel:eventsURI:ConfigI :: Text
eventsURI = Text
"https://events.launchdarkly.com"
, $sel:storeBackend:ConfigI :: Maybe StoreInterface
storeBackend = Maybe StoreInterface
forall a. Maybe a
Nothing
, $sel:storeTTLSeconds:ConfigI :: Natural
storeTTLSeconds = Natural
10
, $sel:streaming:ConfigI :: Bool
streaming = Bool
True
, $sel:allAttributesPrivate:ConfigI :: Bool
allAttributesPrivate = Bool
False
, $sel:privateAttributeNames:ConfigI :: Set Text
privateAttributeNames = Set Text
forall a. Monoid a => a
mempty
, $sel:flushIntervalSeconds:ConfigI :: Natural
flushIntervalSeconds = Natural
5
, $sel:pollIntervalSeconds:ConfigI :: Natural
pollIntervalSeconds = Natural
30
, $sel:userKeyLRUCapacity:ConfigI :: Natural
userKeyLRUCapacity = Natural
1000
, $sel:inlineUsersInEvents:ConfigI :: Bool
inlineUsersInEvents = Bool
False
, $sel:eventsCapacity:ConfigI :: Natural
eventsCapacity = Natural
10000
, $sel:logger:ConfigI :: LoggingT IO () -> IO ()
logger = LoggingT IO () -> IO ()
forall (m :: * -> *) a. MonadIO m => LoggingT m a -> m a
runStdoutLoggingT
, $sel:sendEvents:ConfigI :: Bool
sendEvents = Bool
True
, $sel:offline:ConfigI :: Bool
offline = Bool
False
, $sel:requestTimeoutSeconds:ConfigI :: Natural
requestTimeoutSeconds = Natural
30
, $sel:useLdd:ConfigI :: Bool
useLdd = Bool
False
}
configSetKey :: Text -> Config -> Config
configSetKey :: Text -> Config -> Config
configSetKey = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Text -> ConfigI -> ConfigI) -> Text -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "key" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"key"
configSetBaseURI :: Text -> Config -> Config
configSetBaseURI :: Text -> Config -> Config
configSetBaseURI = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Text -> ConfigI -> ConfigI) -> Text -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "baseURI" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"baseURI"
configSetStreamURI :: Text -> Config -> Config
configSetStreamURI :: Text -> Config -> Config
configSetStreamURI = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Text -> ConfigI -> ConfigI) -> Text -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "streamURI" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"streamURI"
configSetEventsURI :: Text -> Config -> Config
configSetEventsURI :: Text -> Config -> Config
configSetEventsURI = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Text -> ConfigI -> ConfigI) -> Text -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "eventsURI" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"eventsURI"
configSetStoreBackend :: Maybe StoreInterface -> Config -> Config
configSetStoreBackend :: Maybe StoreInterface -> Config -> Config
configSetStoreBackend = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Maybe StoreInterface -> ConfigI -> ConfigI)
-> Maybe StoreInterface
-> Config
-> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "storeBackend" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"storeBackend"
configSetStoreTTL :: Natural -> Config -> Config
configSetStoreTTL :: Natural -> Config -> Config
configSetStoreTTL = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Natural -> ConfigI -> ConfigI) -> Natural -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "storeTTLSeconds" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"storeTTLSeconds"
configSetStreaming :: Bool -> Config -> Config
configSetStreaming :: Bool -> Config -> Config
configSetStreaming = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Bool -> ConfigI -> ConfigI) -> Bool -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "streaming" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"streaming"
configSetAllAttributesPrivate :: Bool -> Config -> Config
configSetAllAttributesPrivate :: Bool -> Config -> Config
configSetAllAttributesPrivate = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Bool -> ConfigI -> ConfigI) -> Bool -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "allAttributesPrivate" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"allAttributesPrivate"
configSetPrivateAttributeNames :: Set Text -> Config -> Config
configSetPrivateAttributeNames :: Set Text -> Config -> Config
configSetPrivateAttributeNames = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Set Text -> ConfigI -> ConfigI) -> Set Text -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "privateAttributeNames" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"privateAttributeNames"
configSetFlushIntervalSeconds :: Natural -> Config -> Config
configSetFlushIntervalSeconds :: Natural -> Config -> Config
configSetFlushIntervalSeconds = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Natural -> ConfigI -> ConfigI) -> Natural -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "flushIntervalSeconds" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"flushIntervalSeconds"
configSetPollIntervalSeconds :: Natural -> Config -> Config
configSetPollIntervalSeconds :: Natural -> Config -> Config
configSetPollIntervalSeconds = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Natural -> ConfigI -> ConfigI) -> Natural -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "pollIntervalSeconds" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"pollIntervalSeconds"
configSetUserKeyLRUCapacity :: Natural -> Config -> Config
configSetUserKeyLRUCapacity :: Natural -> Config -> Config
configSetUserKeyLRUCapacity = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Natural -> ConfigI -> ConfigI) -> Natural -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "userKeyLRUCapacity" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"userKeyLRUCapacity"
configSetInlineUsersInEvents :: Bool -> Config -> Config
configSetInlineUsersInEvents :: Bool -> Config -> Config
configSetInlineUsersInEvents = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Bool -> ConfigI -> ConfigI) -> Bool -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "inlineUsersInEvents" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"inlineUsersInEvents"
configSetEventsCapacity :: Natural -> Config -> Config
configSetEventsCapacity :: Natural -> Config -> Config
configSetEventsCapacity = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Natural -> ConfigI -> ConfigI) -> Natural -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "eventsCapacity" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"eventsCapacity"
configSetLogger :: (LoggingT IO () -> IO ()) -> Config -> Config
configSetLogger :: (LoggingT IO () -> IO ()) -> Config -> Config
configSetLogger = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> ((LoggingT IO () -> IO ()) -> ConfigI -> ConfigI)
-> (LoggingT IO () -> IO ())
-> Config
-> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "logger" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"logger"
configSetSendEvents :: Bool -> Config -> Config
configSetSendEvents :: Bool -> Config -> Config
configSetSendEvents = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Bool -> ConfigI -> ConfigI) -> Bool -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "sendEvents" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"sendEvents"
configSetOffline :: Bool -> Config -> Config
configSetOffline :: Bool -> Config -> Config
configSetOffline = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Bool -> ConfigI -> ConfigI) -> Bool -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "offline" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"offline"
configSetRequestTimeoutSeconds :: Natural -> Config -> Config
configSetRequestTimeoutSeconds :: Natural -> Config -> Config
configSetRequestTimeoutSeconds = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Natural -> ConfigI -> ConfigI) -> Natural -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "requestTimeoutSeconds" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"requestTimeoutSeconds"
configSetUseLdd :: Bool -> Config -> Config
configSetUseLdd :: Bool -> Config -> Config
configSetUseLdd = (ConfigI -> ConfigI) -> Config -> Config
mapConfig ((ConfigI -> ConfigI) -> Config -> Config)
-> (Bool -> ConfigI -> ConfigI) -> Bool -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s a. HasField' "useLdd" s a => a -> s -> s
forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"useLdd"