module LaunchDarkly.Server.Config
( Config
, makeConfig
, configSetKey
, configSetBaseURI
, configSetStreamURI
, configSetEventsURI
, configSetStreaming
, configSetAllAttributesPrivate
, configSetPrivateAttributeNames
, configSetFlushIntervalSeconds
, configSetPollIntervalSeconds
, configSetUserKeyLRUCapacity
, configSetInlineUsersInEvents
, configSetEventsCapacity
, configSetLogger
, configSetManager
, configSetSendEvents
, configSetOffline
, configSetRequestTimeoutSeconds
, configSetStoreBackend
, configSetStoreTTL
, configSetUseLdd
, configSetDataSourceFactory
, configSetApplicationInfo
, ApplicationInfo
, makeApplicationInfo
, withApplicationValue
) where
import Control.Monad.Logger (LoggingT, runStdoutLoggingT)
import Data.Generics.Product (setField)
import Data.Set (Set)
import Data.Text (Text, dropWhileEnd)
import GHC.Natural (Natural)
import Network.HTTP.Client (Manager)
import LaunchDarkly.Server.Config.Internal (Config(..), mapConfig, ConfigI(..), ApplicationInfo, makeApplicationInfo, withApplicationValue)
import LaunchDarkly.Server.Store (StoreInterface)
import LaunchDarkly.Server.DataSource.Internal (DataSourceFactory)
makeConfig :: Text -> Config
makeConfig :: Text -> Config
makeConfig Text
key =
ConfigI -> Config
Config forall a b. (a -> b) -> a -> b
$ 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 = 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 = 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 = 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
, $sel:dataSourceFactory:ConfigI :: Maybe DataSourceFactory
dataSourceFactory = forall a. Maybe a
Nothing
, $sel:manager:ConfigI :: Maybe Manager
manager = forall a. Maybe a
Nothing
, $sel:applicationInfo:ConfigI :: Maybe ApplicationInfo
applicationInfo = forall a. Maybe a
Nothing
}
configSetKey :: Text -> Config -> Config
configSetKey :: Text -> Config -> Config
configSetKey = (ConfigI -> ConfigI) -> Config -> Config
mapConfig forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"baseURI" forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> Text -> Text
dropWhileEnd (forall a. Eq a => a -> a -> Bool
(==) Char
'/')
configSetStreamURI :: Text -> Config -> Config
configSetStreamURI :: Text -> Config -> Config
configSetStreamURI = (ConfigI -> ConfigI) -> Config -> Config
mapConfig forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"streamURI" forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> Text -> Text
dropWhileEnd (forall a. Eq a => a -> a -> Bool
(==) Char
'/')
configSetEventsURI :: Text -> Config -> Config
configSetEventsURI :: Text -> Config -> Config
configSetEventsURI = (ConfigI -> ConfigI) -> Config -> Config
mapConfig forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"eventsURI" forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> Text -> Text
dropWhileEnd (forall a. Eq a => a -> a -> Bool
(==) Char
'/')
configSetStoreBackend :: Maybe StoreInterface -> Config -> Config
configSetStoreBackend :: Maybe StoreInterface -> Config -> Config
configSetStoreBackend = (ConfigI -> ConfigI) -> Config -> Config
mapConfig forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"useLdd"
configSetDataSourceFactory :: Maybe DataSourceFactory -> Config -> Config
configSetDataSourceFactory :: Maybe DataSourceFactory -> Config -> Config
configSetDataSourceFactory = (ConfigI -> ConfigI) -> Config -> Config
mapConfig forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"dataSourceFactory"
configSetManager :: Manager -> Config -> Config
configSetManager :: Manager -> Config -> Config
configSetManager = (ConfigI -> ConfigI) -> Config -> Config
mapConfig forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"manager" forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just
configSetApplicationInfo :: ApplicationInfo -> Config -> Config
configSetApplicationInfo :: ApplicationInfo -> Config -> Config
configSetApplicationInfo = (ConfigI -> ConfigI) -> Config -> Config
mapConfig forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: Symbol) s a. HasField' f s a => a -> s -> s
setField @"applicationInfo" forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just