server: refactor Hasura.Metadata.Class

- Remove `MonadMetadataStorageQueryAPI` which was only implemented by a default implementation
- Introduce `TransT` which can be used to easily derive `lift`ing implementations for `MonadBlaBlaBla` classes

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8579
GitOrigin-RevId: 4f804fda7e2de5c9d75ee4df269f500ebd46b8c9
This commit is contained in:
Auke Booij 2023-04-03 15:35:15 +02:00 committed by hasura-bot
parent ed4f3b7406
commit 7cc33dd8ec
12 changed files with 103 additions and 280 deletions

View File

@ -490,6 +490,7 @@ library
, Control.Monad.Circular , Control.Monad.Circular
, Control.Monad.Memoize , Control.Monad.Memoize
, Control.Monad.Stateless , Control.Monad.Stateless
, Control.Monad.Trans.Extended
, Control.Monad.Trans.Managed , Control.Monad.Trans.Managed
, Data.Aeson.Extended , Data.Aeson.Extended
, Data.Aeson.Kriti.Functions , Data.Aeson.Kriti.Functions

View File

@ -0,0 +1,21 @@
module Control.Monad.Trans.Extended
( TransT (..),
)
where
import Control.Monad.Morph
import Data.Kind
import Prelude
-- | Utility newtype that can be used to derive type class instances just using
-- `MonadTrans`.
--
-- We often derive some `MonadBlaBla` instance for `ReaderT` by using `lift`
-- from `MonadTrans`. Which is fine, but it gets laborious if you do the same
-- for `ExceptT`, `StateT` and `WriterT`, even though the method implementations
-- are exactly the same. `TransT` allows you to write one `MonadTrans`-based
-- instance, which can then be used with `DerivingVia` to use that one
-- implementation for all monad transformers that use that same lifting
-- implementation.
newtype TransT t (m :: Type -> Type) a = TransT (t m a)
deriving (Functor, Applicative, Monad, MonadTrans, MFunctor, MMonad)

View File

@ -804,8 +804,6 @@ instance MonadMetadataStorage AppM where
clearActionData = runInSeparateTx . clearActionDataTx clearActionData = runInSeparateTx . clearActionDataTx
setProcessingActionLogsToPending = runInSeparateTx . setProcessingActionLogsToPendingTx setProcessingActionLogsToPending = runInSeparateTx . setProcessingActionLogsToPendingTx
instance MonadMetadataStorageQueryAPI AppM
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- misc -- misc
@ -891,7 +889,7 @@ runHGEServer ::
WS.MonadWSLog m, WS.MonadWSLog m,
MonadExecuteQuery m, MonadExecuteQuery m,
HasResourceLimits m, HasResourceLimits m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadResolveSource m, MonadResolveSource m,
MonadQueryTags m, MonadQueryTags m,
MonadEventLogCleanup m, MonadEventLogCleanup m,
@ -983,7 +981,7 @@ mkHGEServer ::
WS.MonadWSLog m, WS.MonadWSLog m,
MonadExecuteQuery m, MonadExecuteQuery m,
HasResourceLimits m, HasResourceLimits m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadResolveSource m, MonadResolveSource m,
MonadQueryTags m, MonadQueryTags m,
MonadEventLogCleanup m, MonadEventLogCleanup m,

View File

