]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/API/Admin/EnvTypes.hs
[CLEAN] fix imports / explicit instances / warnings
[gargantext.git] / src / Gargantext / API / Admin / EnvTypes.hs
1 -- |
2
3 {-# LANGUAGE TemplateHaskell #-}
4
5 module Gargantext.API.Admin.EnvTypes where
6
7 import Control.Lens
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
16
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
23
24 data Env = Env
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
33 }
34 deriving (Generic)
35
36 makeLenses ''Env
37
38 instance HasConfig Env where
39 hasConfig = env_config
40
41 instance HasConnectionPool Env where
42 connPool = env_pool
43
44 instance HasNodeStoryEnv Env where
45 hasNodeStory = env_nodeStory
46
47 instance HasNodeStoryVar Env where
48 hasNodeStoryVar = hasNodeStory . nse_getter
49
50 instance HasNodeStorySaver Env where
51 hasNodeStorySaver = hasNodeStory . nse_saver
52
53 instance HasSettings Env where
54 settings = env_settings
55
56
57
58
59 instance Servant.Job.Core.HasEnv Env (Job JobLog JobLog) where
60 _env = env_scrapers . Servant.Job.Core._env
61
62 instance HasJobEnv Env JobLog JobLog where
63 job_env = env_scrapers
64
65 data MockEnv = MockEnv
66 { _menv_firewall :: !FireWall
67 }
68 deriving (Generic)
69
70 makeLenses ''MockEnv
71
72
73
74
75 data DevEnv = DevEnv
76 { _dev_env_settings :: !Settings
77 , _dev_env_config :: !GargConfig
78 , _dev_env_pool :: !(Pool Connection)
79 , _dev_env_nodeStory :: !NodeStoryEnv
80 }
81
82 makeLenses ''DevEnv
83
84 instance HasConfig DevEnv where
85 hasConfig = dev_env_config
86
87 instance HasConnectionPool DevEnv where
88 connPool = dev_env_pool
89
90 instance HasSettings DevEnv where
91 settings = dev_env_settings
92
93
94
95 instance HasNodeStoryEnv DevEnv where
96 hasNodeStory = dev_env_nodeStory
97
98 instance HasNodeStoryVar DevEnv where
99 hasNodeStoryVar = hasNodeStory . nse_getter
100
101 instance HasNodeStorySaver DevEnv where
102 hasNodeStorySaver = hasNodeStory . nse_saver
103