From 9cdee8017606580a3c4e8ca7de854cf90e41d9cf Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Thu, 21 Sep 2017 18:09:23 +0300 Subject: Allow configure backend response timeout --- src/Sproxy/Config.hs | 4 +++- src/Sproxy/Server.hs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Sproxy/Config.hs b/src/Sproxy/Config.hs index f1d8004..cb32a06 100644 --- a/src/Sproxy/Config.hs +++ b/src/Sproxy/Config.hs @@ -65,6 +65,7 @@ data BackendConf = BackendConf , beCookieDomain :: Maybe String , beCookieMaxAge :: Int64 , beConnCount :: Int + , beTimeout :: Int } deriving (Show) instance FromJSON BackendConf where @@ -75,7 +76,8 @@ instance FromJSON BackendConf where m .:? "cookie_name" .!= "sproxy" <*> m .:? "cookie_domain" <*> m .:? "cookie_max_age" .!= (7 * 24 * 60 * 60) <*> - m .:? "conn_count" .!= 32 + m .:? "conn_count" .!= 32 <*> + m .:? "timeout" .!= 30 parseJSON _ = empty data OAuth2Conf = OAuth2Conf diff --git a/src/Sproxy/Server.hs b/src/Sproxy/Server.hs index 75a50a4..2477364 100644 --- a/src/Sproxy/Server.hs +++ b/src/Sproxy/Server.hs @@ -13,7 +13,7 @@ import Data.Word (Word16) import Data.Yaml.Include (decodeFileEither) import Network.HTTP.Client (Manager, ManagerSettings(..), defaultManagerSettings, newManager, - socketConnection) + responseTimeoutMicro, socketConnection) import Network.HTTP.Client.Internal (Connection) import Network.Socket (Family(AF_INET, AF_UNIX), SockAddr(SockAddrInet, SockAddrUnix), @@ -152,6 +152,7 @@ newBackendManager be = do defaultManagerSettings { managerRawConnection = return $ \_ _ _ -> openConn , managerConnCount = beConnCount be + , managerResponseTimeout = responseTimeoutMicro (1000000 * beTimeout be) } newServer :: ConfigFile -> IO (Settings -> Socket -> Application -> IO ()) -- cgit v1.2.3