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(..))
23 import Gargantext.Core.NodeStory
26 { _env_settings :: !Settings
27 , _env_logger :: !LoggerSet
28 , _env_pool :: !(Pool Connection)
29 , _env_repo :: !RepoEnv
30 , _env_nodeStory :: !NodeStoryEnv
31 , _env_manager :: !Manager
32 , _env_self_url :: !BaseUrl
33 , _env_scrapers :: !ScrapersEnv
34 , _env_config :: !GargConfig
40 instance HasConfig Env where
41 hasConfig = env_config
43 instance HasConnectionPool Env where
46 instance HasRepoVar Env where
47 repoVar = repoEnv . repoVar
49 instance HasRepoSaver Env where
50 repoSaver = repoEnv . repoSaver
52 instance HasRepo Env where
55 instance HasSettings Env where
56 settings = env_settings
58 instance Servant.Job.Core.HasEnv Env (Job JobLog JobLog) where
59 _env = env_scrapers . Servant.Job.Core._env
61 instance HasJobEnv Env JobLog JobLog where
62 job_env = env_scrapers
64 data MockEnv = MockEnv
65 { _menv_firewall :: !FireWall
73 { _dev_env_pool :: !(Pool Connection)
74 , _dev_env_repo :: !RepoEnv
75 , _dev_env_settings :: !Settings
76 , _dev_env_config :: !GargConfig
81 instance HasConfig DevEnv where
82 hasConfig = dev_env_config
84 instance HasConnectionPool DevEnv where
85 connPool = dev_env_pool
87 instance HasRepoVar DevEnv where
88 repoVar = repoEnv . repoVar
90 instance HasRepoSaver DevEnv where
91 repoSaver = repoEnv . repoSaver
93 instance HasRepo DevEnv where
94 repoEnv = dev_env_repo
96 instance HasSettings DevEnv where
97 settings = dev_env_settings