graphql-engine/server/src-lib/Hasura/Backends/MSSQL/DDL/Source.hs
Swann Moreau d3611af58d server: lazy event catalog initialisation
event catalog:
- `hdb_catalog` is no longer automatically created
- catalog is initialised when the first event trigger is created
- catalog initialisation is done during the schema cache build, using `ArrowCache` so it is only run in response to a change to the set of event triggers

event queue:
- `processEventQueue` thread is prevented from starting when `HASURA_GRAPHQL_EVENTS_FETCH_INTERVAL=0`
- `processEventQueue` thread only processes sources for which at least one event trigger exists in some table in the source

Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
GitOrigin-RevId: 73f256465d62490cd2b59dcd074718679993d4fe
2021-05-25 06:51:03 +00:00

42 lines
1.2 KiB
Haskell

module Hasura.Backends.MSSQL.DDL.Source
( resolveSourceConfig
, resolveDatabaseMetadata
, postDropSourceHook
)
where
import Hasura.Prelude
import Hasura.Backends.MSSQL.Connection
import Hasura.Backends.MSSQL.Meta
import Hasura.Base.Error
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.Source
import Hasura.SQL.Backend
resolveSourceConfig
:: (MonadIO m)
=> SourceName
-> MSSQLConnConfiguration
-> m (Either QErr MSSQLSourceConfig)
resolveSourceConfig _name (MSSQLConnConfiguration connInfo) = runExceptT do
(connString, mssqlPool) <- createMSSQLPool connInfo
pure $ MSSQLSourceConfig connString mssqlPool
resolveDatabaseMetadata
:: (MonadIO m)
=> MSSQLSourceConfig
-> m (Either QErr (ResolvedSource 'MSSQL))
resolveDatabaseMetadata config = runExceptT do
dbTablesMetadata <- loadDBMetadata pool
pure $ ResolvedSource config dbTablesMetadata mempty mempty
where
MSSQLSourceConfig _connString pool = config
postDropSourceHook
:: (MonadIO m)
=> MSSQLSourceConfig -> m ()
postDropSourceHook (MSSQLSourceConfig _ pool) =
-- Close the connection
liftIO $ drainMSSQLPool pool