| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Hasura.Server.AppStateRef
Synopsis
- data AppStateRef impl
- initialiseAppStateRef :: MonadIO m => TLSAllowListRef -> Maybe MetricsConfigRef -> ServerMetrics -> RebuildableSchemaCache -> RebuildableAppContext impl -> m (AppStateRef impl)
- withSchemaCacheUpdate :: (MonadIO m, MonadBaseControl IO m, MonadError QErr m) => AppStateRef impl -> Logger Hasura -> Maybe (TVar Bool) -> m (a, RebuildableSchemaCache) -> m a
- withSchemaCacheReadUpdate :: (MonadIO m, MonadBaseControl IO m, MonadError QErr m) => AppStateRef impl -> Logger Hasura -> Maybe (TVar Bool) -> (RebuildableSchemaCache -> m (a, RebuildableSchemaCache)) -> m a
- readAppContextRef :: AppStateRef impl -> IO (RebuildableAppContext impl)
- getRebuildableSchemaCacheWithVersion :: AppStateRef impl -> IO RebuildableSchemaCache
- data TLSAllowListRef
- createTLSAllowListRef :: [TlsAllow] -> IO TLSAllowListRef
- readTLSAllowList :: TLSAllowListRef -> IO [TlsAllow]
- data MetricsConfigRef
- createMetricsConfigRef :: MetricsConfig -> IO MetricsConfigRef
- readMetricsConfig :: MetricsConfigRef -> IO MetricsConfig
- getSchemaCache :: AppStateRef impl -> IO SchemaCache
- getSchemaCacheWithVersion :: AppStateRef impl -> IO SchemaCache
- getAppContext :: AppStateRef impl -> IO AppContext
- logInconsistentMetadata :: Logger Hasura -> [InconsistentMetadata] -> IO ()
- withAppContextUpdate :: (MonadIO m, MonadBaseControl IO m) => AppStateRef impl -> m (a, RebuildableAppContext impl) -> m a
- updateAppStateRef :: (MonadIO m, MonadBaseControl IO m) => AppStateRef impl -> Logger Hasura -> (RebuildableAppContext impl -> m (RebuildableAppContext impl, RebuildableSchemaCache)) -> m ()
Documentation
data AppStateRef impl Source #
A mutable reference to a AppState, plus
- a write lock,
- update version tracking, and
- a gauge metric that tracks the metadata version of the
SchemaCache.
initialiseAppStateRef :: MonadIO m => TLSAllowListRef -> Maybe MetricsConfigRef -> ServerMetrics -> RebuildableSchemaCache -> RebuildableAppContext impl -> m (AppStateRef impl) Source #
Build a new AppStateRef.
This function also updates the TLSAllowListRef to make it point to the
newly minted SchemaCacheRef.
withSchemaCacheUpdate :: (MonadIO m, MonadBaseControl IO m, MonadError QErr m) => AppStateRef impl -> Logger Hasura -> Maybe (TVar Bool) -> m (a, RebuildableSchemaCache) -> m a Source #
withSchemaCacheReadUpdate :: (MonadIO m, MonadBaseControl IO m, MonadError QErr m) => AppStateRef impl -> Logger Hasura -> Maybe (TVar Bool) -> (RebuildableSchemaCache -> m (a, RebuildableSchemaCache)) -> m a Source #
Set the AppStateRef to the RebuildableSchemaCache produced by the
given action.
An internal lock ensures that at most one update to the AppStateRef may
proceed at a time.
readAppContextRef :: AppStateRef impl -> IO (RebuildableAppContext impl) Source #
Read the contents of the AppStateRef to get the latest RebuildableAppContext
getRebuildableSchemaCacheWithVersion :: AppStateRef impl -> IO RebuildableSchemaCache Source #
Read the contents of the AppStateRef to get the latest RebuildableSchemaCache and SchemaCacheVer
data TLSAllowListRef Source #
Reference to a TLS AllowList, used for dynamic TLS settings in the app's HTTP Manager.
This exists to break a chicken-and-egg problem in the initialisation of the
engine: the IO action that dynamically reads the TLS settings reads it from
the schema cache; but to build the schema cache we need a HTTP manager that
has access to the TLS settings... In the past, we were using a temporary HTTP
Manager to create the first schema cache, to then create the *real* Manager
that would refer to the list in the schema cache. Now, instead, we only
create one Manager, which uses a TLSAllowListRef to dynamically access the
Allow List.
createTLSAllowListRef :: [TlsAllow] -> IO TLSAllowListRef Source #
Creates a new TLSAllowListRef that points to the given list.
readTLSAllowList :: TLSAllowListRef -> IO [TlsAllow] Source #
Reads the TLS AllowList by attempting to read from the schema cache, and defaulting to the list given when the ref was created.
data MetricsConfigRef Source #
Reference to the metadata's MetricsConfig.
Similarly to the TLSAllowListRef, this exists to break a
chicken-and-egg problem in the initialisation of the engine: the
implementation of several behaviour classes requires access to said
config, but those classes are implemented on the app monad, that
doesn't have access to the schema cache. This small type allows the
app monad to have access to the config, even before we build the
first schema cache.
createMetricsConfigRef :: MetricsConfig -> IO MetricsConfigRef Source #
Creates a new MetricsConfigRef that points to the given config.
readMetricsConfig :: MetricsConfigRef -> IO MetricsConfig Source #
Reads the TLS AllowList by attempting to read from the schema cache, and defaulting to the list given when the ref was created.
getSchemaCache :: AppStateRef impl -> IO SchemaCache Source #
Read the latest SchemaCache from the AppStateRef.
getSchemaCacheWithVersion :: AppStateRef impl -> IO SchemaCache Source #
Read the latest SchemaCache and its version from the AppStateRef.
getAppContext :: AppStateRef impl -> IO AppContext Source #
Read the latest AppContext from the AppStateRef.
logInconsistentMetadata :: Logger Hasura -> [InconsistentMetadata] -> IO () Source #
Formats and logs a list of inconsistent metadata objects.
withAppContextUpdate :: (MonadIO m, MonadBaseControl IO m) => AppStateRef impl -> m (a, RebuildableAppContext impl) -> m a Source #
Set the RebuildableAppContext to the AppStateRef produced by the given
action.
An internal lock ensures that at most one update to the AppStateRef may
proceed at a time.
updateAppStateRef :: (MonadIO m, MonadBaseControl IO m) => AppStateRef impl -> Logger Hasura -> (RebuildableAppContext impl -> m (RebuildableAppContext impl, RebuildableSchemaCache)) -> m () Source #
Set the AppStateRef, atomically, to the (RebuildableSchemaCache,
RebuildableAppContext) produced by the given action.
An internal lock ensures that at most one update to the AppStateRef may
proceed at a time.