Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Types and functions used in the process of building the schema cache from metadata information
stored in the hdb_catalog
schema in Postgres.
Synopsis
- recordInconsistencies :: (ArrowWriter (Seq CollectItem) arr, Functor f, Foldable f) => ((Maybe Value, f MetadataObject), Text) `arr` ()
- recordInconsistencyM :: MonadWriter (Seq CollectItem) m => Maybe Value -> MetadataObject -> Text -> m ()
- recordInconsistenciesM :: MonadWriter (Seq CollectItem) m => [MetadataObject] -> Text -> m ()
- data MetadataDependency = MetadataDependency MetadataObject SchemaObjId SchemaDependency
- recordDependencies :: ArrowWriter (Seq CollectItem) arr => (MetadataObject, SchemaObjId, Seq SchemaDependency) `arr` ()
- recordDependenciesM :: MonadWriter (Seq CollectItem) m => MetadataObject -> SchemaObjId -> Seq SchemaDependency -> m ()
- withRecordInconsistencyM :: MonadWriter (Seq CollectItem) m => MetadataObject -> ExceptT QErr m a -> m (Maybe a)
- withRecordInconsistency :: (ArrowChoice arr, ArrowWriter (Seq CollectItem) arr) => ErrorA QErr arr (e, s) a -> arr (e, (MetadataObject, s)) (Maybe a)
- withRecordInconsistencies :: (ArrowChoice arr, ArrowWriter (Seq CollectItem) arr) => ErrorA QErr arr (e, s) a -> arr (e, ([MetadataObject], s)) (Maybe a)
- class CacheRM m => CacheRWM m where
- buildSchemaCacheWithOptions :: CacheRWM m => BuildReason -> CacheInvalidations -> Metadata -> Maybe MetadataResourceVersion -> m ()
- data BuildReason
- data CacheInvalidations = CacheInvalidations {}
- type ValidateNewSchemaCache a = SchemaCache -> SchemaCache -> (ValidateNewSchemaCacheResult, a)
- data ValidateNewSchemaCacheResult
- newtype MetadataT m a = MetadataT {
- unMetadataT :: StateT Metadata m a
- runMetadataT :: Metadata -> MetadataDefaults -> MetadataT m a -> m (a, Metadata)
- buildSchemaCacheWithInvalidations :: (MetadataM m, CacheRWM m) => CacheInvalidations -> MetadataModifier -> m ()
- buildSchemaCache :: (MetadataM m, CacheRWM m) => MetadataModifier -> m ()
- tryBuildSchemaCache :: (CacheRWM m, MetadataM m) => MetadataModifier -> m (HashMap MetadataObjId (NonEmpty InconsistentMetadata))
- tryBuildSchemaCacheWithModifiers :: (CacheRWM m, MetadataM m) => [Metadata -> m Metadata] -> m (HashMap MetadataObjId (NonEmpty InconsistentMetadata))
- tryBuildSchemaCacheAndWarnOnFailingObjects :: forall m a. (CacheRWM m, MonadWarnings m, QErrM m, MetadataM m) => (a -> m MetadataModifier) -> WarningCode -> HashMap MetadataObjId a -> m (HashMap MetadataObjId a)
- buildSchemaCacheFor :: (QErrM m, CacheRWM m, MetadataM m) => MetadataObjId -> MetadataModifier -> m ()
- throwOnInconsistencies :: (QErrM m, CacheRWM m) => m ()
- withNewInconsistentObjsCheck :: (QErrM m, CacheRM m) => m a -> m a
- getInconsistentQueryCollections :: SchemaIntrospection -> QueryCollections -> ((CollectionName, ListedQuery) -> MetadataObject) -> EndpointTrie GQLQueryWithText -> [NormalizedQuery] -> [InconsistentMetadata]
- data StoredIntrospection = StoredIntrospection {}
- data StoredIntrospectionItem
- data CollectItem
Inconsistencies
recordInconsistencies :: (ArrowWriter (Seq CollectItem) arr, Functor f, Foldable f) => ((Maybe Value, f MetadataObject), Text) `arr` () Source #
recordInconsistencyM :: MonadWriter (Seq CollectItem) m => Maybe Value -> MetadataObject -> Text -> m () Source #
recordInconsistenciesM :: MonadWriter (Seq CollectItem) m => [MetadataObject] -> Text -> m () Source #
Dependencies
data MetadataDependency Source #
MetadataDependency | |
|
Instances
Show MetadataDependency Source # | |
Defined in Hasura.RQL.Types.SchemaCache.Build showsPrec :: Int -> MetadataDependency -> ShowS # show :: MetadataDependency -> String # showList :: [MetadataDependency] -> ShowS # | |
Eq MetadataDependency Source # | |
Defined in Hasura.RQL.Types.SchemaCache.Build (==) :: MetadataDependency -> MetadataDependency -> Bool # (/=) :: MetadataDependency -> MetadataDependency -> Bool # |
recordDependencies :: ArrowWriter (Seq CollectItem) arr => (MetadataObject, SchemaObjId, Seq SchemaDependency) `arr` () Source #
recordDependenciesM :: MonadWriter (Seq CollectItem) m => MetadataObject -> SchemaObjId -> Seq SchemaDependency -> m () Source #
Helpers
withRecordInconsistencyM :: MonadWriter (Seq CollectItem) m => MetadataObject -> ExceptT QErr m a -> m (Maybe a) Source #
Monadic version of withRecordInconsistency
withRecordInconsistency :: (ArrowChoice arr, ArrowWriter (Seq CollectItem) arr) => ErrorA QErr arr (e, s) a -> arr (e, (MetadataObject, s)) (Maybe a) Source #
Record any errors resulting from a computation as inconsistencies
withRecordInconsistencies :: (ArrowChoice arr, ArrowWriter (Seq CollectItem) arr) => ErrorA QErr arr (e, s) a -> arr (e, ([MetadataObject], s)) (Maybe a) Source #
class CacheRM m => CacheRWM m where Source #
tryBuildSchemaCacheWithOptions :: BuildReason -> CacheInvalidations -> Metadata -> Maybe MetadataResourceVersion -> ValidateNewSchemaCache a -> m a Source #
setMetadataResourceVersionInSchemaCache :: MetadataResourceVersion -> m () Source #
Instances
buildSchemaCacheWithOptions :: CacheRWM m => BuildReason -> CacheInvalidations -> Metadata -> Maybe MetadataResourceVersion -> m () Source #
data BuildReason Source #
CatalogUpdate (Maybe (HashSet SourceName)) | The build was triggered by an update this instance made to the catalog (in the
currently-active transaction), so information in Postgres that needs to be kept in sync with
the catalog (i.e. table event triggers in |
CatalogSync | The build was triggered by a notification that some other currently-running Hasura instance
updated the catalog. Since that instance already updated table event triggers in |
Instances
Show BuildReason Source # | |
Defined in Hasura.RQL.Types.SchemaCache.Build showsPrec :: Int -> BuildReason -> ShowS # show :: BuildReason -> String # showList :: [BuildReason] -> ShowS # | |
Eq BuildReason Source # | |
Defined in Hasura.RQL.Types.SchemaCache.Build (==) :: BuildReason -> BuildReason -> Bool # (/=) :: BuildReason -> BuildReason -> Bool # |
data CacheInvalidations Source #
CacheInvalidations | |
|
Instances
type ValidateNewSchemaCache a = SchemaCache -> SchemaCache -> (ValidateNewSchemaCacheResult, a) Source #
Function that validates the new schema cache (usually involves checking for any metadata inconsistencies)
and can decide whether or not to keep or discard the new schema cache (ValidateNewSchemaCacheResult
). It
can also return some arbitrary extra information that will be returned from tryBuildSchemaCacheWithOptions
.
First parameter is the old schema cache, the second is the new schema cache.
data ValidateNewSchemaCacheResult Source #
Instances
newtype MetadataT m a Source #
MetadataT | |
|
Instances
runMetadataT :: Metadata -> MetadataDefaults -> MetadataT m a -> m (a, Metadata) Source #
runMetadataT
puts a stateful metadata in scope. MetadataDefaults
is
provided so that it can be considered from the --metadataDefaults arguments.
buildSchemaCacheWithInvalidations :: (MetadataM m, CacheRWM m) => CacheInvalidations -> MetadataModifier -> m () Source #
buildSchemaCache :: (MetadataM m, CacheRWM m) => MetadataModifier -> m () Source #
tryBuildSchemaCache :: (CacheRWM m, MetadataM m) => MetadataModifier -> m (HashMap MetadataObjId (NonEmpty InconsistentMetadata)) Source #
Rebuilds the schema cache after modifying metadata and returns any _new_ metadata inconsistencies. If there are any new inconsistencies, the changes to the metadata and the schema cache are abandoned.
tryBuildSchemaCacheWithModifiers :: (CacheRWM m, MetadataM m) => [Metadata -> m Metadata] -> m (HashMap MetadataObjId (NonEmpty InconsistentMetadata)) Source #
Rebuilds the schema cache after modifying metadata sequentially and returns any _new_ metadata inconsistencies. If there are any new inconsistencies, the changes to the metadata and the schema cache are abandoned. If the metadata modifiers run into validation issues (e.g. a native query is already tracked in the metadata), we throw these errors back without changing the metadata and schema cache.
tryBuildSchemaCacheAndWarnOnFailingObjects Source #
:: forall m a. (CacheRWM m, MonadWarnings m, QErrM m, MetadataM m) | |
=> (a -> m MetadataModifier) | Function makes a metadata modifier for a metadata object |
-> WarningCode | Warning code to use for failed metadata objects |
-> HashMap MetadataObjId a | Map of metadata objects to apply to metadata using the |
-> m (HashMap MetadataObjId a) | Successfully applied metadata objects |
Tries to modify the metadata for all the specified metadata objects. If the modification fails,
any objects that directly caused a new metadata inconsistency are removed and the modification
is attempted again without those failing objects. The failing objects are raised as warnings
in MonadWarnings
and the successful objects are returned. If there are metadata inconsistencies
that are not directly related to the specified metadata objects, an error is thrown.
buildSchemaCacheFor :: (QErrM m, CacheRWM m, MetadataM m) => MetadataObjId -> MetadataModifier -> m () Source #
Rebuilds the schema cache after modifying metadata. If an object with the given object id became newly inconsistent, raises an error about it specifically. Otherwise, raises a generic metadata inconsistency error.
throwOnInconsistencies :: (QErrM m, CacheRWM m) => m () Source #
Requests the schema cache, and fails if there is any inconsistent metadata.
withNewInconsistentObjsCheck :: (QErrM m, CacheRM m) => m a -> m a Source #
Executes the given action, and if any new InconsistentMetadata
s are added to the schema
cache as a result of its execution, raises an error.
getInconsistentQueryCollections :: SchemaIntrospection -> QueryCollections -> ((CollectionName, ListedQuery) -> MetadataObject) -> EndpointTrie GQLQueryWithText -> [NormalizedQuery] -> [InconsistentMetadata] Source #
getInconsistentQueryCollections is a helper function that runs the static analysis over the saved queries and reports any inconsistenties with the current schema.
data StoredIntrospection Source #
Instances
data StoredIntrospectionItem Source #
Represents remote schema or source introspection data to be persisted in a storage (database).
Instances
Show StoredIntrospectionItem Source # | |
Defined in Hasura.RQL.Types.SchemaCache.Build showsPrec :: Int -> StoredIntrospectionItem -> ShowS # show :: StoredIntrospectionItem -> String # showList :: [StoredIntrospectionItem] -> ShowS # | |
Eq StoredIntrospectionItem Source # | |
Defined in Hasura.RQL.Types.SchemaCache.Build |
data CollectItem Source #
Items to be collected while building schema cache
See @buildSchemaCacheRule
for more details.
CollectInconsistentMetadata InconsistentMetadata | |
CollectMetadataDependency MetadataDependency | |
CollectStoredIntrospection StoredIntrospectionItem |
Instances
Show CollectItem Source # | |
Defined in Hasura.RQL.Types.SchemaCache.Build showsPrec :: Int -> CollectItem -> ShowS # show :: CollectItem -> String # showList :: [CollectItem] -> ShowS # | |
Eq CollectItem Source # | |
Defined in Hasura.RQL.Types.SchemaCache.Build (==) :: CollectItem -> CollectItem -> Bool # (/=) :: CollectItem -> CollectItem -> Bool # |