@@ -15,7 +15,6 @@ import Control.Monad
15import Control.Monad.Catch
15import Control.Monad.Catch
16import Control.Monad.IO.Class
16import Control.Monad.IO.Class
17import Control.Monad.Reader
17import Control.Monad.Reader
19import Data.Monoid
18import Data.Monoid
20import Network.Google.Auth
19import Network.Google.Auth
21import Network.Google.Internal.Types
20import Network.Google.Internal.Types
@@ -35,48 +34,33 @@ data Env = Env
35-- total field initialisation.
34-- total field initialisation.
37class HasEnv a where
36class HasEnv a where
38− environment :: Lens' a Env
37+ environment :: Lens' a Env
39 {-# MINIMAL environment #-}
38 {-# MINIMAL environment #-}
41− -- -- | The function used to determine if an 'HttpException' should be retried.
42− -- envRetryCheck :: Lens' a (Int -> HttpException -> Bool)
45− -- envRetryPolicy :: Lens' a RetryPolicy
48− envTimeout :: Lens' a (Maybe Seconds)
41+ envTimeout :: Lens' a (Maybe Seconds)
50 -- | The 'Manager' used to create and manage open HTTP connections.
43 -- | The 'Manager' used to create and manage open HTTP connections.
51− envManager :: Lens' a Manager
44+ envManager :: Lens' a Manager
53 -- | The credentials used to sign requests for authentication with Google.
46 -- | The credentials used to sign requests for authentication with Google.
54− envAuth :: Lens' a Auth
47+ envAuth :: Lens' a Auth
56− -- envRetryCheck = environment . lens _envRetryCheck (\s a -> s { _envRetryCheck = a })
57− -- envRetryPolicy = environment . lens _envRetryPolicy (\s a -> s { _envRetryPolicy = a })
58− envTimeout = environment . lens _envTimeout (\s a -> s { _envTimeout = a })
49+ envTimeout = environment . lens _envTimeout (\s a -> s { _envTimeout = a })
59− envManager = environment . lens _envManager (\s a -> s { _envManager = a })
50+ envManager = environment . lens _envManager (\s a -> s { _envManager = a })
60− envAuth = environment . lens _envAuth (\s a -> s { _envAuth = a })
51+ envAuth = environment . lens _envAuth (\s a -> s { _envAuth = a })
62instance HasEnv Env where
53instance HasEnv Env where
63 environment = id
54 environment = id
65−-- -- | Scope an action such that any retry logic for the 'Env' is
66−-- -- ignored and any requests will at most be sent once.
67−-- once :: (MonadReader r m, HasEnv r) => m a -> m a
68−-- once = policy (limitRetries 0)
71−-- policy :: (MonadReader r m, HasEnv r) => RetryPolicy -> m a -> m a
72−-- policy r = local (envRetryPolicy <>~ r)
74-- | Scope an action such that any HTTP response will use this timeout value.
56-- | Scope an action such that any HTTP response will use this timeout value.
76-- Default timeouts are chosen by considering:
58-- Default timeouts are chosen by considering:
78-- * This 'timeout', if set.
60-- * This 'timeout', if set.
62+-- * The related 'Service' timeout for the sent request if set. (Usually 70s)
80-- * The 'envManager' timeout if set.
64-- * The 'envManager' timeout if set.
82-- * The default 'ClientRequest' timeout. (Approximately 30s)
66-- * The default 'ClientRequest' timeout. (Approximately 30s)
@@ -94,5 +78,3 @@ newEnv c = liftIO (newManager conduitManagerSettings) >>= newEnvWith c
94-- | /See:/ 'newEnv'
78-- | /See:/ 'newEnv'
95newEnvWith :: (MonadIO m, MonadCatch m) => Credentials -> Manager -> m Env
79newEnvWith :: (MonadIO m, MonadCatch m) => Credentials -> Manager -> m Env
96newEnvWith c m = Env Nothing m <$> getAuth c
80newEnvWith c m = Env Nothing m <$> getAuth c