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.Database.Prelude (HasConnectionPool(..), HasConfig(..))
20 import Gargantext.Prelude
21 import Gargantext.Prelude.Config (GargConfig(..))
22 import Gargantext.Core.NodeStory
25 { _env_settings :: !Settings
26 , _env_logger :: !LoggerSet
27 , _env_pool :: !(Pool Connection)
28 , _env_nodeStory :: !NodeStoryEnv
29 , _env_manager :: !Manager
30 , _env_self_url :: !BaseUrl
31 , _env_scrapers :: !ScrapersEnv
32 , _env_config :: !GargConfig
38 instance HasConfig Env where
39 hasConfig = env_config
41 instance HasConnectionPool Env where
44 instance HasNodeStoryEnv Env where
45 hasNodeStory = env_nodeStory
47 instance HasNodeStoryVar Env where
48 hasNodeStoryVar = hasNodeStory . nse_getter
50 instance HasNodeStorySaver Env where
51 hasNodeStorySaver = hasNodeStory . nse_saver
53 instance HasSettings Env where
54 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
74 { _dev_env_settings :: !Settings
75 , _dev_env_config :: !GargConfig
76 , _dev_env_pool :: !(Pool Connection)
77 , _dev_env_nodeStory :: !NodeStoryEnv
82 instance HasConfig DevEnv where
83 hasConfig = dev_env_config
85 instance HasConnectionPool DevEnv where
86 connPool = dev_env_pool
88 instance HasSettings DevEnv where
89 settings = dev_env_settings
92 instance HasNodeStoryEnv DevEnv where
93 hasNodeStory = dev_env_nodeStory
95 instance HasNodeStoryVar DevEnv where
96 hasNodeStoryVar = hasNodeStory . nse_getter
98 instance HasNodeStorySaver DevEnv where
99 hasNodeStorySaver = hasNodeStory . nse_saver