@ -2,13 +2,21 @@
module Hasura.Metadata.Class module Hasura.Metadata.Class
( SchemaSyncEventProcessResult (..), ( SchemaSyncEventProcessResult (..),
MonadMetadataStorage (..), MonadMetadataStorage (..),
MonadMetadataStorageQueryAPI (..), createOneOffScheduledEvent,
createCronEvents,
dropFutureCronEvents,
deleteActionData,
fetchScheduledEventInvocations,
fetchScheduledEvents,
dropEvent,
fetchCatalogState,
updateCatalogState,
) )
where where
import Control.Monad.Trans.Extended
import Control.Monad.Trans.Managed import Control.Monad.Trans.Managed
import Data.Aeson import Data.Aeson
import Database.PG.Query qualified as PG
import Hasura.Base.Error import Hasura.Base.Error
import Hasura.Eventing.ScheduledTrigger.Types import Hasura.Eventing.ScheduledTrigger.Types
import Hasura.Prelude import Hasura.Prelude
@ -21,7 +29,6 @@ import Hasura.RQL.Types.SchemaCache
import Hasura.RQL.Types.SchemaCache.Build import Hasura.RQL.Types.SchemaCache.Build
import Hasura.Server.Types import Hasura.Server.Types
import Hasura.Session import Hasura.Session
import Hasura.Tracing qualified as Tracing
import Network.HTTP.Types qualified as HTTP import Network.HTTP.Types qualified as HTTP
data SchemaSyncEventProcessResult = SchemaSyncEventProcessResult data SchemaSyncEventProcessResult = SchemaSyncEventProcessResult
@ -136,7 +143,7 @@ class Monad m => MonadMetadataStorage m where
clearActionData :: ActionName -> m (Either QErr ()) clearActionData :: ActionName -> m (Either QErr ())
setProcessingActionLogsToPending :: LockedActionIdArray -> m (Either QErr ()) setProcessingActionLogsToPending :: LockedActionIdArray -> m (Either QErr ())
instance (MonadMetadataStorage m) => MonadMetadataStorage (ReaderT r m) where instance (MonadMetadataStorage m, MonadTrans t, Monad (t m)) => MonadMetadataStorage (TransT t m) where
fetchMetadataResourceVersion = lift fetchMetadataResourceVersion fetchMetadataResourceVersion = lift fetchMetadataResourceVersion
fetchMetadata = lift fetchMetadata fetchMetadata = lift fetchMetadata
fetchMetadataNotifications a b = lift $ fetchMetadataNotifications a b fetchMetadataNotifications a b = lift $ fetchMetadataNotifications a b
@ -169,258 +176,57 @@ instance (MonadMetadataStorage m) => MonadMetadataStorage (ReaderT r m) where
clearActionData = lift . clearActionData clearActionData = lift . clearActionData
setProcessingActionLogsToPending = lift . setProcessingActionLogsToPending setProcessingActionLogsToPending = lift . setProcessingActionLogsToPending
instance (MonadMetadataStorage m) => MonadMetadataStorage (StateT s m) where deriving via (TransT (ReaderT r) m) instance (MonadMetadataStorage m) => MonadMetadataStorage (ReaderT r m)
fetchMetadataResourceVersion = lift fetchMetadataResourceVersion
fetchMetadata = lift fetchMetadata
fetchMetadataNotifications a b = lift $ fetchMetadataNotifications a b
setMetadata r = lift . setMetadata r
notifySchemaCacheSync a b c = lift $ notifySchemaCacheSync a b c
getCatalogState = lift getCatalogState
setCatalogState a b = lift $ setCatalogState a b
getMetadataDbUid = lift getMetadataDbUid deriving via (TransT (StateT s) m) instance (MonadMetadataStorage m) => MonadMetadataStorage (StateT s m)
checkMetadataStorageHealth = lift checkMetadataStorageHealth
getDeprivedCronTriggerStats = lift . getDeprivedCronTriggerStats deriving via (TransT (ExceptT e) m) instance (MonadMetadataStorage m) => MonadMetadataStorage (ExceptT e m)
getScheduledEventsForDelivery = lift getScheduledEventsForDelivery
insertCronEvents = lift . insertCronEvents
insertOneOffScheduledEvent = lift . insertOneOffScheduledEvent
insertScheduledEventInvocation a b = lift $ insertScheduledEventInvocation a b
setScheduledEventOp a b c = lift $ setScheduledEventOp a b c
unlockScheduledEvents a b = lift $ unlockScheduledEvents a b
unlockAllLockedScheduledEvents = lift $ unlockAllLockedScheduledEvents
clearFutureCronEvents = lift . clearFutureCronEvents
getOneOffScheduledEvents a b c = lift $ getOneOffScheduledEvents a b c
getCronEvents a b c d = lift $ getCronEvents a b c d
getScheduledEventInvocations a = lift $ getScheduledEventInvocations a
deleteScheduledEvent a b = lift $ deleteScheduledEvent a b
insertAction a b c d = lift $ insertAction a b c d deriving via (TransT MetadataT m) instance (MonadMetadataStorage m) => MonadMetadataStorage (MetadataT m)
fetchUndeliveredActionEvents = lift fetchUndeliveredActionEvents
setActionStatus a b = lift $ setActionStatus a b
fetchActionResponse = lift . fetchActionResponse
clearActionData = lift . clearActionData
setProcessingActionLogsToPending = lift . setProcessingActionLogsToPending
instance (MonadMetadataStorage m) => MonadMetadataStorage (ExceptT e m) where deriving via (TransT ManagedT m) instance (MonadMetadataStorage m) => MonadMetadataStorage (ManagedT m)
fetchMetadataResourceVersion = lift fetchMetadataResourceVersion
fetchMetadata = lift fetchMetadata
fetchMetadataNotifications a b = lift $ fetchMetadataNotifications a b
setMetadata r = lift . setMetadata r
notifySchemaCacheSync a b c = lift $ notifySchemaCacheSync a b c
getCatalogState = lift getCatalogState
setCatalogState a b = lift $ setCatalogState a b
getMetadataDbUid = lift getMetadataDbUid -- | Record a one-off event
checkMetadataStorageHealth = lift checkMetadataStorageHealth createOneOffScheduledEvent :: MonadMetadataStorage m => OneOffEvent -> m (Either QErr EventId)
createOneOffScheduledEvent = insertOneOffScheduledEvent
getDeprivedCronTriggerStats = lift . getDeprivedCronTriggerStats -- | Record a cron event
getScheduledEventsForDelivery = lift getScheduledEventsForDelivery createCronEvents :: MonadMetadataStorage m => [CronEventSeed] -> m (Either QErr ())
insertCronEvents = lift . insertCronEvents createCronEvents = insertCronEvents
insertOneOffScheduledEvent = lift . insertOneOffScheduledEvent
insertScheduledEventInvocation a b = lift $ insertScheduledEventInvocation a b
setScheduledEventOp a b c = lift $ setScheduledEventOp a b c
unlockScheduledEvents a b = lift $ unlockScheduledEvents a b
unlockAllLockedScheduledEvents = lift $ unlockAllLockedScheduledEvents
clearFutureCronEvents = lift . clearFutureCronEvents
getOneOffScheduledEvents a b c = lift $ getOneOffScheduledEvents a b c
getCronEvents a b c d = lift $ getCronEvents a b c d
getScheduledEventInvocations a = lift $ getScheduledEventInvocations a
deleteScheduledEvent a b = lift $ deleteScheduledEvent a b
insertAction a b c d = lift $ insertAction a b c d -- | Clear cron events
fetchUndeliveredActionEvents = lift fetchUndeliveredActionEvents dropFutureCronEvents :: MonadMetadataStorage m => ClearCronEvents -> m (Either QErr ())
setActionStatus a b = lift $ setActionStatus a b dropFutureCronEvents = clearFutureCronEvents
fetchActionResponse = lift . fetchActionResponse
clearActionData = lift . clearActionData
setProcessingActionLogsToPending = lift . setProcessingActionLogsToPending
instance (MonadMetadataStorage m) => MonadMetadataStorage (Tracing.TraceT m) where -- | Delete async action logs
fetchMetadataResourceVersion = lift fetchMetadataResourceVersion deleteActionData :: MonadMetadataStorage m => ActionName -> m (Either QErr ())
fetchMetadata = lift fetchMetadata deleteActionData = clearActionData
fetchMetadataNotifications a b = lift $ fetchMetadataNotifications a b
setMetadata r = lift . setMetadata r
notifySchemaCacheSync a b c = lift $ notifySchemaCacheSync a b c
getCatalogState = lift getCatalogState
setCatalogState a b = lift $ setCatalogState a b
getMetadataDbUid = lift getMetadataDbUid -- | Fetch cron/oneoff scheduled event invocations
checkMetadataStorageHealth = lift checkMetadataStorageHealth fetchScheduledEventInvocations ::
MonadMetadataStorage m =>
GetScheduledEventInvocations ->
m (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
fetchScheduledEventInvocations = getScheduledEventInvocations
getDeprivedCronTriggerStats = lift . getDeprivedCronTriggerStats -- | Fetch cron/oneoff scheduled events
getScheduledEventsForDelivery = lift getScheduledEventsForDelivery fetchScheduledEvents :: MonadMetadataStorage m => GetScheduledEvents -> m (Either QErr Value)
insertCronEvents = lift . insertCronEvents fetchScheduledEvents GetScheduledEvents {..} = do
insertOneOffScheduledEvent = lift . insertOneOffScheduledEvent let totalCountToJSON WithOptionalTotalCount {..} =
insertScheduledEventInvocation a b = lift $ insertScheduledEventInvocation a b object $
setScheduledEventOp a b c = lift $ setScheduledEventOp a b c ("events" .= _wtcData) : (maybe mempty (\count -> ["count" .= count]) _wtcCount)
unlockScheduledEvents a b = lift $ unlockScheduledEvents a b case _gseScheduledEvent of
unlockAllLockedScheduledEvents = lift $ unlockAllLockedScheduledEvents SEOneOff -> (fmap . fmap) totalCountToJSON $ getOneOffScheduledEvents _gsePagination _gseStatus _gseGetRowsCount
clearFutureCronEvents = lift . clearFutureCronEvents SECron name -> (fmap . fmap) totalCountToJSON $ getCronEvents name _gsePagination _gseStatus _gseGetRowsCount
getOneOffScheduledEvents a b c = lift $ getOneOffScheduledEvents a b c
getCronEvents a b c d = lift $ getCronEvents a b c d
getScheduledEventInvocations a = lift $ getScheduledEventInvocations a
deleteScheduledEvent a b = lift $ deleteScheduledEvent a b
insertAction a b c d = lift $ insertAction a b c d -- | Drop a cron/oneoff scheduled event
fetchUndeliveredActionEvents = lift fetchUndeliveredActionEvents dropEvent :: MonadMetadataStorage m => ScheduledEventId -> ScheduledEventType -> m (Either QErr ())
setActionStatus a b = lift $ setActionStatus a b dropEvent = deleteScheduledEvent
fetchActionResponse = lift . fetchActionResponse
clearActionData = lift . clearActionData
setProcessingActionLogsToPending = lift . setProcessingActionLogsToPending
instance (MonadMetadataStorage m) => MonadMetadataStorage (MetadataT m) where -- | Retrieve the state from metadata storage catalog
fetchMetadataResourceVersion = lift fetchMetadataResourceVersion fetchCatalogState :: MonadMetadataStorage m => m (Either QErr CatalogState)
fetchMetadata = lift fetchMetadata fetchCatalogState = getCatalogState
fetchMetadataNotifications a b = lift $ fetchMetadataNotifications a b
setMetadata r = lift . setMetadata r
notifySchemaCacheSync a b c = lift $ notifySchemaCacheSync a b c
getCatalogState = lift getCatalogState
setCatalogState a b = lift $ setCatalogState a b
getMetadataDbUid = lift getMetadataDbUid -- | Update the state from metadata storage catalog
checkMetadataStorageHealth = lift checkMetadataStorageHealth updateCatalogState :: MonadMetadataStorage m => CatalogStateType -> Value -> m (Either QErr ())
updateCatalogState = setCatalogState
getDeprivedCronTriggerStats = lift . getDeprivedCronTriggerStats
getScheduledEventsForDelivery = lift getScheduledEventsForDelivery
insertCronEvents = lift . insertCronEvents
insertOneOffScheduledEvent = lift . insertOneOffScheduledEvent
insertScheduledEventInvocation a b = lift $ insertScheduledEventInvocation a b
setScheduledEventOp a b c = lift $ setScheduledEventOp a b c
unlockScheduledEvents a b = lift $ unlockScheduledEvents a b
unlockAllLockedScheduledEvents = lift $ unlockAllLockedScheduledEvents
clearFutureCronEvents = lift . clearFutureCronEvents
getOneOffScheduledEvents a b c = lift $ getOneOffScheduledEvents a b c
getCronEvents a b c d = lift $ getCronEvents a b c d
getScheduledEventInvocations a = lift $ getScheduledEventInvocations a
deleteScheduledEvent a b = lift $ deleteScheduledEvent a b
insertAction a b c d = lift $ insertAction a b c d
fetchUndeliveredActionEvents = lift fetchUndeliveredActionEvents
setActionStatus a b = lift $ setActionStatus a b
fetchActionResponse = lift . fetchActionResponse
clearActionData = lift . clearActionData
setProcessingActionLogsToPending = lift . setProcessingActionLogsToPending
instance (MonadMetadataStorage m) => MonadMetadataStorage (PG.TxET e m) where
fetchMetadataResourceVersion = lift fetchMetadataResourceVersion
fetchMetadata = lift fetchMetadata
fetchMetadataNotifications a b = lift $ fetchMetadataNotifications a b
setMetadata r = lift . setMetadata r
notifySchemaCacheSync a b c = lift $ notifySchemaCacheSync a b c
getCatalogState = lift getCatalogState
setCatalogState a b = lift $ setCatalogState a b
getMetadataDbUid = lift getMetadataDbUid
checkMetadataStorageHealth = lift checkMetadataStorageHealth
getDeprivedCronTriggerStats = lift . getDeprivedCronTriggerStats
getScheduledEventsForDelivery = lift getScheduledEventsForDelivery
insertCronEvents = lift . insertCronEvents
insertOneOffScheduledEvent = lift . insertOneOffScheduledEvent
insertScheduledEventInvocation a b = lift $ insertScheduledEventInvocation a b
setScheduledEventOp a b c = lift $ setScheduledEventOp a b c
unlockScheduledEvents a b = lift $ unlockScheduledEvents a b
unlockAllLockedScheduledEvents = lift $ unlockAllLockedScheduledEvents
clearFutureCronEvents = lift . clearFutureCronEvents
getOneOffScheduledEvents a b c = lift $ getOneOffScheduledEvents a b c
getCronEvents a b c d = lift $ getCronEvents a b c d
getScheduledEventInvocations a = lift $ getScheduledEventInvocations a
deleteScheduledEvent a b = lift $ deleteScheduledEvent a b
insertAction a b c d = lift $ insertAction a b c d
fetchUndeliveredActionEvents = lift fetchUndeliveredActionEvents
setActionStatus a b = lift $ setActionStatus a b
fetchActionResponse = lift . fetchActionResponse
clearActionData = lift . clearActionData
setProcessingActionLogsToPending = lift . setProcessingActionLogsToPending
instance (MonadMetadataStorage m) => MonadMetadataStorage (ManagedT m) where
fetchMetadataResourceVersion = lift fetchMetadataResourceVersion
fetchMetadata = lift fetchMetadata
fetchMetadataNotifications a b = lift $ fetchMetadataNotifications a b
setMetadata r = lift . setMetadata r
notifySchemaCacheSync a b c = lift $ notifySchemaCacheSync a b c
getCatalogState = lift getCatalogState
setCatalogState a b = lift $ setCatalogState a b
getMetadataDbUid = lift getMetadataDbUid
checkMetadataStorageHealth = lift checkMetadataStorageHealth
getDeprivedCronTriggerStats = lift . getDeprivedCronTriggerStats
getScheduledEventsForDelivery = lift getScheduledEventsForDelivery
insertCronEvents = lift . insertCronEvents
insertOneOffScheduledEvent = lift . insertOneOffScheduledEvent
insertScheduledEventInvocation a b = lift $ insertScheduledEventInvocation a b
setScheduledEventOp a b c = lift $ setScheduledEventOp a b c
unlockScheduledEvents a b = lift $ unlockScheduledEvents a b
unlockAllLockedScheduledEvents = lift $ unlockAllLockedScheduledEvents
clearFutureCronEvents = lift . clearFutureCronEvents
getOneOffScheduledEvents a b c = lift $ getOneOffScheduledEvents a b c
getCronEvents a b c d = lift $ getCronEvents a b c d
getScheduledEventInvocations a = lift $ getScheduledEventInvocations a
deleteScheduledEvent a b = lift $ deleteScheduledEvent a b
insertAction a b c d = lift $ insertAction a b c d
fetchUndeliveredActionEvents = lift fetchUndeliveredActionEvents
setActionStatus a b = lift $ setActionStatus a b
fetchActionResponse = lift . fetchActionResponse
clearActionData = lift . clearActionData
setProcessingActionLogsToPending = lift . setProcessingActionLogsToPending
-- | Operations from @'MonadMetadataStorage' used in '/v1/query' and '/v1/metadata' APIs
class (MonadMetadataStorage m) => MonadMetadataStorageQueryAPI m where
-- | Record a one-off event
createOneOffScheduledEvent :: OneOffEvent -> m (Either QErr EventId)
createOneOffScheduledEvent = insertOneOffScheduledEvent
-- | Record a cron event
createCronEvents :: [CronEventSeed] -> m (Either QErr ())
createCronEvents = insertCronEvents
-- | Clear cron events
dropFutureCronEvents :: ClearCronEvents -> m (Either QErr ())
dropFutureCronEvents = clearFutureCronEvents
-- | Delete async action logs
deleteActionData :: ActionName -> m (Either QErr ())
deleteActionData = clearActionData
-- | Fetch cron/oneoff scheduled event invocations
fetchScheduledEventInvocations ::
GetScheduledEventInvocations ->
m (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation]))
fetchScheduledEventInvocations = getScheduledEventInvocations
-- | Fetch cron/oneoff scheduled events
fetchScheduledEvents :: GetScheduledEvents -> m (Either QErr Value)
fetchScheduledEvents GetScheduledEvents {..} = do
let totalCountToJSON WithOptionalTotalCount {..} =
object $
("events" .= _wtcData) : (maybe mempty (\count -> ["count" .= count]) _wtcCount)
case _gseScheduledEvent of
SEOneOff -> (fmap . fmap) totalCountToJSON $ getOneOffScheduledEvents _gsePagination _gseStatus _gseGetRowsCount
SECron name -> (fmap . fmap) totalCountToJSON $ getCronEvents name _gsePagination _gseStatus _gseGetRowsCount
-- | Drop a cron/oneoff scheduled event
dropEvent :: ScheduledEventId -> ScheduledEventType -> m (Either QErr ())
dropEvent = deleteScheduledEvent
-- | Retrieve the state from metadata storage catalog
fetchCatalogState :: m (Either QErr CatalogState)
fetchCatalogState = getCatalogState
-- | Update the state from metadata storage catalog
updateCatalogState :: CatalogStateType -> Value -> m (Either QErr ())
updateCatalogState = setCatalogState
instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (ReaderT r m)
instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (StateT s m)
instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (ExceptT s m)
instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (Tracing.TraceT m)
instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (MetadataT m)
instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (PG.TxET QErr m)

