Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ExitCode
- data ExitException = ExitException {
- eeCode :: !ExitCode
- eeMessage :: !ByteString
- throwErrExit :: MonadIO m => forall a. ExitCode -> String -> m a
- throwErrJExit :: (ToJSON a, MonadIO m) => forall b. ExitCode -> a -> m b
- parseArgs :: EnabledLogTypes impl => IO (HGEOptions (ServeOptions impl))
- printJSON :: (ToJSON a, MonadIO m) => a -> m ()
- printYaml :: (ToJSON a, MonadIO m) => a -> m ()
- mkPGLogger :: Logger Hasura -> PGLogger
- data GlobalCtx = GlobalCtx {
- _gcMetadataDbConnInfo :: !ConnInfo
- _gcDefaultPostgresConnInfo :: !(Maybe (UrlConf, ConnInfo), Maybe Int)
- readTlsAllowlist :: SchemaCacheRef -> IO [TlsAllow]
- initGlobalCtx :: MonadIO m => Environment -> Maybe String -> PostgresConnInfo (Maybe UrlConf) -> m GlobalCtx
- data ServeCtx = ServeCtx {
- _scHttpManager :: !Manager
- _scInstanceId :: !InstanceId
- _scLoggers :: !Loggers
- _scEnabledLogTypes :: !(HashSet (EngineLogType Hasura))
- _scMetadataDbPool :: !PGPool
- _scShutdownLatch :: !ShutdownLatch
- _scSchemaCache :: !RebuildableSchemaCache
- _scSchemaCacheRef :: !SchemaCacheRef
- _scMetaVersionRef :: !(TMVar MetadataResourceVersion)
- data Loggers = Loggers {
- _lsLoggerCtx :: !(LoggerCtx Hasura)
- _lsLogger :: !(Logger Hasura)
- _lsPgLogger :: !PGLogger
- newtype PGMetadataStorageAppT m a = PGMetadataStorageAppT {
- runPGMetadataStorageAppT :: (PGPool, PGLogger) -> m a
- resolvePostgresConnInfo :: MonadIO m => Environment -> UrlConf -> Maybe Int -> m ConnInfo
- initialiseServeCtx :: (ForkableMonadIO m, MonadCatch m) => Environment -> GlobalCtx -> ServeOptions Hasura -> ServerMetrics -> ManagedT m ServeCtx
- mkLoggers :: (MonadIO m, MonadBaseControl IO m) => HashSet (EngineLogType Hasura) -> LogLevel -> ManagedT m Loggers
- migrateCatalogSchema :: (MonadIO m, MonadBaseControl IO m) => Environment -> Logger Hasura -> PGPool -> Maybe (SourceConnConfiguration ('Postgres 'Vanilla)) -> Manager -> ServerConfigCtx -> SourceResolver ('Postgres 'Vanilla) -> SourceResolver 'MSSQL -> ExtensionsSchema -> m RebuildableSchemaCache
- newtype ShutdownLatch = ShutdownLatch {
- unShutdownLatch :: MVar ()
- data ShutdownAction
- newShutdownLatch :: IO ShutdownLatch
- waitForShutdown :: ShutdownLatch -> IO ()
- shutdownGracefully :: ShutdownLatch -> IO ()
- shuttingDown :: ShutdownLatch -> IO Bool
- flushLogger :: MonadIO m => LoggerCtx impl -> m ()
- runHGEServer :: forall m impl. (MonadIO m, MonadFix m, MonadMask m, MonadStateless IO m, Forall (Pure m), UserAuthentication (TraceT m), HttpLog m, ConsoleRenderer m, MonadMetadataApiAuthorization m, MonadGQLExecutionCheck m, MonadConfigApiHandler m, MonadQueryLog m, MonadWSLog m, MonadExecuteQuery m, HasReporter m, HasResourceLimits m, MonadMetadataStorage (MetadataStorageT m), MonadResolveSource m, MonadQueryTags m) => (ServerCtx -> SpockT m ()) -> Environment -> ServeOptions impl -> ServeCtx -> UTCTime -> Maybe SubscriptionPostPollHook -> ServerMetrics -> Store EmptyMetrics -> Maybe (IO ()) -> PrometheusMetrics -> ManagedT m ()
- mkHGEServer :: forall m impl. (MonadIO m, MonadFix m, MonadMask m, MonadStateless IO m, Forall (Pure m), UserAuthentication (TraceT m), HttpLog m, ConsoleRenderer m, MonadMetadataApiAuthorization m, MonadGQLExecutionCheck m, MonadConfigApiHandler m, MonadQueryLog m, MonadWSLog m, MonadExecuteQuery m, HasReporter m, HasResourceLimits m, MonadMetadataStorage (MetadataStorageT m), MonadResolveSource m, MonadQueryTags m) => (ServerCtx -> SpockT m ()) -> Environment -> ServeOptions impl -> ServeCtx -> UTCTime -> Maybe SubscriptionPostPollHook -> ServerMetrics -> Store EmptyMetrics -> PrometheusMetrics -> ManagedT m Application
- accessDeniedErrMsg :: Text
- runInSeparateTx :: MonadIO m => TxE QErr a -> MetadataStorageT (PGMetadataStorageAppT m) a
- notifySchemaCacheSyncTx :: MetadataResourceVersion -> InstanceId -> CacheInvalidations -> TxE QErr ()
- getCatalogStateTx :: TxE QErr CatalogState
- setCatalogStateTx :: CatalogStateType -> Value -> TxE QErr ()
- mkConsoleHTML :: Text -> AuthMode -> Bool -> Maybe Text -> Either String Text
- telemetryNotice :: String
- mkPgSourceResolver :: PGLogger -> SourceResolver ('Postgres 'Vanilla)
- mkMSSQLSourceResolver :: SourceResolver 'MSSQL
Documentation
InvalidEnvironmentVariableOptionsError | |
InvalidDatabaseConnectionParamsError | |
AuthConfigurationError | |
EventSubSystemError | |
DatabaseMigrationError | |
SchemaCacheInitError | used by MT because it initialises the schema cache only these are used in app/Main.hs: |
MetadataExportError | |
MetadataCleanError | |
ExecuteProcessError | |
DowngradeProcessError |
data ExitException Source #
ExitException | |
|
Instances
Show ExitException Source # | |
Defined in Hasura.App showsPrec :: Int -> ExitException -> ShowS # show :: ExitException -> String # showList :: [ExitException] -> ShowS # | |
Exception ExitException Source # | |
Defined in Hasura.App |
throwErrJExit :: (ToJSON a, MonadIO m) => forall b. ExitCode -> a -> m b Source #
parseArgs :: EnabledLogTypes impl => IO (HGEOptions (ServeOptions impl)) Source #
mkPGLogger :: Logger Hasura -> PGLogger Source #
Context required for all graphql-engine CLI commands
GlobalCtx | |
|
readTlsAllowlist :: SchemaCacheRef -> IO [TlsAllow] Source #
:: MonadIO m | |
=> Environment | |
-> Maybe String | the metadata DB URL |
-> PostgresConnInfo (Maybe UrlConf) | the user's DB URL |
-> m GlobalCtx |
Context required for the serve
CLI command.
ServeCtx | |
|
Collection of the LoggerCtx, the regular Logger and the PGLogger TODO (from master): better naming?
Loggers | |
|
newtype PGMetadataStorageAppT m a Source #
An application with Postgres database as a metadata storage
PGMetadataStorageAppT | |
|
Instances
resolvePostgresConnInfo :: MonadIO m => Environment -> UrlConf -> Maybe Int -> m ConnInfo Source #
initialiseServeCtx :: (ForkableMonadIO m, MonadCatch m) => Environment -> GlobalCtx -> ServeOptions Hasura -> ServerMetrics -> ManagedT m ServeCtx Source #
Initializes or migrates the catalog and returns the context required to start the server.
mkLoggers :: (MonadIO m, MonadBaseControl IO m) => HashSet (EngineLogType Hasura) -> LogLevel -> ManagedT m Loggers Source #
migrateCatalogSchema :: (MonadIO m, MonadBaseControl IO m) => Environment -> Logger Hasura -> PGPool -> Maybe (SourceConnConfiguration ('Postgres 'Vanilla)) -> Manager -> ServerConfigCtx -> SourceResolver ('Postgres 'Vanilla) -> SourceResolver 'MSSQL -> ExtensionsSchema -> m RebuildableSchemaCache Source #
helper function to initialize or migrate the hdb_catalog
schema (used by pro as well)
newtype ShutdownLatch Source #
A latch for the graceful shutdown of a server process.
ShutdownLatch | |
|
data ShutdownAction Source #
Event triggers live in the user's DB and other events (cron, one-off and async actions) live in the metadata DB, so we need a way to differentiate the type of shutdown action
waitForShutdown :: ShutdownLatch -> IO () Source #
Block the current thread, waiting on the latch.
shutdownGracefully :: ShutdownLatch -> IO () Source #
Initiate a graceful shutdown of the server associated with the provided latch.
shuttingDown :: ShutdownLatch -> IO Bool Source #
Returns True if the latch is set for shutdown and vice-versa
flushLogger :: MonadIO m => LoggerCtx impl -> m () Source #
If an exception is encountered , flush the log buffer and rethrow If we do not flush the log buffer on exception, then log lines may be missed See: https://github.com/hasura/graphql-engine/issues/4772
:: forall m impl. (MonadIO m, MonadFix m, MonadMask m, MonadStateless IO m, Forall (Pure m), UserAuthentication (TraceT m), HttpLog m, ConsoleRenderer m, MonadMetadataApiAuthorization m, MonadGQLExecutionCheck m, MonadConfigApiHandler m, MonadQueryLog m, MonadWSLog m, MonadExecuteQuery m, HasReporter m, HasResourceLimits m, MonadMetadataStorage (MetadataStorageT m), MonadResolveSource m, MonadQueryTags m) | |
=> (ServerCtx -> SpockT m ()) | |
-> Environment | |
-> ServeOptions impl | |
-> ServeCtx | |
-> UTCTime | start time |
-> Maybe SubscriptionPostPollHook | |
-> ServerMetrics | |
-> Store EmptyMetrics | |
-> Maybe (IO ()) | A hook which can be called to indicate when the server is started succesfully |
-> PrometheusMetrics | |
-> ManagedT m () |
This function acts as the entrypoint for the graphql-engine webserver.
Note: at the exit of this function, or in case of a graceful server shutdown (SIGTERM, or more generally, whenever the shutdown latch is set), we need to make absolutely sure that we clean up any resources which were allocated during server setup. In the case of a multitenant process, failure to do so can lead to resource leaks.
To track these resources, we use the ManagedT monad, and attach finalizers at
the same point in the code where we allocate resources. If you fork a new
long-lived thread, or create a connection pool, or allocate any other
long-lived resource, make sure to pair the allocator with its finalizer.
There are plenty of examples throughout the code. For example, see
forkManagedT
.
Note also: the order in which the finalizers run can be important. Specifically, we want the finalizers for the logger threads to run last, so that we retain as many "thread stopping" log messages as possible. The order in which the finalizers is run is determined by the order in which they are introduced in the code.
:: forall m impl. (MonadIO m, MonadFix m, MonadMask m, MonadStateless IO m, Forall (Pure m), UserAuthentication (TraceT m), HttpLog m, ConsoleRenderer m, MonadMetadataApiAuthorization m, MonadGQLExecutionCheck m, MonadConfigApiHandler m, MonadQueryLog m, MonadWSLog m, MonadExecuteQuery m, HasReporter m, HasResourceLimits m, MonadMetadataStorage (MetadataStorageT m), MonadResolveSource m, MonadQueryTags m) | |
=> (ServerCtx -> SpockT m ()) | |
-> Environment | |
-> ServeOptions impl | |
-> ServeCtx | |
-> UTCTime | start time |
-> Maybe SubscriptionPostPollHook | |
-> ServerMetrics | |
-> Store EmptyMetrics | |
-> PrometheusMetrics | |
-> ManagedT m Application |
Part of a factorization of runHGEServer
to expose the constructed WAI
application for testing purposes. See runHGEServer
for documentation.
accessDeniedErrMsg :: Text Source #
runInSeparateTx :: MonadIO m => TxE QErr a -> MetadataStorageT (PGMetadataStorageAppT m) a Source #
notifySchemaCacheSyncTx :: MetadataResourceVersion -> InstanceId -> CacheInvalidations -> TxE QErr () Source #
getCatalogStateTx :: TxE QErr CatalogState Source #
setCatalogStateTx :: CatalogStateType -> Value -> TxE QErr () Source #
mkPgSourceResolver :: PGLogger -> SourceResolver ('Postgres 'Vanilla) Source #