Extended config data types with time bound option

Implemented connection time bound option for both V04 and V10
configurations, default value is set to 5000ms.
This commit is contained in:
Артур Файзрахманов 2015-04-30 08:59:22 +05:00
parent 107ddf9e5e
commit f74a95a852
3 changed files with 29 additions and 18 deletions

View File

@ -80,6 +80,7 @@ data KeterConfig = KeterConfig
, kconfigSetuid :: Maybe Text , kconfigSetuid :: Maybe Text
, kconfigReverseProxy :: Set ReverseProxyConfig , kconfigReverseProxy :: Set ReverseProxyConfig
, kconfigIpFromHeader :: Bool , kconfigIpFromHeader :: Bool
, kconfigConnectionTimeBound :: Int
} }
instance Default KeterConfig where instance Default KeterConfig where
@ -92,6 +93,7 @@ instance Default KeterConfig where
, kconfigSetuid = Nothing , kconfigSetuid = Nothing
, kconfigReverseProxy = Set.empty , kconfigReverseProxy = Set.empty
, kconfigIpFromHeader = False , kconfigIpFromHeader = False
, kconfigConnectionTimeBound = 5000
} }
instance ParseYamlFile KeterConfig where instance ParseYamlFile KeterConfig where
@ -104,6 +106,7 @@ instance ParseYamlFile KeterConfig where
<*> o .:? "setuid" <*> o .:? "setuid"
<*> o .:? "reverse-proxy" .!= Set.empty <*> o .:? "reverse-proxy" .!= Set.empty
<*> o .:? "ip-from-header" .!= False <*> o .:? "ip-from-header" .!= False
<*> o .:? "connection-time-bound" .!= 5000
data TLSConfig = TLSConfig !Warp.Settings !WarpTLS.TLSSettings data TLSConfig = TLSConfig !Warp.Settings !WarpTLS.TLSSettings

View File

@ -99,11 +99,12 @@ data KeterConfig = KeterConfig
-- ^ External HTTPS port when generating APPROOTs. -- ^ External HTTPS port when generating APPROOTs.
, kconfigEnvironment :: !(Map Text Text) , kconfigEnvironment :: !(Map Text Text)
-- ^ Environment variables to be passed to all apps. -- ^ Environment variables to be passed to all apps.
, kconfigConnectionTimeBound :: !Int
} }
instance ToCurrent KeterConfig where instance ToCurrent KeterConfig where
type Previous KeterConfig = V04.KeterConfig type Previous KeterConfig = V04.KeterConfig
toCurrent (V04.KeterConfig dir portman host port ssl setuid rproxy ipFromHeader) = KeterConfig toCurrent (V04.KeterConfig dir portman host port ssl setuid rproxy ipFromHeader connectionTimeBound) = KeterConfig
{ kconfigDir = dir { kconfigDir = dir
, kconfigPortPool = portman , kconfigPortPool = portman
, kconfigListeners = NonEmptyVector (LPInsecure host port) (getSSL ssl) , kconfigListeners = NonEmptyVector (LPInsecure host port) (getSSL ssl)
@ -113,6 +114,7 @@ instance ToCurrent KeterConfig where
, kconfigExternalHttpPort = 80 , kconfigExternalHttpPort = 80
, kconfigExternalHttpsPort = 443 , kconfigExternalHttpsPort = 443
, kconfigEnvironment = Map.empty , kconfigEnvironment = Map.empty
, kconfigConnectionTimeBound = connectionTimeBound
} }
where where
getSSL Nothing = V.empty getSSL Nothing = V.empty
@ -134,6 +136,7 @@ instance Default KeterConfig where
, kconfigExternalHttpPort = 80 , kconfigExternalHttpPort = 80
, kconfigExternalHttpsPort = 443 , kconfigExternalHttpsPort = 443
, kconfigEnvironment = Map.empty , kconfigEnvironment = Map.empty
, kconfigConnectionTimeBound = 5000
} }
instance ParseYamlFile KeterConfig where instance ParseYamlFile KeterConfig where
@ -153,6 +156,7 @@ instance ParseYamlFile KeterConfig where
<*> o .:? "external-http-port" .!= 80 <*> o .:? "external-http-port" .!= 80
<*> o .:? "external-https-port" .!= 443 <*> o .:? "external-https-port" .!= 443
<*> o .:? "env" .!= Map.empty <*> o .:? "env" .!= Map.empty
<*> o .:? "connection-time-bound" .!= 5000
-- | Whether we should force redirect to HTTPS routes. -- | Whether we should force redirect to HTTPS routes.
type RequiresSecure = Bool type RequiresSecure = Bool

View File

@ -32,3 +32,7 @@ listeners:
# Set additional environment variables for all apps # Set additional environment variables for all apps
# env: # env:
# key: value # key: value
# Connection time bound in milliseconds, set to 0 to have no time bound,
# i.e. keep connections alive indefinitely. Default value is 5000.
# connection-time-bound: 5000