View File

@ -261,7 +261,7 @@ runDropAction ::
( MonadError QErr m, ( MonadError QErr m,
CacheRWM m, CacheRWM m,
MetadataM m, MetadataM m,
MonadMetadataStorageQueryAPI m MonadMetadataStorage m
) => ) =>
DropAction -> DropAction ->
m EncJSON m EncJSON

View File

@ -122,7 +122,7 @@ runClearMetadata ::
( MonadIO m, ( MonadIO m,
CacheRWM m, CacheRWM m,
MetadataM m, MetadataM m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadBaseControl IO m, MonadBaseControl IO m,
MonadReader r m, MonadReader r m,
MonadError QErr m, MonadError QErr m,
@ -195,7 +195,7 @@ runReplaceMetadata ::
MetadataM m, MetadataM m,
MonadIO m, MonadIO m,
MonadBaseControl IO m, MonadBaseControl IO m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadReader r m, MonadReader r m,
MonadError QErr m, MonadError QErr m,
Has (HL.Logger HL.Hasura) r, Has (HL.Logger HL.Hasura) r,
@ -213,7 +213,7 @@ runReplaceMetadataV1 ::
MetadataM m, MetadataM m,
MonadIO m, MonadIO m,
MonadBaseControl IO m, MonadBaseControl IO m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadReader r m, MonadReader r m,
MonadError QErr m, MonadError QErr m,
Has (HL.Logger HL.Hasura) r, Has (HL.Logger HL.Hasura) r,
@ -231,7 +231,7 @@ runReplaceMetadataV2 ::
MetadataM m, MetadataM m,
MonadIO m, MonadIO m,
MonadBaseControl IO m, MonadBaseControl IO m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadReader r m, MonadReader r m,
MonadError QErr m, MonadError QErr m,
Has (HL.Logger HL.Hasura) r, Has (HL.Logger HL.Hasura) r,
@ -255,7 +255,7 @@ runReplaceMetadataV2' ::
MetadataM m, MetadataM m,
MonadIO m, MonadIO m,
MonadBaseControl IO m, MonadBaseControl IO m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadReader r m, MonadReader r m,
MonadError QErr m, MonadError QErr m,
Has (HL.Logger HL.Hasura) r, Has (HL.Logger HL.Hasura) r,
@ -760,12 +760,12 @@ purgeMetadataObj = \case
} }
runGetCatalogState :: runGetCatalogState ::
(MonadMetadataStorageQueryAPI m, MonadError QErr m) => GetCatalogState -> m EncJSON (MonadMetadataStorage m, MonadError QErr m) => GetCatalogState -> m EncJSON
runGetCatalogState _ = runGetCatalogState _ =
encJFromJValue <$> liftEitherM fetchCatalogState encJFromJValue <$> liftEitherM fetchCatalogState
runSetCatalogState :: runSetCatalogState ::
(MonadMetadataStorageQueryAPI m, MonadError QErr m) => SetCatalogState -> m EncJSON (MonadMetadataStorage m, MonadError QErr m) => SetCatalogState -> m EncJSON
runSetCatalogState SetCatalogState {..} = do runSetCatalogState SetCatalogState {..} = do
liftEitherM $ updateCatalogState _scsType _scsState liftEitherM $ updateCatalogState _scsType _scsState
pure successMsg pure successMsg

