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
59 instance Servant.Job.Core.HasEnv Env (Job JobLog JobLog) where
60 _env = env_scrapers . Servant.Job.Core._env
62 instance HasJobEnv Env JobLog JobLog where
63 job_env = env_scrapers
65 data MockEnv = MockEnv
66 { _menv_firewall :: !FireWall
76 { _dev_env_settings :: !Settings
77 , _dev_env_config :: !GargConfig
78 , _dev_env_pool :: !(Pool Connection)
79 , _dev_env_nodeStory :: !NodeStoryEnv
84 instance HasConfig DevEnv where
85 hasConfig = dev_env_config
87 instance HasConnectionPool DevEnv where
88 connPool = dev_env_pool
90 instance HasSettings DevEnv where
91 settings = dev_env_settings
95 instance HasNodeStoryEnv DevEnv where
96 hasNodeStory = dev_env_nodeStory
98 instance HasNodeStoryVar DevEnv where
99 hasNodeStoryVar = hasNodeStory . nse_getter
101 instance HasNodeStorySaver DevEnv where
102 hasNodeStorySaver = hasNodeStory . nse_saver