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.Ngrams.Types (HasRepoVar(..), HasRepoSaver(..), HasRepo(..), RepoEnv(..))
18 import Gargantext.API.Admin.Types
19 import Gargantext.API.Admin.Orchestrator.Types
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 HasNodeStoryEnv Env where
47 hasNodeStory = env_nodeStory
49 instance HasNodeStoryVar Env where
50 hasNodeStoryVar = hasNodeStory . nse_getter
52 instance HasNodeStorySaver Env where
53 hasNodeStorySaver = hasNodeStory . nse_saver
55 instance HasSettings Env where
56 settings = env_settings
59 instance HasRepoVar Env where
60 repoVar = repoEnv . repoVar
61 instance HasRepoSaver Env where
62 repoSaver = repoEnv . repoSaver
63 instance HasRepo Env where
69 instance Servant.Job.Core.HasEnv Env (Job JobLog JobLog) where
70 _env = env_scrapers . Servant.Job.Core._env
72 instance HasJobEnv Env JobLog JobLog where
73 job_env = env_scrapers
75 data MockEnv = MockEnv
76 { _menv_firewall :: !FireWall
85 { _dev_env_settings :: !Settings
86 , _dev_env_repo :: !RepoEnv
87 , _dev_env_config :: !GargConfig
88 , _dev_env_pool :: !(Pool Connection)
89 , _dev_env_nodeStory :: !NodeStoryEnv
94 instance HasConfig DevEnv where
95 hasConfig = dev_env_config
97 instance HasConnectionPool DevEnv where
98 connPool = dev_env_pool
100 instance HasSettings DevEnv where
101 settings = dev_env_settings
104 instance HasNodeStoryEnv DevEnv where
105 hasNodeStory = dev_env_nodeStory
107 instance HasNodeStoryVar DevEnv where
108 hasNodeStoryVar = hasNodeStory . nse_getter
110 instance HasNodeStorySaver DevEnv where
111 hasNodeStorySaver = hasNodeStory . nse_saver
114 instance HasRepoVar DevEnv where
115 repoVar = repoEnv . repoVar
116 instance HasRepoSaver DevEnv where
117 repoSaver = repoEnv . repoSaver
118 instance HasRepo DevEnv where
119 repoEnv = dev_env_repo