View File

@ -36,7 +36,7 @@ import System.Cron.Types (CronSchedule)
populateInitialCronTriggerEvents :: populateInitialCronTriggerEvents ::
( MonadIO m, ( MonadIO m,
MonadError QErr m, MonadError QErr m,
MonadMetadataStorageQueryAPI m MonadMetadataStorage m
) => ) =>
CronSchedule -> CronSchedule ->
TriggerName -> TriggerName ->
@ -54,7 +54,7 @@ runCreateCronTrigger ::
CacheRWM m, CacheRWM m,
MonadIO m, MonadIO m,
MetadataM m, MetadataM m,
MonadMetadataStorageQueryAPI m MonadMetadataStorage m
) => ) =>
CreateCronTrigger -> CreateCronTrigger ->
m EncJSON m EncJSON
@ -128,7 +128,7 @@ updateCronTrigger ::
CacheRWM m, CacheRWM m,
MonadIO m, MonadIO m,
MetadataM m, MetadataM m,
MonadMetadataStorageQueryAPI m MonadMetadataStorage m
) => ) =>
CronTriggerMetadata -> CronTriggerMetadata ->
m EncJSON m EncJSON
@ -148,7 +148,7 @@ runDeleteCronTrigger ::
( MonadError QErr m, ( MonadError QErr m,
CacheRWM m, CacheRWM m,
MetadataM m, MetadataM m,
MonadMetadataStorageQueryAPI m MonadMetadataStorage m
) => ) =>
ScheduledTriggerName -> ScheduledTriggerName ->
m EncJSON m EncJSON
@ -165,7 +165,7 @@ dropCronTriggerInMetadata name =
MetadataModifier $ metaCronTriggers %~ OMap.delete name MetadataModifier $ metaCronTriggers %~ OMap.delete name
runCreateScheduledEvent :: runCreateScheduledEvent ::
(MonadError QErr m, MonadMetadataStorageQueryAPI m) => (MonadError QErr m, MonadMetadataStorage m) =>
CreateScheduledEvent -> CreateScheduledEvent ->
m EncJSON m EncJSON
runCreateScheduledEvent scheduledEvent = do runCreateScheduledEvent scheduledEvent = do
@ -181,7 +181,7 @@ checkExists name = do
"cron trigger with name: " <> triggerNameToTxt name <> " does not exist" "cron trigger with name: " <> triggerNameToTxt name <> " does not exist"
runDeleteScheduledEvent :: runDeleteScheduledEvent ::
(MonadMetadataStorageQueryAPI m, MonadError QErr m) => DeleteScheduledEvent -> m EncJSON (MonadMetadataStorage m, MonadError QErr m) => DeleteScheduledEvent -> m EncJSON
runDeleteScheduledEvent DeleteScheduledEvent {..} = do runDeleteScheduledEvent DeleteScheduledEvent {..} = do
liftEitherM $ dropEvent _dseEventId _dseType liftEitherM $ dropEvent _dseEventId _dseType
pure successMsg pure successMsg
@ -189,7 +189,7 @@ runDeleteScheduledEvent DeleteScheduledEvent {..} = do
runGetScheduledEvents :: runGetScheduledEvents ::
( MonadError QErr m, ( MonadError QErr m,
CacheRM m, CacheRM m,
MonadMetadataStorageQueryAPI m MonadMetadataStorage m
) => ) =>
GetScheduledEvents -> GetScheduledEvents ->
m EncJSON m EncJSON
@ -202,7 +202,7 @@ runGetScheduledEvents gse = do
runGetScheduledEventInvocations :: runGetScheduledEventInvocations ::
( MonadError QErr m, ( MonadError QErr m,
CacheRM m, CacheRM m,
MonadMetadataStorageQueryAPI m MonadMetadataStorage m
) => ) =>
GetScheduledEventInvocations -> GetScheduledEventInvocations ->
m EncJSON m EncJSON

