module Database.EventStore.Internal.Settings where
import Network.Connection (TLSSettings)
import Database.EventStore.Internal.Logger
import Database.EventStore.Internal.Prelude
data Flag
= None
| Authenticated
deriving Int -> Flag -> ShowS
[Flag] -> ShowS
Flag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Flag] -> ShowS
$cshowList :: [Flag] -> ShowS
show :: Flag -> String
$cshow :: Flag -> String
showsPrec :: Int -> Flag -> ShowS
$cshowsPrec :: Int -> Flag -> ShowS
Show
flagWord8 :: Flag -> Word8
flagWord8 :: Flag -> Word8
flagWord8 Flag
None = Word8
0x00
flagWord8 Flag
Authenticated = Word8
0x01
data Credentials
= Credentials
{ Credentials -> ByteString
credLogin :: !ByteString
, Credentials -> ByteString
credPassword :: !ByteString
}
deriving (Credentials -> Credentials -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Credentials -> Credentials -> Bool
$c/= :: Credentials -> Credentials -> Bool
== :: Credentials -> Credentials -> Bool
$c== :: Credentials -> Credentials -> Bool
Eq, Int -> Credentials -> ShowS
[Credentials] -> ShowS
Credentials -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Credentials] -> ShowS
$cshowList :: [Credentials] -> ShowS
show :: Credentials -> String
$cshow :: Credentials -> String
showsPrec :: Int -> Credentials -> ShowS
$cshowsPrec :: Int -> Credentials -> ShowS
Show)
credentials :: ByteString
-> ByteString
-> Credentials
credentials :: ByteString -> ByteString -> Credentials
credentials = ByteString -> ByteString -> Credentials
Credentials
data Retry
= AtMost Int
| KeepRetrying
atMost :: Int -> Retry
atMost :: Int -> Retry
atMost = Int -> Retry
AtMost
keepRetrying :: Retry
keepRetrying :: Retry
keepRetrying = Retry
KeepRetrying
data Settings
= Settings
{ Settings -> NominalDiffTime
s_heartbeatInterval :: NominalDiffTime
, Settings -> NominalDiffTime
s_heartbeatTimeout :: NominalDiffTime
, Settings -> Bool
s_requireMaster :: Bool
, Settings -> Retry
s_retry :: Retry
, Settings -> NominalDiffTime
s_reconnect_delay :: NominalDiffTime
, Settings -> Maybe TLSSettings
s_ssl :: Maybe TLSSettings
, Settings -> LogType
s_loggerType :: LogType
, Settings -> LoggerFilter
s_loggerFilter :: LoggerFilter
, Settings -> Bool
s_loggerDetailed :: Bool
, Settings -> NominalDiffTime
s_operationTimeout :: NominalDiffTime
, Settings -> Retry
s_operationRetry :: Retry
, Settings -> MonitoringBackend
s_monitoring :: MonitoringBackend
, Settings -> Maybe Text
s_defaultConnectionName :: Maybe Text
, Settings -> Maybe Credentials
s_defaultUserCredentials :: Maybe Credentials
}
defaultSettings :: Settings
defaultSettings :: Settings
defaultSettings = Settings
{ s_heartbeatInterval :: NominalDiffTime
s_heartbeatInterval = Float -> NominalDiffTime
msDiffTime Float
750
, s_heartbeatTimeout :: NominalDiffTime
s_heartbeatTimeout = Float -> NominalDiffTime
msDiffTime Float
1500
, s_requireMaster :: Bool
s_requireMaster = Bool
True
, s_retry :: Retry
s_retry = Int -> Retry
atMost Int
3
, s_reconnect_delay :: NominalDiffTime
s_reconnect_delay = NominalDiffTime
3
, s_ssl :: Maybe TLSSettings
s_ssl = forall a. Maybe a
Nothing
, s_loggerType :: LogType
s_loggerType = LogType
LogNone
, s_loggerFilter :: LoggerFilter
s_loggerFilter = LogLevel -> LoggerFilter
LoggerLevel LogLevel
LevelInfo
, s_loggerDetailed :: Bool
s_loggerDetailed = Bool
False
, s_operationTimeout :: NominalDiffTime
s_operationTimeout = NominalDiffTime
10
, s_operationRetry :: Retry
s_operationRetry = Int -> Retry
atMost Int
3
, s_monitoring :: MonitoringBackend
s_monitoring = MonitoringBackend
noopMonitoringBackend
, s_defaultConnectionName :: Maybe Text
s_defaultConnectionName = forall a. Maybe a
Nothing
, s_defaultUserCredentials :: Maybe Credentials
s_defaultUserCredentials = forall a. Maybe a
Nothing
}
defaultSSLSettings :: TLSSettings -> Settings
defaultSSLSettings :: TLSSettings -> Settings
defaultSSLSettings TLSSettings
tls = Settings
defaultSettings { s_ssl :: Maybe TLSSettings
s_ssl = forall a. a -> Maybe a
Just TLSSettings
tls }
msDiffTime :: Float -> NominalDiffTime
msDiffTime :: Float -> NominalDiffTime
msDiffTime Float
n = forall a. Fractional a => Rational -> a
fromRational forall a b. (a -> b) -> a -> b
$ forall a. Real a => a -> Rational
toRational (Float
n forall a. Fractional a => a -> a -> a
/ Float
1000)
data MonitoringBackend =
MonitoringBackend
{ MonitoringBackend -> IO ()
monitoringBackendIncrPkgCount :: IO ()
, MonitoringBackend -> IO ()
monitoringBackendIncrConnectionDrop :: IO ()
, MonitoringBackend -> Int -> IO ()
monitoringBackendAddDataTransmitted :: Int -> IO ()
, MonitoringBackend -> IO ()
monitoringBackendIncrForceReconnect :: IO ()
, MonitoringBackend -> IO ()
monitoringBackendIncrHeartbeatTimeouts :: IO ()
}
noopMonitoringBackend :: MonitoringBackend
noopMonitoringBackend :: MonitoringBackend
noopMonitoringBackend =
MonitoringBackend
{ monitoringBackendIncrPkgCount :: IO ()
monitoringBackendIncrPkgCount = forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
, monitoringBackendIncrConnectionDrop :: IO ()
monitoringBackendIncrConnectionDrop = forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
, monitoringBackendAddDataTransmitted :: Int -> IO ()
monitoringBackendAddDataTransmitted = forall a b. a -> b -> a
const (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
, monitoringBackendIncrForceReconnect :: IO ()
monitoringBackendIncrForceReconnect = forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
, monitoringBackendIncrHeartbeatTimeouts :: IO ()
monitoringBackendIncrHeartbeatTimeouts = forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
}