aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2017-09-21 18:09:23 +0300
committerIgor Pashev <pashev.igor@gmail.com>2017-09-21 18:09:23 +0300
commit9cdee8017606580a3c4e8ca7de854cf90e41d9cf (patch)
treef903d0d69ab4df18ac8187d9b39e1efbb2921db1 /src
parent392d665b9beeb767a2adbd75b9147c41a4d2a033 (diff)
downloadsproxy2-9cdee8017606580a3c4e8ca7de854cf90e41d9cf.tar.gz
Allow configure backend response timeout
Diffstat (limited to 'src')
-rw-r--r--src/Sproxy/Config.hs4
-rw-r--r--src/Sproxy/Server.hs3
2 files changed, 5 insertions, 2 deletions
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 ())