View File

@ -185,7 +185,6 @@ newtype CacheRWT m a
MonadError e, MonadError e,
UserInfoM, UserInfoM,
MonadMetadataStorage, MonadMetadataStorage,
MonadMetadataStorageQueryAPI,
Tracing.MonadTrace, Tracing.MonadTrace,
MonadBase b, MonadBase b,
MonadBaseControl b, MonadBaseControl b,

View File

@ -391,7 +391,7 @@ runMetadataQuery ::
MonadBaseControl IO m, MonadBaseControl IO m,
HasAppEnv m, HasAppEnv m,
Tracing.MonadTrace m, Tracing.MonadTrace m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadResolveSource m, MonadResolveSource m,
MonadEventLogCleanup m, MonadEventLogCleanup m,
ProvidesHasuraServices m, ProvidesHasuraServices m,
@ -610,7 +610,7 @@ runMetadataQueryM ::
Tracing.MonadTrace m, Tracing.MonadTrace m,
UserInfoM m, UserInfoM m,
MetadataM m, MetadataM m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
HasServerConfigCtx m, HasServerConfigCtx m,
MonadReader r m, MonadReader r m,
Has (L.Logger L.Hasura) r, Has (L.Logger L.Hasura) r,
@ -642,7 +642,7 @@ runMetadataQueryV1M ::
Tracing.MonadTrace m, Tracing.MonadTrace m,
UserInfoM m, UserInfoM m,
MetadataM m, MetadataM m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
HasServerConfigCtx m, HasServerConfigCtx m,
MonadReader r m, MonadReader r m,
Has (L.Logger L.Hasura) r, Has (L.Logger L.Hasura) r,
@ -819,7 +819,7 @@ runMetadataQueryV2M ::
CacheRWM m, CacheRWM m,
MonadBaseControl IO m, MonadBaseControl IO m,
MetadataM m, MetadataM m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadReader r m, MonadReader r m,
Has (L.Logger L.Hasura) r, Has (L.Logger L.Hasura) r,
MonadError QErr m, MonadError QErr m,

