3 {-# LANGUAGE TemplateHaskell #-}
5 module Gargantext.API.Admin.EnvTypes where
8 import Data.Pool (Pool)
9 import Database.PostgreSQL.Simple (Connection)
10 import GHC.Generics (Generic)
11 import Network.HTTP.Client (Manager)
12 import Servant.Client (BaseUrl)
13 import Servant.Job.Async (HasJobEnv(..), Job)
14 import System.Log.FastLogger
15 import qualified Servant.Job.Core
17 import Gargantext.API.Admin.Types
18 import Gargantext.API.Admin.Orchestrator.Types
19 import Gargantext.API.Ngrams.Types (HasRepoVar(..), HasRepoSaver(..), HasRepo(..), RepoEnv(..))
20 import Gargantext.Database.Prelude (HasConnectionPool(..), HasConfig(..))
21 import Gargantext.Prelude
22 import Gargantext.Prelude.Config (GargConfig(..))
26 { _env_settings :: !Settings
27 , _env_logger :: !LoggerSet
28 , _env_pool :: !(Pool Connection)
29 , _env_repo :: !RepoEnv
30 , _env_manager :: !Manager
31 , _env_self_url :: !BaseUrl
32 , _env_scrapers :: !ScrapersEnv
33 , _env_config :: !GargConfig
39 instance HasConfig Env where
42 instance HasConnectionPool Env where
45 instance HasRepoVar Env where
46 repoVar = repoEnv . repoVar
48 instance HasRepoSaver Env where
49 repoSaver = repoEnv . repoSaver
51 instance HasRepo Env where
54 instance HasSettings Env where
55 settings = env_settings
57 instance Servant.Job.Core.HasEnv Env (Job JobLog JobLog) where
58 _env = env_scrapers . Servant.Job.Core._env
60 instance HasJobEnv Env JobLog JobLog where
61 job_env = env_scrapers
63 data MockEnv = MockEnv
64 { _menv_firewall :: !FireWall
72 { _dev_env_pool :: !(Pool Connection)
73 , _dev_env_repo :: !RepoEnv
74 , _dev_env_settings :: !Settings
75 , _dev_env_config :: !GargConfig
80 instance HasConfig DevEnv where
81 config = dev_env_config
83 instance HasConnectionPool DevEnv where
84 connPool = dev_env_pool
86 instance HasRepoVar DevEnv where
87 repoVar = repoEnv . repoVar
89 instance HasRepoSaver DevEnv where
90 repoSaver = repoEnv . repoSaver
92 instance HasRepo DevEnv where
93 repoEnv = dev_env_repo
95 instance HasSettings DevEnv where
96 settings = dev_env_settings