View File

@ -182,7 +182,7 @@ runQuery ::
HasAppEnv m, HasAppEnv m,
Tracing.MonadTrace m, Tracing.MonadTrace m,
MonadBaseControl IO m, MonadBaseControl IO m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadResolveSource m, MonadResolveSource m,
MonadQueryTags m, MonadQueryTags m,
MonadEventLogCleanup m, MonadEventLogCleanup m,
@ -394,7 +394,7 @@ runQueryM ::
HasServerConfigCtx m, HasServerConfigCtx m,
Tracing.MonadTrace m, Tracing.MonadTrace m,
MetadataM m, MetadataM m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadQueryTags m, MonadQueryTags m,
MonadReader r m, MonadReader r m,
MonadError QErr m, MonadError QErr m,

View File

@ -144,7 +144,6 @@ newtype Handler m a = Handler (ReaderT HandlerCtx (ExceptT QErr m) a)
GH.MonadExecuteQuery, GH.MonadExecuteQuery,
MonadMetadataApiAuthorization, MonadMetadataApiAuthorization,
MonadMetadataStorage, MonadMetadataStorage,
MonadMetadataStorageQueryAPI,
ProvidesNetwork, ProvidesNetwork,
MonadGetApiTimeLimit MonadGetApiTimeLimit
) )
@ -421,7 +420,7 @@ v1QueryHandler ::
MonadMetadataApiAuthorization m, MonadMetadataApiAuthorization m,
MonadTrace m, MonadTrace m,
MonadReader HandlerCtx m, MonadReader HandlerCtx m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadResolveSource m, MonadResolveSource m,
HasAppEnv m, HasAppEnv m,
MonadQueryTags m, MonadQueryTags m,
@ -453,7 +452,7 @@ v1MetadataHandler ::
MonadBaseControl IO m, MonadBaseControl IO m,
MonadReader HandlerCtx m, MonadReader HandlerCtx m,
MonadTrace m, MonadTrace m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadResolveSource m, MonadResolveSource m,
MonadMetadataApiAuthorization m, MonadMetadataApiAuthorization m,
MonadEventLogCleanup m, MonadEventLogCleanup m,
@ -724,7 +723,7 @@ mkWaiApp ::
MonadTrace m, MonadTrace m,
GH.MonadExecuteQuery m, GH.MonadExecuteQuery m,
HasResourceLimits m, HasResourceLimits m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadResolveSource m, MonadResolveSource m,
MonadQueryTags m, MonadQueryTags m,
MonadEventLogCleanup m, MonadEventLogCleanup m,
@ -768,7 +767,7 @@ httpApp ::
MonadExecutionLog m, MonadExecutionLog m,
MonadTrace m, MonadTrace m,
GH.MonadExecuteQuery m, GH.MonadExecuteQuery m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
HasResourceLimits m, HasResourceLimits m,
MonadResolveSource m, MonadResolveSource m,
MonadQueryTags m, MonadQueryTags m,

View File

@ -51,7 +51,6 @@ newtype CacheRefT m a = CacheRefT {runCacheRefT :: (ServerConfigCtx, MVar Rebuil
MonadTx, MonadTx,
UserInfoM, UserInfoM,
MonadMetadataStorage, MonadMetadataStorage,
MonadMetadataStorageQueryAPI,
MonadResolveSource, MonadResolveSource,
ProvidesNetwork, ProvidesNetwork,
MonadGetApiTimeLimit MonadGetApiTimeLimit
@ -112,7 +111,7 @@ suite ::
MonadError QErr m, MonadError QErr m,
MonadBaseControl IO m, MonadBaseControl IO m,
MonadResolveSource m, MonadResolveSource m,
MonadMetadataStorageQueryAPI m, MonadMetadataStorage m,
MonadEventLogCleanup m, MonadEventLogCleanup m,
ProvidesNetwork m, ProvidesNetwork m,
MonadGetApiTimeLimit m MonadGetApiTimeLimit m