{-# LANGUAGE UndecidableInstances #-}

-- | This module has type class and types which implements the Metadata Storage Abstraction
module Hasura.Metadata.Class
  ( SchemaSyncEventProcessResult (..),
    MetadataStorageT (..),
    runMetadataStorageT,
    MonadMetadataStorage (..),
    MonadMetadataStorageQueryAPI (..),
  )
where

import Control.Monad.Morph (MFunctor, hoist)
import Control.Monad.Trans.Control (MonadBaseControl)
import Data.Aeson
import Database.PG.Query qualified as Q
import Hasura.Base.Error
import Hasura.Eventing.ScheduledTrigger.Types
import Hasura.Prelude
import Hasura.RQL.Types.Action
import Hasura.RQL.Types.EventTrigger
import Hasura.RQL.Types.Eventing
import Hasura.RQL.Types.Metadata
import Hasura.RQL.Types.ScheduledTrigger
import Hasura.RQL.Types.SchemaCache
import Hasura.RQL.Types.SchemaCache.Build
import Hasura.RQL.Types.Source
import Hasura.Server.Types
import Hasura.Session
import Hasura.Tracing qualified as Tracing
import Network.HTTP.Client.Manager (HasHttpManagerM (..))
import Network.HTTP.Types qualified as HTTP

data SchemaSyncEventProcessResult = SchemaSyncEventProcessResult
  { SchemaSyncEventProcessResult -> Bool
_sseprShouldReload :: !Bool,
    SchemaSyncEventProcessResult -> CacheInvalidations
_sseprCacheInvalidations :: !CacheInvalidations
  }

{- Note [Todo: Common interface for eventing sub-system]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Postgres tables' event triggers and scheduled event triggers are similar in the
core logic. But currently, their implementation is completely isolated and do not
share a common schema in Postgres. We're having a plan to simplify them via a
common 'event storage and retrieval' interface (maybe via a Postgres extension?).
This will potentially reduce number of interactions made to database and schema foot print.

TODO: Reference to open issue or rfc?
-}

-- | Metadata storage abstraction via a type class.
--
-- This type class enables storing and managing Hasura metadata in an isolated
-- database which will not interfere with user's database where tables/functions
-- are defined. Hence, it'll enable support for databases of multiple backends
-- like MySQL, MSSQL etc.
--
-- This class has functions broadly related to:
--
-- 1. Metadata Management
-- ----------------------
-- Basic metadata management functions such as retrieving metadata from storage
-- database and replacing the given metadata.
-- TODO: Console specific operations
--
-- 2. Scheduled Triggers
-- ---------------------
-- Eventing sub-system for scheduled triggers is implemented via metadata storage.
-- For more details, refer description in 'Hasura.Eventing.ScheduledTrigger' module.
--
-- TODO: Functions need to be added to the type class
-- - Retrieving invocation logs from storage (console requirement)
-- - Deleting an scheduled event
-- - Creating an one-off scheduled event
--
-- 3. Async Actions
-- ----------------
-- Operations to implement async actions sub-system. This includes recording an
-- async action event and retreiving the details of action delivery to the webhook.
-- For more details see Note [Async action architecture] in 'Hasura.GraphQL.Execute.Action' module.
--
-- It is believed that all the above three are implemented in a single storage
-- system (ex: a Postgres database). We can split the functions into appropriate and
-- specific type classes in future iterations if required.
class (MonadError QErr m) => MonadMetadataStorage m where
  -- Metadata
  fetchMetadataResourceVersion :: m MetadataResourceVersion
  fetchMetadata :: m (Metadata, MetadataResourceVersion)
  fetchMetadataNotifications :: MetadataResourceVersion -> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
  setMetadata :: MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
  notifySchemaCacheSync :: MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
  getCatalogState :: m CatalogState

  -- the `setCatalogState` function is used by the console and CLI to store its state
  -- it is disabled when maintenance mode is on
  setCatalogState :: CatalogStateType -> Value -> m ()

  -- get the @db_uuid@ that we store in the database.
  getMetadataDbUid :: m MetadataDbId
  checkMetadataStorageHealth :: m ()

  -- Scheduled triggers
  -- TODO:-
  -- Ideally we would've liked to avoid having functions that are specific to
  -- scheduled/cron triggers and instead have functions that provide a generic
  -- 'event storage and retrieval' interface but we'll have to change a lot of
  -- existing code for scheduled and cron triggers. We can get to this after the
  -- multi-source work is done. See Note [Todo: Common interface for eventing sub-system]
  getDeprivedCronTriggerStats :: [TriggerName] -> m [CronTriggerStats]
  getScheduledEventsForDelivery :: m ([CronEvent], [OneOffScheduledEvent])
  insertCronEvents :: [CronEventSeed] -> m ()
  insertOneOffScheduledEvent :: OneOffEvent -> m EventId
  insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> m ()
  setScheduledEventOp :: ScheduledEventId -> ScheduledEventOp -> ScheduledEventType -> m ()
  unlockScheduledEvents :: ScheduledEventType -> [ScheduledEventId] -> m Int
  unlockAllLockedScheduledEvents :: m ()
  clearFutureCronEvents :: ClearCronEvents -> m ()

  -- Console API requirements
  getOneOffScheduledEvents :: ScheduledEventPagination -> [ScheduledEventStatus] -> m (WithTotalCount [OneOffScheduledEvent])
  getCronEvents :: TriggerName -> ScheduledEventPagination -> [ScheduledEventStatus] -> m (WithTotalCount [CronEvent])
  getInvocations :: GetInvocationsBy -> ScheduledEventPagination -> m (WithTotalCount [ScheduledEventInvocation])
  deleteScheduledEvent :: ScheduledEventId -> ScheduledEventType -> m ()

  -- Async actions
  insertAction ::
    ActionName ->
    SessionVariables ->
    [HTTP.Header] ->
    Value ->
    m ActionId
  fetchUndeliveredActionEvents :: m [ActionLogItem]
  setActionStatus :: ActionId -> AsyncActionStatus -> m ()
  fetchActionResponse :: ActionId -> m ActionLogResponse
  clearActionData :: ActionName -> m ()
  setProcessingActionLogsToPending :: LockedActionIdArray -> m ()

instance (MonadMetadataStorage m) => MonadMetadataStorage (ReaderT r m) where
  fetchMetadataResourceVersion :: ReaderT r m MetadataResourceVersion
fetchMetadataResourceVersion = m MetadataResourceVersion -> ReaderT r m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
m MetadataResourceVersion
fetchMetadataResourceVersion
  fetchMetadata :: ReaderT r m (Metadata, MetadataResourceVersion)
fetchMetadata = m (Metadata, MetadataResourceVersion)
-> ReaderT r m (Metadata, MetadataResourceVersion)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Metadata, MetadataResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Metadata, MetadataResourceVersion)
fetchMetadata
  fetchMetadataNotifications :: MetadataResourceVersion
-> InstanceId
-> ReaderT r m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b = m [(MetadataResourceVersion, CacheInvalidations)]
-> ReaderT r m [(MetadataResourceVersion, CacheInvalidations)]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [(MetadataResourceVersion, CacheInvalidations)]
 -> ReaderT r m [(MetadataResourceVersion, CacheInvalidations)])
-> m [(MetadataResourceVersion, CacheInvalidations)]
-> ReaderT r m [(MetadataResourceVersion, CacheInvalidations)]
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b
  setMetadata :: MetadataResourceVersion
-> Metadata -> ReaderT r m MetadataResourceVersion
setMetadata MetadataResourceVersion
r = m MetadataResourceVersion -> ReaderT r m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m MetadataResourceVersion -> ReaderT r m MetadataResourceVersion)
-> (Metadata -> m MetadataResourceVersion)
-> Metadata
-> ReaderT r m MetadataResourceVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
setMetadata MetadataResourceVersion
r
  notifySchemaCacheSync :: MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> ReaderT r m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ()) -> m () -> ReaderT r m ()
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c
  getCatalogState :: ReaderT r m CatalogState
getCatalogState = m CatalogState -> ReaderT r m CatalogState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m CatalogState
forall (m :: * -> *). MonadMetadataStorage m => m CatalogState
getCatalogState
  setCatalogState :: CatalogStateType -> Value -> ReaderT r m ()
setCatalogState CatalogStateType
a Value
b = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ()) -> m () -> ReaderT r m ()
forall a b. (a -> b) -> a -> b
$ CatalogStateType -> Value -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m ()
setCatalogState CatalogStateType
a Value
b

  getMetadataDbUid :: ReaderT r m MetadataDbId
getMetadataDbUid = m MetadataDbId -> ReaderT r m MetadataDbId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataDbId
forall (m :: * -> *). MonadMetadataStorage m => m MetadataDbId
getMetadataDbUid
  checkMetadataStorageHealth :: ReaderT r m ()
checkMetadataStorageHealth = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
checkMetadataStorageHealth

  getDeprivedCronTriggerStats :: [TriggerName] -> ReaderT r m [CronTriggerStats]
getDeprivedCronTriggerStats = m [CronTriggerStats] -> ReaderT r m [CronTriggerStats]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [CronTriggerStats] -> ReaderT r m [CronTriggerStats])
-> ([TriggerName] -> m [CronTriggerStats])
-> [TriggerName]
-> ReaderT r m [CronTriggerStats]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TriggerName] -> m [CronTriggerStats]
forall (m :: * -> *).
MonadMetadataStorage m =>
[TriggerName] -> m [CronTriggerStats]
getDeprivedCronTriggerStats
  getScheduledEventsForDelivery :: ReaderT r m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery = m ([CronEvent], [OneOffScheduledEvent])
-> ReaderT r m ([CronEvent], [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ([CronEvent], [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery
  insertCronEvents :: [CronEventSeed] -> ReaderT r m ()
insertCronEvents = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ())
-> ([CronEventSeed] -> m ()) -> [CronEventSeed] -> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CronEventSeed] -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m ()
insertCronEvents
  insertOneOffScheduledEvent :: OneOffEvent -> ReaderT r m EventId
insertOneOffScheduledEvent = m EventId -> ReaderT r m EventId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m EventId -> ReaderT r m EventId)
-> (OneOffEvent -> m EventId) -> OneOffEvent -> ReaderT r m EventId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OneOffEvent -> m EventId
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m EventId
insertOneOffScheduledEvent
  insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> ReaderT r m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ()) -> m () -> ReaderT r m ()
forall a b. (a -> b) -> a -> b
$ Invocation 'ScheduledType -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
Invocation 'ScheduledType -> ScheduledEventType -> m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b
  setScheduledEventOp :: EventId -> ScheduledEventOp -> ScheduledEventType -> ReaderT r m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ()) -> m () -> ReaderT r m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c
  unlockScheduledEvents :: ScheduledEventType -> [EventId] -> ReaderT r m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b = m Int -> ReaderT r m Int
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m Int -> ReaderT r m Int) -> m Int -> ReaderT r m Int
forall a b. (a -> b) -> a -> b
$ ScheduledEventType -> [EventId] -> m Int
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventType -> [EventId] -> m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b
  unlockAllLockedScheduledEvents :: ReaderT r m ()
unlockAllLockedScheduledEvents = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ()) -> m () -> ReaderT r m ()
forall a b. (a -> b) -> a -> b
$ m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
unlockAllLockedScheduledEvents
  clearFutureCronEvents :: ClearCronEvents -> ReaderT r m ()
clearFutureCronEvents = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ())
-> (ClearCronEvents -> m ()) -> ClearCronEvents -> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ClearCronEvents -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m ()
clearFutureCronEvents
  getOneOffScheduledEvents :: ScheduledEventPagination
-> [ScheduledEventStatus]
-> ReaderT r m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b = m (WithTotalCount [OneOffScheduledEvent])
-> ReaderT r m (WithTotalCount [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [OneOffScheduledEvent])
 -> ReaderT r m (WithTotalCount [OneOffScheduledEvent]))
-> m (WithTotalCount [OneOffScheduledEvent])
-> ReaderT r m (WithTotalCount [OneOffScheduledEvent])
forall a b. (a -> b) -> a -> b
$ ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b
  getCronEvents :: TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> ReaderT r m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c = m (WithTotalCount [CronEvent])
-> ReaderT r m (WithTotalCount [CronEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [CronEvent])
 -> ReaderT r m (WithTotalCount [CronEvent]))
-> m (WithTotalCount [CronEvent])
-> ReaderT r m (WithTotalCount [CronEvent])
forall a b. (a -> b) -> a -> b
$ TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c
  getInvocations :: GetInvocationsBy
-> ScheduledEventPagination
-> ReaderT r m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b = m (WithTotalCount [ScheduledEventInvocation])
-> ReaderT r m (WithTotalCount [ScheduledEventInvocation])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [ScheduledEventInvocation])
 -> ReaderT r m (WithTotalCount [ScheduledEventInvocation]))
-> m (WithTotalCount [ScheduledEventInvocation])
-> ReaderT r m (WithTotalCount [ScheduledEventInvocation])
forall a b. (a -> b) -> a -> b
$ GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
forall (m :: * -> *).
MonadMetadataStorage m =>
GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b
  deleteScheduledEvent :: EventId -> ScheduledEventType -> ReaderT r m ()
deleteScheduledEvent EventId
a ScheduledEventType
b = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ()) -> m () -> ReaderT r m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m ()
deleteScheduledEvent EventId
a ScheduledEventType
b

  insertAction :: ActionName
-> SessionVariables -> [Header] -> Value -> ReaderT r m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d = m ActionId -> ReaderT r m ActionId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionId -> ReaderT r m ActionId)
-> m ActionId -> ReaderT r m ActionId
forall a b. (a -> b) -> a -> b
$ ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d
  fetchUndeliveredActionEvents :: ReaderT r m [ActionLogItem]
fetchUndeliveredActionEvents = m [ActionLogItem] -> ReaderT r m [ActionLogItem]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m [ActionLogItem]
forall (m :: * -> *). MonadMetadataStorage m => m [ActionLogItem]
fetchUndeliveredActionEvents
  setActionStatus :: ActionId -> AsyncActionStatus -> ReaderT r m ()
setActionStatus ActionId
a AsyncActionStatus
b = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ()) -> m () -> ReaderT r m ()
forall a b. (a -> b) -> a -> b
$ ActionId -> AsyncActionStatus -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> AsyncActionStatus -> m ()
setActionStatus ActionId
a AsyncActionStatus
b
  fetchActionResponse :: ActionId -> ReaderT r m ActionLogResponse
fetchActionResponse = m ActionLogResponse -> ReaderT r m ActionLogResponse
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionLogResponse -> ReaderT r m ActionLogResponse)
-> (ActionId -> m ActionLogResponse)
-> ActionId
-> ReaderT r m ActionLogResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionId -> m ActionLogResponse
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> m ActionLogResponse
fetchActionResponse
  clearActionData :: ActionName -> ReaderT r m ()
clearActionData = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ())
-> (ActionName -> m ()) -> ActionName -> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionName -> m ()
forall (m :: * -> *). MonadMetadataStorage m => ActionName -> m ()
clearActionData
  setProcessingActionLogsToPending :: LockedActionIdArray -> ReaderT r m ()
setProcessingActionLogsToPending = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ())
-> (LockedActionIdArray -> m ())
-> LockedActionIdArray
-> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LockedActionIdArray -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
LockedActionIdArray -> m ()
setProcessingActionLogsToPending

instance (MonadMetadataStorage m) => MonadMetadataStorage (StateT s m) where
  fetchMetadataResourceVersion :: StateT s m MetadataResourceVersion
fetchMetadataResourceVersion = m MetadataResourceVersion -> StateT s m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
m MetadataResourceVersion
fetchMetadataResourceVersion
  fetchMetadata :: StateT s m (Metadata, MetadataResourceVersion)
fetchMetadata = m (Metadata, MetadataResourceVersion)
-> StateT s m (Metadata, MetadataResourceVersion)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Metadata, MetadataResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Metadata, MetadataResourceVersion)
fetchMetadata
  fetchMetadataNotifications :: MetadataResourceVersion
-> InstanceId
-> StateT s m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b = m [(MetadataResourceVersion, CacheInvalidations)]
-> StateT s m [(MetadataResourceVersion, CacheInvalidations)]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [(MetadataResourceVersion, CacheInvalidations)]
 -> StateT s m [(MetadataResourceVersion, CacheInvalidations)])
-> m [(MetadataResourceVersion, CacheInvalidations)]
-> StateT s m [(MetadataResourceVersion, CacheInvalidations)]
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b
  setMetadata :: MetadataResourceVersion
-> Metadata -> StateT s m MetadataResourceVersion
setMetadata MetadataResourceVersion
r = m MetadataResourceVersion -> StateT s m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m MetadataResourceVersion -> StateT s m MetadataResourceVersion)
-> (Metadata -> m MetadataResourceVersion)
-> Metadata
-> StateT s m MetadataResourceVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
setMetadata MetadataResourceVersion
r
  notifySchemaCacheSync :: MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> StateT s m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> m () -> StateT s m ()
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c
  getCatalogState :: StateT s m CatalogState
getCatalogState = m CatalogState -> StateT s m CatalogState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m CatalogState
forall (m :: * -> *). MonadMetadataStorage m => m CatalogState
getCatalogState
  setCatalogState :: CatalogStateType -> Value -> StateT s m ()
setCatalogState CatalogStateType
a Value
b = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> m () -> StateT s m ()
forall a b. (a -> b) -> a -> b
$ CatalogStateType -> Value -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m ()
setCatalogState CatalogStateType
a Value
b

  getMetadataDbUid :: StateT s m MetadataDbId
getMetadataDbUid = m MetadataDbId -> StateT s m MetadataDbId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataDbId
forall (m :: * -> *). MonadMetadataStorage m => m MetadataDbId
getMetadataDbUid
  checkMetadataStorageHealth :: StateT s m ()
checkMetadataStorageHealth = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
checkMetadataStorageHealth

  getDeprivedCronTriggerStats :: [TriggerName] -> StateT s m [CronTriggerStats]
getDeprivedCronTriggerStats = m [CronTriggerStats] -> StateT s m [CronTriggerStats]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [CronTriggerStats] -> StateT s m [CronTriggerStats])
-> ([TriggerName] -> m [CronTriggerStats])
-> [TriggerName]
-> StateT s m [CronTriggerStats]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TriggerName] -> m [CronTriggerStats]
forall (m :: * -> *).
MonadMetadataStorage m =>
[TriggerName] -> m [CronTriggerStats]
getDeprivedCronTriggerStats
  getScheduledEventsForDelivery :: StateT s m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery = m ([CronEvent], [OneOffScheduledEvent])
-> StateT s m ([CronEvent], [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ([CronEvent], [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery
  insertCronEvents :: [CronEventSeed] -> StateT s m ()
insertCronEvents = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> ([CronEventSeed] -> m ()) -> [CronEventSeed] -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CronEventSeed] -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m ()
insertCronEvents
  insertOneOffScheduledEvent :: OneOffEvent -> StateT s m EventId
insertOneOffScheduledEvent = m EventId -> StateT s m EventId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m EventId -> StateT s m EventId)
-> (OneOffEvent -> m EventId) -> OneOffEvent -> StateT s m EventId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OneOffEvent -> m EventId
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m EventId
insertOneOffScheduledEvent
  insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> StateT s m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> m () -> StateT s m ()
forall a b. (a -> b) -> a -> b
$ Invocation 'ScheduledType -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
Invocation 'ScheduledType -> ScheduledEventType -> m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b
  setScheduledEventOp :: EventId -> ScheduledEventOp -> ScheduledEventType -> StateT s m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> m () -> StateT s m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c
  unlockScheduledEvents :: ScheduledEventType -> [EventId] -> StateT s m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b = m Int -> StateT s m Int
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m Int -> StateT s m Int) -> m Int -> StateT s m Int
forall a b. (a -> b) -> a -> b
$ ScheduledEventType -> [EventId] -> m Int
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventType -> [EventId] -> m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b
  unlockAllLockedScheduledEvents :: StateT s m ()
unlockAllLockedScheduledEvents = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> m () -> StateT s m ()
forall a b. (a -> b) -> a -> b
$ m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
unlockAllLockedScheduledEvents
  clearFutureCronEvents :: ClearCronEvents -> StateT s m ()
clearFutureCronEvents = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> (ClearCronEvents -> m ()) -> ClearCronEvents -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ClearCronEvents -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m ()
clearFutureCronEvents
  getOneOffScheduledEvents :: ScheduledEventPagination
-> [ScheduledEventStatus]
-> StateT s m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b = m (WithTotalCount [OneOffScheduledEvent])
-> StateT s m (WithTotalCount [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [OneOffScheduledEvent])
 -> StateT s m (WithTotalCount [OneOffScheduledEvent]))
-> m (WithTotalCount [OneOffScheduledEvent])
-> StateT s m (WithTotalCount [OneOffScheduledEvent])
forall a b. (a -> b) -> a -> b
$ ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b
  getCronEvents :: TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> StateT s m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c = m (WithTotalCount [CronEvent])
-> StateT s m (WithTotalCount [CronEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [CronEvent])
 -> StateT s m (WithTotalCount [CronEvent]))
-> m (WithTotalCount [CronEvent])
-> StateT s m (WithTotalCount [CronEvent])
forall a b. (a -> b) -> a -> b
$ TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c
  getInvocations :: GetInvocationsBy
-> ScheduledEventPagination
-> StateT s m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b = m (WithTotalCount [ScheduledEventInvocation])
-> StateT s m (WithTotalCount [ScheduledEventInvocation])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [ScheduledEventInvocation])
 -> StateT s m (WithTotalCount [ScheduledEventInvocation]))
-> m (WithTotalCount [ScheduledEventInvocation])
-> StateT s m (WithTotalCount [ScheduledEventInvocation])
forall a b. (a -> b) -> a -> b
$ GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
forall (m :: * -> *).
MonadMetadataStorage m =>
GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b
  deleteScheduledEvent :: EventId -> ScheduledEventType -> StateT s m ()
deleteScheduledEvent EventId
a ScheduledEventType
b = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> m () -> StateT s m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m ()
deleteScheduledEvent EventId
a ScheduledEventType
b

  insertAction :: ActionName
-> SessionVariables -> [Header] -> Value -> StateT s m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d = m ActionId -> StateT s m ActionId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionId -> StateT s m ActionId)
-> m ActionId -> StateT s m ActionId
forall a b. (a -> b) -> a -> b
$ ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d
  fetchUndeliveredActionEvents :: StateT s m [ActionLogItem]
fetchUndeliveredActionEvents = m [ActionLogItem] -> StateT s m [ActionLogItem]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m [ActionLogItem]
forall (m :: * -> *). MonadMetadataStorage m => m [ActionLogItem]
fetchUndeliveredActionEvents
  setActionStatus :: ActionId -> AsyncActionStatus -> StateT s m ()
setActionStatus ActionId
a AsyncActionStatus
b = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> m () -> StateT s m ()
forall a b. (a -> b) -> a -> b
$ ActionId -> AsyncActionStatus -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> AsyncActionStatus -> m ()
setActionStatus ActionId
a AsyncActionStatus
b
  fetchActionResponse :: ActionId -> StateT s m ActionLogResponse
fetchActionResponse = m ActionLogResponse -> StateT s m ActionLogResponse
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionLogResponse -> StateT s m ActionLogResponse)
-> (ActionId -> m ActionLogResponse)
-> ActionId
-> StateT s m ActionLogResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionId -> m ActionLogResponse
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> m ActionLogResponse
fetchActionResponse
  clearActionData :: ActionName -> StateT s m ()
clearActionData = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> (ActionName -> m ()) -> ActionName -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionName -> m ()
forall (m :: * -> *). MonadMetadataStorage m => ActionName -> m ()
clearActionData
  setProcessingActionLogsToPending :: LockedActionIdArray -> StateT s m ()
setProcessingActionLogsToPending = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> (LockedActionIdArray -> m ())
-> LockedActionIdArray
-> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LockedActionIdArray -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
LockedActionIdArray -> m ()
setProcessingActionLogsToPending

instance (MonadMetadataStorage m) => MonadMetadataStorage (Tracing.TraceT m) where
  fetchMetadataResourceVersion :: TraceT m MetadataResourceVersion
fetchMetadataResourceVersion = m MetadataResourceVersion -> TraceT m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
m MetadataResourceVersion
fetchMetadataResourceVersion
  fetchMetadata :: TraceT m (Metadata, MetadataResourceVersion)
fetchMetadata = m (Metadata, MetadataResourceVersion)
-> TraceT m (Metadata, MetadataResourceVersion)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Metadata, MetadataResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Metadata, MetadataResourceVersion)
fetchMetadata
  fetchMetadataNotifications :: MetadataResourceVersion
-> InstanceId
-> TraceT m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b = m [(MetadataResourceVersion, CacheInvalidations)]
-> TraceT m [(MetadataResourceVersion, CacheInvalidations)]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [(MetadataResourceVersion, CacheInvalidations)]
 -> TraceT m [(MetadataResourceVersion, CacheInvalidations)])
-> m [(MetadataResourceVersion, CacheInvalidations)]
-> TraceT m [(MetadataResourceVersion, CacheInvalidations)]
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b
  setMetadata :: MetadataResourceVersion
-> Metadata -> TraceT m MetadataResourceVersion
setMetadata MetadataResourceVersion
r = m MetadataResourceVersion -> TraceT m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m MetadataResourceVersion -> TraceT m MetadataResourceVersion)
-> (Metadata -> m MetadataResourceVersion)
-> Metadata
-> TraceT m MetadataResourceVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
setMetadata MetadataResourceVersion
r
  notifySchemaCacheSync :: MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> TraceT m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ()) -> m () -> TraceT m ()
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c
  getCatalogState :: TraceT m CatalogState
getCatalogState = m CatalogState -> TraceT m CatalogState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m CatalogState
forall (m :: * -> *). MonadMetadataStorage m => m CatalogState
getCatalogState
  setCatalogState :: CatalogStateType -> Value -> TraceT m ()
setCatalogState CatalogStateType
a Value
b = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ()) -> m () -> TraceT m ()
forall a b. (a -> b) -> a -> b
$ CatalogStateType -> Value -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m ()
setCatalogState CatalogStateType
a Value
b

  getMetadataDbUid :: TraceT m MetadataDbId
getMetadataDbUid = m MetadataDbId -> TraceT m MetadataDbId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataDbId
forall (m :: * -> *). MonadMetadataStorage m => m MetadataDbId
getMetadataDbUid
  checkMetadataStorageHealth :: TraceT m ()
checkMetadataStorageHealth = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
checkMetadataStorageHealth

  getDeprivedCronTriggerStats :: [TriggerName] -> TraceT m [CronTriggerStats]
getDeprivedCronTriggerStats = m [CronTriggerStats] -> TraceT m [CronTriggerStats]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [CronTriggerStats] -> TraceT m [CronTriggerStats])
-> ([TriggerName] -> m [CronTriggerStats])
-> [TriggerName]
-> TraceT m [CronTriggerStats]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TriggerName] -> m [CronTriggerStats]
forall (m :: * -> *).
MonadMetadataStorage m =>
[TriggerName] -> m [CronTriggerStats]
getDeprivedCronTriggerStats
  getScheduledEventsForDelivery :: TraceT m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery = m ([CronEvent], [OneOffScheduledEvent])
-> TraceT m ([CronEvent], [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ([CronEvent], [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery
  insertCronEvents :: [CronEventSeed] -> TraceT m ()
insertCronEvents = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ())
-> ([CronEventSeed] -> m ()) -> [CronEventSeed] -> TraceT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CronEventSeed] -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m ()
insertCronEvents
  insertOneOffScheduledEvent :: OneOffEvent -> TraceT m EventId
insertOneOffScheduledEvent = m EventId -> TraceT m EventId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m EventId -> TraceT m EventId)
-> (OneOffEvent -> m EventId) -> OneOffEvent -> TraceT m EventId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OneOffEvent -> m EventId
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m EventId
insertOneOffScheduledEvent
  insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> TraceT m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ()) -> m () -> TraceT m ()
forall a b. (a -> b) -> a -> b
$ Invocation 'ScheduledType -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
Invocation 'ScheduledType -> ScheduledEventType -> m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b
  setScheduledEventOp :: EventId -> ScheduledEventOp -> ScheduledEventType -> TraceT m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ()) -> m () -> TraceT m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c
  unlockScheduledEvents :: ScheduledEventType -> [EventId] -> TraceT m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b = m Int -> TraceT m Int
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m Int -> TraceT m Int) -> m Int -> TraceT m Int
forall a b. (a -> b) -> a -> b
$ ScheduledEventType -> [EventId] -> m Int
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventType -> [EventId] -> m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b
  unlockAllLockedScheduledEvents :: TraceT m ()
unlockAllLockedScheduledEvents = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ()) -> m () -> TraceT m ()
forall a b. (a -> b) -> a -> b
$ m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
unlockAllLockedScheduledEvents
  clearFutureCronEvents :: ClearCronEvents -> TraceT m ()
clearFutureCronEvents = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ())
-> (ClearCronEvents -> m ()) -> ClearCronEvents -> TraceT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ClearCronEvents -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m ()
clearFutureCronEvents
  getOneOffScheduledEvents :: ScheduledEventPagination
-> [ScheduledEventStatus]
-> TraceT m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b = m (WithTotalCount [OneOffScheduledEvent])
-> TraceT m (WithTotalCount [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [OneOffScheduledEvent])
 -> TraceT m (WithTotalCount [OneOffScheduledEvent]))
-> m (WithTotalCount [OneOffScheduledEvent])
-> TraceT m (WithTotalCount [OneOffScheduledEvent])
forall a b. (a -> b) -> a -> b
$ ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b
  getCronEvents :: TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> TraceT m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c = m (WithTotalCount [CronEvent])
-> TraceT m (WithTotalCount [CronEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [CronEvent])
 -> TraceT m (WithTotalCount [CronEvent]))
-> m (WithTotalCount [CronEvent])
-> TraceT m (WithTotalCount [CronEvent])
forall a b. (a -> b) -> a -> b
$ TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c
  getInvocations :: GetInvocationsBy
-> ScheduledEventPagination
-> TraceT m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b = m (WithTotalCount [ScheduledEventInvocation])
-> TraceT m (WithTotalCount [ScheduledEventInvocation])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [ScheduledEventInvocation])
 -> TraceT m (WithTotalCount [ScheduledEventInvocation]))
-> m (WithTotalCount [ScheduledEventInvocation])
-> TraceT m (WithTotalCount [ScheduledEventInvocation])
forall a b. (a -> b) -> a -> b
$ GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
forall (m :: * -> *).
MonadMetadataStorage m =>
GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b
  deleteScheduledEvent :: EventId -> ScheduledEventType -> TraceT m ()
deleteScheduledEvent EventId
a ScheduledEventType
b = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ()) -> m () -> TraceT m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m ()
deleteScheduledEvent EventId
a ScheduledEventType
b

  insertAction :: ActionName
-> SessionVariables -> [Header] -> Value -> TraceT m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d = m ActionId -> TraceT m ActionId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionId -> TraceT m ActionId)
-> m ActionId -> TraceT m ActionId
forall a b. (a -> b) -> a -> b
$ ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d
  fetchUndeliveredActionEvents :: TraceT m [ActionLogItem]
fetchUndeliveredActionEvents = m [ActionLogItem] -> TraceT m [ActionLogItem]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m [ActionLogItem]
forall (m :: * -> *). MonadMetadataStorage m => m [ActionLogItem]
fetchUndeliveredActionEvents
  setActionStatus :: ActionId -> AsyncActionStatus -> TraceT m ()
setActionStatus ActionId
a AsyncActionStatus
b = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ()) -> m () -> TraceT m ()
forall a b. (a -> b) -> a -> b
$ ActionId -> AsyncActionStatus -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> AsyncActionStatus -> m ()
setActionStatus ActionId
a AsyncActionStatus
b
  fetchActionResponse :: ActionId -> TraceT m ActionLogResponse
fetchActionResponse = m ActionLogResponse -> TraceT m ActionLogResponse
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionLogResponse -> TraceT m ActionLogResponse)
-> (ActionId -> m ActionLogResponse)
-> ActionId
-> TraceT m ActionLogResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionId -> m ActionLogResponse
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> m ActionLogResponse
fetchActionResponse
  clearActionData :: ActionName -> TraceT m ()
clearActionData = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ())
-> (ActionName -> m ()) -> ActionName -> TraceT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionName -> m ()
forall (m :: * -> *). MonadMetadataStorage m => ActionName -> m ()
clearActionData
  setProcessingActionLogsToPending :: LockedActionIdArray -> TraceT m ()
setProcessingActionLogsToPending = m () -> TraceT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TraceT m ())
-> (LockedActionIdArray -> m ())
-> LockedActionIdArray
-> TraceT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LockedActionIdArray -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
LockedActionIdArray -> m ()
setProcessingActionLogsToPending

instance (MonadMetadataStorage m) => MonadMetadataStorage (ExceptT QErr m) where
  fetchMetadataResourceVersion :: ExceptT QErr m MetadataResourceVersion
fetchMetadataResourceVersion = m MetadataResourceVersion -> ExceptT QErr m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
m MetadataResourceVersion
fetchMetadataResourceVersion
  fetchMetadata :: ExceptT QErr m (Metadata, MetadataResourceVersion)
fetchMetadata = m (Metadata, MetadataResourceVersion)
-> ExceptT QErr m (Metadata, MetadataResourceVersion)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Metadata, MetadataResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Metadata, MetadataResourceVersion)
fetchMetadata
  fetchMetadataNotifications :: MetadataResourceVersion
-> InstanceId
-> ExceptT QErr m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b = m [(MetadataResourceVersion, CacheInvalidations)]
-> ExceptT QErr m [(MetadataResourceVersion, CacheInvalidations)]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [(MetadataResourceVersion, CacheInvalidations)]
 -> ExceptT QErr m [(MetadataResourceVersion, CacheInvalidations)])
-> m [(MetadataResourceVersion, CacheInvalidations)]
-> ExceptT QErr m [(MetadataResourceVersion, CacheInvalidations)]
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b
  setMetadata :: MetadataResourceVersion
-> Metadata -> ExceptT QErr m MetadataResourceVersion
setMetadata MetadataResourceVersion
r = m MetadataResourceVersion -> ExceptT QErr m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m MetadataResourceVersion
 -> ExceptT QErr m MetadataResourceVersion)
-> (Metadata -> m MetadataResourceVersion)
-> Metadata
-> ExceptT QErr m MetadataResourceVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
setMetadata MetadataResourceVersion
r
  notifySchemaCacheSync :: MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> ExceptT QErr m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ()) -> m () -> ExceptT QErr m ()
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c
  getCatalogState :: ExceptT QErr m CatalogState
getCatalogState = m CatalogState -> ExceptT QErr m CatalogState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m CatalogState
forall (m :: * -> *). MonadMetadataStorage m => m CatalogState
getCatalogState
  setCatalogState :: CatalogStateType -> Value -> ExceptT QErr m ()
setCatalogState CatalogStateType
a Value
b = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ()) -> m () -> ExceptT QErr m ()
forall a b. (a -> b) -> a -> b
$ CatalogStateType -> Value -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m ()
setCatalogState CatalogStateType
a Value
b

  getMetadataDbUid :: ExceptT QErr m MetadataDbId
getMetadataDbUid = m MetadataDbId -> ExceptT QErr m MetadataDbId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataDbId
forall (m :: * -> *). MonadMetadataStorage m => m MetadataDbId
getMetadataDbUid
  checkMetadataStorageHealth :: ExceptT QErr m ()
checkMetadataStorageHealth = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
checkMetadataStorageHealth

  getDeprivedCronTriggerStats :: [TriggerName] -> ExceptT QErr m [CronTriggerStats]
getDeprivedCronTriggerStats = m [CronTriggerStats] -> ExceptT QErr m [CronTriggerStats]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [CronTriggerStats] -> ExceptT QErr m [CronTriggerStats])
-> ([TriggerName] -> m [CronTriggerStats])
-> [TriggerName]
-> ExceptT QErr m [CronTriggerStats]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TriggerName] -> m [CronTriggerStats]
forall (m :: * -> *).
MonadMetadataStorage m =>
[TriggerName] -> m [CronTriggerStats]
getDeprivedCronTriggerStats
  getScheduledEventsForDelivery :: ExceptT QErr m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery = m ([CronEvent], [OneOffScheduledEvent])
-> ExceptT QErr m ([CronEvent], [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ([CronEvent], [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery
  insertCronEvents :: [CronEventSeed] -> ExceptT QErr m ()
insertCronEvents = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ())
-> ([CronEventSeed] -> m ())
-> [CronEventSeed]
-> ExceptT QErr m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CronEventSeed] -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m ()
insertCronEvents
  insertOneOffScheduledEvent :: OneOffEvent -> ExceptT QErr m EventId
insertOneOffScheduledEvent = m EventId -> ExceptT QErr m EventId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m EventId -> ExceptT QErr m EventId)
-> (OneOffEvent -> m EventId)
-> OneOffEvent
-> ExceptT QErr m EventId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OneOffEvent -> m EventId
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m EventId
insertOneOffScheduledEvent
  insertScheduledEventInvocation :: Invocation 'ScheduledType
-> ScheduledEventType -> ExceptT QErr m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ()) -> m () -> ExceptT QErr m ()
forall a b. (a -> b) -> a -> b
$ Invocation 'ScheduledType -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
Invocation 'ScheduledType -> ScheduledEventType -> m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b
  setScheduledEventOp :: EventId
-> ScheduledEventOp -> ScheduledEventType -> ExceptT QErr m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ()) -> m () -> ExceptT QErr m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c
  unlockScheduledEvents :: ScheduledEventType -> [EventId] -> ExceptT QErr m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b = m Int -> ExceptT QErr m Int
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m Int -> ExceptT QErr m Int) -> m Int -> ExceptT QErr m Int
forall a b. (a -> b) -> a -> b
$ ScheduledEventType -> [EventId] -> m Int
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventType -> [EventId] -> m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b
  unlockAllLockedScheduledEvents :: ExceptT QErr m ()
unlockAllLockedScheduledEvents = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ()) -> m () -> ExceptT QErr m ()
forall a b. (a -> b) -> a -> b
$ m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
unlockAllLockedScheduledEvents
  clearFutureCronEvents :: ClearCronEvents -> ExceptT QErr m ()
clearFutureCronEvents = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ())
-> (ClearCronEvents -> m ())
-> ClearCronEvents
-> ExceptT QErr m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ClearCronEvents -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m ()
clearFutureCronEvents
  getOneOffScheduledEvents :: ScheduledEventPagination
-> [ScheduledEventStatus]
-> ExceptT QErr m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b = m (WithTotalCount [OneOffScheduledEvent])
-> ExceptT QErr m (WithTotalCount [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [OneOffScheduledEvent])
 -> ExceptT QErr m (WithTotalCount [OneOffScheduledEvent]))
-> m (WithTotalCount [OneOffScheduledEvent])
-> ExceptT QErr m (WithTotalCount [OneOffScheduledEvent])
forall a b. (a -> b) -> a -> b
$ ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b
  getCronEvents :: TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> ExceptT QErr m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c = m (WithTotalCount [CronEvent])
-> ExceptT QErr m (WithTotalCount [CronEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [CronEvent])
 -> ExceptT QErr m (WithTotalCount [CronEvent]))
-> m (WithTotalCount [CronEvent])
-> ExceptT QErr m (WithTotalCount [CronEvent])
forall a b. (a -> b) -> a -> b
$ TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c
  getInvocations :: GetInvocationsBy
-> ScheduledEventPagination
-> ExceptT QErr m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b = m (WithTotalCount [ScheduledEventInvocation])
-> ExceptT QErr m (WithTotalCount [ScheduledEventInvocation])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [ScheduledEventInvocation])
 -> ExceptT QErr m (WithTotalCount [ScheduledEventInvocation]))
-> m (WithTotalCount [ScheduledEventInvocation])
-> ExceptT QErr m (WithTotalCount [ScheduledEventInvocation])
forall a b. (a -> b) -> a -> b
$ GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
forall (m :: * -> *).
MonadMetadataStorage m =>
GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b
  deleteScheduledEvent :: EventId -> ScheduledEventType -> ExceptT QErr m ()
deleteScheduledEvent EventId
a ScheduledEventType
b = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ()) -> m () -> ExceptT QErr m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m ()
deleteScheduledEvent EventId
a ScheduledEventType
b

  insertAction :: ActionName
-> SessionVariables -> [Header] -> Value -> ExceptT QErr m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d = m ActionId -> ExceptT QErr m ActionId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionId -> ExceptT QErr m ActionId)
-> m ActionId -> ExceptT QErr m ActionId
forall a b. (a -> b) -> a -> b
$ ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d
  fetchUndeliveredActionEvents :: ExceptT QErr m [ActionLogItem]
fetchUndeliveredActionEvents = m [ActionLogItem] -> ExceptT QErr m [ActionLogItem]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m [ActionLogItem]
forall (m :: * -> *). MonadMetadataStorage m => m [ActionLogItem]
fetchUndeliveredActionEvents
  setActionStatus :: ActionId -> AsyncActionStatus -> ExceptT QErr m ()
setActionStatus ActionId
a AsyncActionStatus
b = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ()) -> m () -> ExceptT QErr m ()
forall a b. (a -> b) -> a -> b
$ ActionId -> AsyncActionStatus -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> AsyncActionStatus -> m ()
setActionStatus ActionId
a AsyncActionStatus
b
  fetchActionResponse :: ActionId -> ExceptT QErr m ActionLogResponse
fetchActionResponse = m ActionLogResponse -> ExceptT QErr m ActionLogResponse
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionLogResponse -> ExceptT QErr m ActionLogResponse)
-> (ActionId -> m ActionLogResponse)
-> ActionId
-> ExceptT QErr m ActionLogResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionId -> m ActionLogResponse
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> m ActionLogResponse
fetchActionResponse
  clearActionData :: ActionName -> ExceptT QErr m ()
clearActionData = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ())
-> (ActionName -> m ()) -> ActionName -> ExceptT QErr m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionName -> m ()
forall (m :: * -> *). MonadMetadataStorage m => ActionName -> m ()
clearActionData
  setProcessingActionLogsToPending :: LockedActionIdArray -> ExceptT QErr m ()
setProcessingActionLogsToPending = m () -> ExceptT QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT QErr m ())
-> (LockedActionIdArray -> m ())
-> LockedActionIdArray
-> ExceptT QErr m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LockedActionIdArray -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
LockedActionIdArray -> m ()
setProcessingActionLogsToPending

instance (MonadMetadataStorage m) => MonadMetadataStorage (MetadataT m) where
  fetchMetadataResourceVersion :: MetadataT m MetadataResourceVersion
fetchMetadataResourceVersion = m MetadataResourceVersion -> MetadataT m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
m MetadataResourceVersion
fetchMetadataResourceVersion
  fetchMetadata :: MetadataT m (Metadata, MetadataResourceVersion)
fetchMetadata = m (Metadata, MetadataResourceVersion)
-> MetadataT m (Metadata, MetadataResourceVersion)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Metadata, MetadataResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Metadata, MetadataResourceVersion)
fetchMetadata
  fetchMetadataNotifications :: MetadataResourceVersion
-> InstanceId
-> MetadataT m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b = m [(MetadataResourceVersion, CacheInvalidations)]
-> MetadataT m [(MetadataResourceVersion, CacheInvalidations)]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [(MetadataResourceVersion, CacheInvalidations)]
 -> MetadataT m [(MetadataResourceVersion, CacheInvalidations)])
-> m [(MetadataResourceVersion, CacheInvalidations)]
-> MetadataT m [(MetadataResourceVersion, CacheInvalidations)]
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b
  setMetadata :: MetadataResourceVersion
-> Metadata -> MetadataT m MetadataResourceVersion
setMetadata MetadataResourceVersion
r = m MetadataResourceVersion -> MetadataT m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m MetadataResourceVersion -> MetadataT m MetadataResourceVersion)
-> (Metadata -> m MetadataResourceVersion)
-> Metadata
-> MetadataT m MetadataResourceVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
setMetadata MetadataResourceVersion
r
  notifySchemaCacheSync :: MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> MetadataT m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ()) -> m () -> MetadataT m ()
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c
  getCatalogState :: MetadataT m CatalogState
getCatalogState = m CatalogState -> MetadataT m CatalogState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m CatalogState
forall (m :: * -> *). MonadMetadataStorage m => m CatalogState
getCatalogState
  setCatalogState :: CatalogStateType -> Value -> MetadataT m ()
setCatalogState CatalogStateType
a Value
b = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ()) -> m () -> MetadataT m ()
forall a b. (a -> b) -> a -> b
$ CatalogStateType -> Value -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m ()
setCatalogState CatalogStateType
a Value
b

  getMetadataDbUid :: MetadataT m MetadataDbId
getMetadataDbUid = m MetadataDbId -> MetadataT m MetadataDbId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataDbId
forall (m :: * -> *). MonadMetadataStorage m => m MetadataDbId
getMetadataDbUid
  checkMetadataStorageHealth :: MetadataT m ()
checkMetadataStorageHealth = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
checkMetadataStorageHealth

  getDeprivedCronTriggerStats :: [TriggerName] -> MetadataT m [CronTriggerStats]
getDeprivedCronTriggerStats = m [CronTriggerStats] -> MetadataT m [CronTriggerStats]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [CronTriggerStats] -> MetadataT m [CronTriggerStats])
-> ([TriggerName] -> m [CronTriggerStats])
-> [TriggerName]
-> MetadataT m [CronTriggerStats]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TriggerName] -> m [CronTriggerStats]
forall (m :: * -> *).
MonadMetadataStorage m =>
[TriggerName] -> m [CronTriggerStats]
getDeprivedCronTriggerStats
  getScheduledEventsForDelivery :: MetadataT m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery = m ([CronEvent], [OneOffScheduledEvent])
-> MetadataT m ([CronEvent], [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ([CronEvent], [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery
  insertCronEvents :: [CronEventSeed] -> MetadataT m ()
insertCronEvents = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ())
-> ([CronEventSeed] -> m ()) -> [CronEventSeed] -> MetadataT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CronEventSeed] -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m ()
insertCronEvents
  insertOneOffScheduledEvent :: OneOffEvent -> MetadataT m EventId
insertOneOffScheduledEvent = m EventId -> MetadataT m EventId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m EventId -> MetadataT m EventId)
-> (OneOffEvent -> m EventId) -> OneOffEvent -> MetadataT m EventId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OneOffEvent -> m EventId
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m EventId
insertOneOffScheduledEvent
  insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> MetadataT m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ()) -> m () -> MetadataT m ()
forall a b. (a -> b) -> a -> b
$ Invocation 'ScheduledType -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
Invocation 'ScheduledType -> ScheduledEventType -> m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b
  setScheduledEventOp :: EventId -> ScheduledEventOp -> ScheduledEventType -> MetadataT m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ()) -> m () -> MetadataT m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c
  unlockScheduledEvents :: ScheduledEventType -> [EventId] -> MetadataT m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b = m Int -> MetadataT m Int
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m Int -> MetadataT m Int) -> m Int -> MetadataT m Int
forall a b. (a -> b) -> a -> b
$ ScheduledEventType -> [EventId] -> m Int
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventType -> [EventId] -> m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b
  unlockAllLockedScheduledEvents :: MetadataT m ()
unlockAllLockedScheduledEvents = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ()) -> m () -> MetadataT m ()
forall a b. (a -> b) -> a -> b
$ m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
unlockAllLockedScheduledEvents
  clearFutureCronEvents :: ClearCronEvents -> MetadataT m ()
clearFutureCronEvents = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ())
-> (ClearCronEvents -> m ()) -> ClearCronEvents -> MetadataT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ClearCronEvents -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m ()
clearFutureCronEvents
  getOneOffScheduledEvents :: ScheduledEventPagination
-> [ScheduledEventStatus]
-> MetadataT m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b = m (WithTotalCount [OneOffScheduledEvent])
-> MetadataT m (WithTotalCount [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [OneOffScheduledEvent])
 -> MetadataT m (WithTotalCount [OneOffScheduledEvent]))
-> m (WithTotalCount [OneOffScheduledEvent])
-> MetadataT m (WithTotalCount [OneOffScheduledEvent])
forall a b. (a -> b) -> a -> b
$ ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b
  getCronEvents :: TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> MetadataT m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c = m (WithTotalCount [CronEvent])
-> MetadataT m (WithTotalCount [CronEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [CronEvent])
 -> MetadataT m (WithTotalCount [CronEvent]))
-> m (WithTotalCount [CronEvent])
-> MetadataT m (WithTotalCount [CronEvent])
forall a b. (a -> b) -> a -> b
$ TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c
  getInvocations :: GetInvocationsBy
-> ScheduledEventPagination
-> MetadataT m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b = m (WithTotalCount [ScheduledEventInvocation])
-> MetadataT m (WithTotalCount [ScheduledEventInvocation])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [ScheduledEventInvocation])
 -> MetadataT m (WithTotalCount [ScheduledEventInvocation]))
-> m (WithTotalCount [ScheduledEventInvocation])
-> MetadataT m (WithTotalCount [ScheduledEventInvocation])
forall a b. (a -> b) -> a -> b
$ GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
forall (m :: * -> *).
MonadMetadataStorage m =>
GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b
  deleteScheduledEvent :: EventId -> ScheduledEventType -> MetadataT m ()
deleteScheduledEvent EventId
a ScheduledEventType
b = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ()) -> m () -> MetadataT m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m ()
deleteScheduledEvent EventId
a ScheduledEventType
b

  insertAction :: ActionName
-> SessionVariables -> [Header] -> Value -> MetadataT m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d = m ActionId -> MetadataT m ActionId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionId -> MetadataT m ActionId)
-> m ActionId -> MetadataT m ActionId
forall a b. (a -> b) -> a -> b
$ ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d
  fetchUndeliveredActionEvents :: MetadataT m [ActionLogItem]
fetchUndeliveredActionEvents = m [ActionLogItem] -> MetadataT m [ActionLogItem]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m [ActionLogItem]
forall (m :: * -> *). MonadMetadataStorage m => m [ActionLogItem]
fetchUndeliveredActionEvents
  setActionStatus :: ActionId -> AsyncActionStatus -> MetadataT m ()
setActionStatus ActionId
a AsyncActionStatus
b = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ()) -> m () -> MetadataT m ()
forall a b. (a -> b) -> a -> b
$ ActionId -> AsyncActionStatus -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> AsyncActionStatus -> m ()
setActionStatus ActionId
a AsyncActionStatus
b
  fetchActionResponse :: ActionId -> MetadataT m ActionLogResponse
fetchActionResponse = m ActionLogResponse -> MetadataT m ActionLogResponse
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionLogResponse -> MetadataT m ActionLogResponse)
-> (ActionId -> m ActionLogResponse)
-> ActionId
-> MetadataT m ActionLogResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionId -> m ActionLogResponse
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> m ActionLogResponse
fetchActionResponse
  clearActionData :: ActionName -> MetadataT m ()
clearActionData = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ())
-> (ActionName -> m ()) -> ActionName -> MetadataT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionName -> m ()
forall (m :: * -> *). MonadMetadataStorage m => ActionName -> m ()
clearActionData
  setProcessingActionLogsToPending :: LockedActionIdArray -> MetadataT m ()
setProcessingActionLogsToPending = m () -> MetadataT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MetadataT m ())
-> (LockedActionIdArray -> m ())
-> LockedActionIdArray
-> MetadataT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LockedActionIdArray -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
LockedActionIdArray -> m ()
setProcessingActionLogsToPending

instance (MonadMetadataStorage m) => MonadMetadataStorage (Q.TxET QErr m) where
  fetchMetadataResourceVersion :: TxET QErr m MetadataResourceVersion
fetchMetadataResourceVersion = m MetadataResourceVersion -> TxET QErr m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
m MetadataResourceVersion
fetchMetadataResourceVersion
  fetchMetadata :: TxET QErr m (Metadata, MetadataResourceVersion)
fetchMetadata = m (Metadata, MetadataResourceVersion)
-> TxET QErr m (Metadata, MetadataResourceVersion)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Metadata, MetadataResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Metadata, MetadataResourceVersion)
fetchMetadata
  fetchMetadataNotifications :: MetadataResourceVersion
-> InstanceId
-> TxET QErr m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b = m [(MetadataResourceVersion, CacheInvalidations)]
-> TxET QErr m [(MetadataResourceVersion, CacheInvalidations)]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [(MetadataResourceVersion, CacheInvalidations)]
 -> TxET QErr m [(MetadataResourceVersion, CacheInvalidations)])
-> m [(MetadataResourceVersion, CacheInvalidations)]
-> TxET QErr m [(MetadataResourceVersion, CacheInvalidations)]
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b
  setMetadata :: MetadataResourceVersion
-> Metadata -> TxET QErr m MetadataResourceVersion
setMetadata MetadataResourceVersion
r = m MetadataResourceVersion -> TxET QErr m MetadataResourceVersion
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m MetadataResourceVersion -> TxET QErr m MetadataResourceVersion)
-> (Metadata -> m MetadataResourceVersion)
-> Metadata
-> TxET QErr m MetadataResourceVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
setMetadata MetadataResourceVersion
r
  notifySchemaCacheSync :: MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> TxET QErr m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ()) -> m () -> TxET QErr m ()
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c
  getCatalogState :: TxET QErr m CatalogState
getCatalogState = m CatalogState -> TxET QErr m CatalogState
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m CatalogState
forall (m :: * -> *). MonadMetadataStorage m => m CatalogState
getCatalogState
  setCatalogState :: CatalogStateType -> Value -> TxET QErr m ()
setCatalogState CatalogStateType
a Value
b = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ()) -> m () -> TxET QErr m ()
forall a b. (a -> b) -> a -> b
$ CatalogStateType -> Value -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m ()
setCatalogState CatalogStateType
a Value
b

  getMetadataDbUid :: TxET QErr m MetadataDbId
getMetadataDbUid = m MetadataDbId -> TxET QErr m MetadataDbId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m MetadataDbId
forall (m :: * -> *). MonadMetadataStorage m => m MetadataDbId
getMetadataDbUid
  checkMetadataStorageHealth :: TxET QErr m ()
checkMetadataStorageHealth = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
checkMetadataStorageHealth

  getDeprivedCronTriggerStats :: [TriggerName] -> TxET QErr m [CronTriggerStats]
getDeprivedCronTriggerStats = m [CronTriggerStats] -> TxET QErr m [CronTriggerStats]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [CronTriggerStats] -> TxET QErr m [CronTriggerStats])
-> ([TriggerName] -> m [CronTriggerStats])
-> [TriggerName]
-> TxET QErr m [CronTriggerStats]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TriggerName] -> m [CronTriggerStats]
forall (m :: * -> *).
MonadMetadataStorage m =>
[TriggerName] -> m [CronTriggerStats]
getDeprivedCronTriggerStats
  getScheduledEventsForDelivery :: TxET QErr m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery = m ([CronEvent], [OneOffScheduledEvent])
-> TxET QErr m ([CronEvent], [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m ([CronEvent], [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery
  insertCronEvents :: [CronEventSeed] -> TxET QErr m ()
insertCronEvents = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ())
-> ([CronEventSeed] -> m ()) -> [CronEventSeed] -> TxET QErr m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CronEventSeed] -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m ()
insertCronEvents
  insertOneOffScheduledEvent :: OneOffEvent -> TxET QErr m EventId
insertOneOffScheduledEvent = m EventId -> TxET QErr m EventId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m EventId -> TxET QErr m EventId)
-> (OneOffEvent -> m EventId) -> OneOffEvent -> TxET QErr m EventId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OneOffEvent -> m EventId
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m EventId
insertOneOffScheduledEvent
  insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> TxET QErr m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ()) -> m () -> TxET QErr m ()
forall a b. (a -> b) -> a -> b
$ Invocation 'ScheduledType -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
Invocation 'ScheduledType -> ScheduledEventType -> m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b
  setScheduledEventOp :: EventId -> ScheduledEventOp -> ScheduledEventType -> TxET QErr m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ()) -> m () -> TxET QErr m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c
  unlockScheduledEvents :: ScheduledEventType -> [EventId] -> TxET QErr m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b = m Int -> TxET QErr m Int
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m Int -> TxET QErr m Int) -> m Int -> TxET QErr m Int
forall a b. (a -> b) -> a -> b
$ ScheduledEventType -> [EventId] -> m Int
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventType -> [EventId] -> m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b
  unlockAllLockedScheduledEvents :: TxET QErr m ()
unlockAllLockedScheduledEvents = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ()) -> m () -> TxET QErr m ()
forall a b. (a -> b) -> a -> b
$ m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
unlockAllLockedScheduledEvents
  clearFutureCronEvents :: ClearCronEvents -> TxET QErr m ()
clearFutureCronEvents = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ())
-> (ClearCronEvents -> m ()) -> ClearCronEvents -> TxET QErr m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ClearCronEvents -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m ()
clearFutureCronEvents
  getOneOffScheduledEvents :: ScheduledEventPagination
-> [ScheduledEventStatus]
-> TxET QErr m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b = m (WithTotalCount [OneOffScheduledEvent])
-> TxET QErr m (WithTotalCount [OneOffScheduledEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [OneOffScheduledEvent])
 -> TxET QErr m (WithTotalCount [OneOffScheduledEvent]))
-> m (WithTotalCount [OneOffScheduledEvent])
-> TxET QErr m (WithTotalCount [OneOffScheduledEvent])
forall a b. (a -> b) -> a -> b
$ ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b
  getCronEvents :: TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> TxET QErr m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c = m (WithTotalCount [CronEvent])
-> TxET QErr m (WithTotalCount [CronEvent])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [CronEvent])
 -> TxET QErr m (WithTotalCount [CronEvent]))
-> m (WithTotalCount [CronEvent])
-> TxET QErr m (WithTotalCount [CronEvent])
forall a b. (a -> b) -> a -> b
$ TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c
  getInvocations :: GetInvocationsBy
-> ScheduledEventPagination
-> TxET QErr m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b = m (WithTotalCount [ScheduledEventInvocation])
-> TxET QErr m (WithTotalCount [ScheduledEventInvocation])
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (WithTotalCount [ScheduledEventInvocation])
 -> TxET QErr m (WithTotalCount [ScheduledEventInvocation]))
-> m (WithTotalCount [ScheduledEventInvocation])
-> TxET QErr m (WithTotalCount [ScheduledEventInvocation])
forall a b. (a -> b) -> a -> b
$ GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
forall (m :: * -> *).
MonadMetadataStorage m =>
GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b
  deleteScheduledEvent :: EventId -> ScheduledEventType -> TxET QErr m ()
deleteScheduledEvent EventId
a ScheduledEventType
b = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ()) -> m () -> TxET QErr m ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m ()
deleteScheduledEvent EventId
a ScheduledEventType
b

  insertAction :: ActionName
-> SessionVariables -> [Header] -> Value -> TxET QErr m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d = m ActionId -> TxET QErr m ActionId
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionId -> TxET QErr m ActionId)
-> m ActionId -> TxET QErr m ActionId
forall a b. (a -> b) -> a -> b
$ ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d
  fetchUndeliveredActionEvents :: TxET QErr m [ActionLogItem]
fetchUndeliveredActionEvents = m [ActionLogItem] -> TxET QErr m [ActionLogItem]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m [ActionLogItem]
forall (m :: * -> *). MonadMetadataStorage m => m [ActionLogItem]
fetchUndeliveredActionEvents
  setActionStatus :: ActionId -> AsyncActionStatus -> TxET QErr m ()
setActionStatus ActionId
a AsyncActionStatus
b = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ()) -> m () -> TxET QErr m ()
forall a b. (a -> b) -> a -> b
$ ActionId -> AsyncActionStatus -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> AsyncActionStatus -> m ()
setActionStatus ActionId
a AsyncActionStatus
b
  fetchActionResponse :: ActionId -> TxET QErr m ActionLogResponse
fetchActionResponse = m ActionLogResponse -> TxET QErr m ActionLogResponse
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ActionLogResponse -> TxET QErr m ActionLogResponse)
-> (ActionId -> m ActionLogResponse)
-> ActionId
-> TxET QErr m ActionLogResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionId -> m ActionLogResponse
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> m ActionLogResponse
fetchActionResponse
  clearActionData :: ActionName -> TxET QErr m ()
clearActionData = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ())
-> (ActionName -> m ()) -> ActionName -> TxET QErr m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionName -> m ()
forall (m :: * -> *). MonadMetadataStorage m => ActionName -> m ()
clearActionData
  setProcessingActionLogsToPending :: LockedActionIdArray -> TxET QErr m ()
setProcessingActionLogsToPending = m () -> TxET QErr m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> TxET QErr m ())
-> (LockedActionIdArray -> m ())
-> LockedActionIdArray
-> TxET QErr m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LockedActionIdArray -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
LockedActionIdArray -> m ()
setProcessingActionLogsToPending

{- Note [Generic MetadataStorageT transformer]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All methods of the MonadMetadataStorage class may fail, which we represent in
the usual way using a MonadError superclass:

    class MonadError QErr m => MonadMetadataStorage m

However, unusually, the location where we pick a concrete MonadMetadataStorage
instance is not a context where we can handle errors, and as such the monad at
that point has no MonadError instance! Instead, clients of MonadMetadataStorage
are expected to handle errors /locally/, even though the code is parameterized
over an arbitrary metadata storage mechanism.

To encode this, we take a slightly unorthodox approach involving the auxiliary
MetadataStorageT transformer, which is really just a wrapper around ExceptT:

    newtype MetadataStorageT m a
      = MetadataStorageT { unMetadataStorageT :: ExceptT QErr m a }

We then define MonadMetadataStorage instances on a transformer stack comprising
both MetadataStorageT and a concrete base monad:

    instance MonadMetadataStorage (MetadataStorageT PGMetadataStorageApp)

This looks unconventional, but it allows polymorphic code to be parameterized
over the metadata storage implementation while still handling errors locally.
Such functions include a constraint of the form

    MonadMetadataStorage (MetadataStorageT m) => ...

and use runMetadataStorageT at the location where errors should be handled, e.g.:

    result <- runMetadataStorageT do
      {- ... some metadata operations ... -}
    case result of
      Left err -> ...
      Right value -> ...

In other words, runMetadataStorageT serves as a marker that says “I’m going to
handle exceptions raised by metadata operations right here,” which allows them
to be handled more locally than the point at which the concrete
MonadMetadataStorage instance (and thus the particular metadata storage
implementation) is actually chosen. -}

-- | The 'MetadataStorageT' transformer adds ability to throw exceptions
-- for monads deriving @'MonadMetadataStorage' instance.
-- For more details see Note [Generic MetadataStorageT transformer]
newtype MetadataStorageT m a = MetadataStorageT {MetadataStorageT m a -> ExceptT QErr m a
unMetadataStorageT :: ExceptT QErr m a}
  deriving
    ( a -> MetadataStorageT m b -> MetadataStorageT m a
(a -> b) -> MetadataStorageT m a -> MetadataStorageT m b
(forall a b.
 (a -> b) -> MetadataStorageT m a -> MetadataStorageT m b)
-> (forall a b. a -> MetadataStorageT m b -> MetadataStorageT m a)
-> Functor (MetadataStorageT m)
forall a b. a -> MetadataStorageT m b -> MetadataStorageT m a
forall a b.
(a -> b) -> MetadataStorageT m a -> MetadataStorageT m b
forall (m :: * -> *) a b.
Functor m =>
a -> MetadataStorageT m b -> MetadataStorageT m a
forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> MetadataStorageT m a -> MetadataStorageT m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> MetadataStorageT m b -> MetadataStorageT m a
$c<$ :: forall (m :: * -> *) a b.
Functor m =>
a -> MetadataStorageT m b -> MetadataStorageT m a
fmap :: (a -> b) -> MetadataStorageT m a -> MetadataStorageT m b
$cfmap :: forall (m :: * -> *) a b.
Functor m =>
(a -> b) -> MetadataStorageT m a -> MetadataStorageT m b
Functor,
      Functor (MetadataStorageT m)
a -> MetadataStorageT m a
Functor (MetadataStorageT m)
-> (forall a. a -> MetadataStorageT m a)
-> (forall a b.
    MetadataStorageT m (a -> b)
    -> MetadataStorageT m a -> MetadataStorageT m b)
-> (forall a b c.
    (a -> b -> c)
    -> MetadataStorageT m a
    -> MetadataStorageT m b
    -> MetadataStorageT m c)
-> (forall a b.
    MetadataStorageT m a
    -> MetadataStorageT m b -> MetadataStorageT m b)
-> (forall a b.
    MetadataStorageT m a
    -> MetadataStorageT m b -> MetadataStorageT m a)
-> Applicative (MetadataStorageT m)
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m a
MetadataStorageT m (a -> b)
-> MetadataStorageT m a -> MetadataStorageT m b
(a -> b -> c)
-> MetadataStorageT m a
-> MetadataStorageT m b
-> MetadataStorageT m c
forall a. a -> MetadataStorageT m a
forall a b.
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m a
forall a b.
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
forall a b.
MetadataStorageT m (a -> b)
-> MetadataStorageT m a -> MetadataStorageT m b
forall a b c.
(a -> b -> c)
-> MetadataStorageT m a
-> MetadataStorageT m b
-> MetadataStorageT m c
forall (m :: * -> *). Monad m => Functor (MetadataStorageT m)
forall (m :: * -> *) a. Monad m => a -> MetadataStorageT m a
forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m a
forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m (a -> b)
-> MetadataStorageT m a -> MetadataStorageT m b
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> c)
-> MetadataStorageT m a
-> MetadataStorageT m b
-> MetadataStorageT m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m a
$c<* :: forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m a
*> :: MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
$c*> :: forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
liftA2 :: (a -> b -> c)
-> MetadataStorageT m a
-> MetadataStorageT m b
-> MetadataStorageT m c
$cliftA2 :: forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> c)
-> MetadataStorageT m a
-> MetadataStorageT m b
-> MetadataStorageT m c
<*> :: MetadataStorageT m (a -> b)
-> MetadataStorageT m a -> MetadataStorageT m b
$c<*> :: forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m (a -> b)
-> MetadataStorageT m a -> MetadataStorageT m b
pure :: a -> MetadataStorageT m a
$cpure :: forall (m :: * -> *) a. Monad m => a -> MetadataStorageT m a
$cp1Applicative :: forall (m :: * -> *). Monad m => Functor (MetadataStorageT m)
Applicative,
      Applicative (MetadataStorageT m)
a -> MetadataStorageT m a
Applicative (MetadataStorageT m)
-> (forall a b.
    MetadataStorageT m a
    -> (a -> MetadataStorageT m b) -> MetadataStorageT m b)
-> (forall a b.
    MetadataStorageT m a
    -> MetadataStorageT m b -> MetadataStorageT m b)
-> (forall a. a -> MetadataStorageT m a)
-> Monad (MetadataStorageT m)
MetadataStorageT m a
-> (a -> MetadataStorageT m b) -> MetadataStorageT m b
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
forall a. a -> MetadataStorageT m a
forall a b.
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
forall a b.
MetadataStorageT m a
-> (a -> MetadataStorageT m b) -> MetadataStorageT m b
forall (m :: * -> *). Monad m => Applicative (MetadataStorageT m)
forall (m :: * -> *) a. Monad m => a -> MetadataStorageT m a
forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m a
-> (a -> MetadataStorageT m b) -> MetadataStorageT m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> MetadataStorageT m a
$creturn :: forall (m :: * -> *) a. Monad m => a -> MetadataStorageT m a
>> :: MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
$c>> :: forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m a
-> MetadataStorageT m b -> MetadataStorageT m b
>>= :: MetadataStorageT m a
-> (a -> MetadataStorageT m b) -> MetadataStorageT m b
$c>>= :: forall (m :: * -> *) a b.
Monad m =>
MetadataStorageT m a
-> (a -> MetadataStorageT m b) -> MetadataStorageT m b
$cp1Monad :: forall (m :: * -> *). Monad m => Applicative (MetadataStorageT m)
Monad,
      MonadError QErr,
      MonadReader r,
      MonadState s,
      m a -> MetadataStorageT m a
(forall (m :: * -> *) a. Monad m => m a -> MetadataStorageT m a)
-> MonadTrans MetadataStorageT
forall (m :: * -> *) a. Monad m => m a -> MetadataStorageT m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> MetadataStorageT m a
$clift :: forall (m :: * -> *) a. Monad m => m a -> MetadataStorageT m a
MonadTrans,
      Monad (MetadataStorageT m)
Monad (MetadataStorageT m)
-> (forall a. (a -> MetadataStorageT m a) -> MetadataStorageT m a)
-> MonadFix (MetadataStorageT m)
(a -> MetadataStorageT m a) -> MetadataStorageT m a
forall a. (a -> MetadataStorageT m a) -> MetadataStorageT m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
forall (m :: * -> *). MonadFix m => Monad (MetadataStorageT m)
forall (m :: * -> *) a.
MonadFix m =>
(a -> MetadataStorageT m a) -> MetadataStorageT m a
mfix :: (a -> MetadataStorageT m a) -> MetadataStorageT m a
$cmfix :: forall (m :: * -> *) a.
MonadFix m =>
(a -> MetadataStorageT m a) -> MetadataStorageT m a
$cp1MonadFix :: forall (m :: * -> *). MonadFix m => Monad (MetadataStorageT m)
MonadFix,
      Monad (MetadataStorageT m)
Monad (MetadataStorageT m)
-> (forall a. IO a -> MetadataStorageT m a)
-> MonadIO (MetadataStorageT m)
IO a -> MetadataStorageT m a
forall a. IO a -> MetadataStorageT m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
forall (m :: * -> *). MonadIO m => Monad (MetadataStorageT m)
forall (m :: * -> *) a. MonadIO m => IO a -> MetadataStorageT m a
liftIO :: IO a -> MetadataStorageT m a
$cliftIO :: forall (m :: * -> *) a. MonadIO m => IO a -> MetadataStorageT m a
$cp1MonadIO :: forall (m :: * -> *). MonadIO m => Monad (MetadataStorageT m)
MonadIO,
      (forall a. m a -> n a)
-> MetadataStorageT m b -> MetadataStorageT n b
(forall (m :: * -> *) (n :: * -> *) b.
 Monad m =>
 (forall a. m a -> n a)
 -> MetadataStorageT m b -> MetadataStorageT n b)
-> MFunctor MetadataStorageT
forall k (t :: (* -> *) -> k -> *).
(forall (m :: * -> *) (n :: * -> *) (b :: k).
 Monad m =>
 (forall a. m a -> n a) -> t m b -> t n b)
-> MFunctor t
forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a)
-> MetadataStorageT m b -> MetadataStorageT n b
hoist :: (forall a. m a -> n a)
-> MetadataStorageT m b -> MetadataStorageT n b
$choist :: forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a)
-> MetadataStorageT m b -> MetadataStorageT n b
MFunctor,
      Monad (MetadataStorageT m)
MetadataStorageT m Reporter
Monad (MetadataStorageT m)
-> MetadataStorageT m Reporter -> HasReporter (MetadataStorageT m)
forall (m :: * -> *). Monad m -> m Reporter -> HasReporter m
forall (m :: * -> *). HasReporter m => Monad (MetadataStorageT m)
forall (m :: * -> *). HasReporter m => MetadataStorageT m Reporter
askReporter :: MetadataStorageT m Reporter
$caskReporter :: forall (m :: * -> *). HasReporter m => MetadataStorageT m Reporter
$cp1HasReporter :: forall (m :: * -> *). HasReporter m => Monad (MetadataStorageT m)
Tracing.HasReporter,
      Monad (MetadataStorageT m)
MetadataStorageT m TraceContext
MetadataStorageT m Reporter
Monad (MetadataStorageT m)
-> (forall a. Text -> MetadataStorageT m a -> MetadataStorageT m a)
-> MetadataStorageT m TraceContext
-> MetadataStorageT m Reporter
-> (TracingMetadata -> MetadataStorageT m ())
-> MonadTrace (MetadataStorageT m)
TracingMetadata -> MetadataStorageT m ()
Text -> MetadataStorageT m a -> MetadataStorageT m a
forall a. Text -> MetadataStorageT m a -> MetadataStorageT m a
forall (m :: * -> *).
Monad m
-> (forall a. Text -> m a -> m a)
-> m TraceContext
-> m Reporter
-> (TracingMetadata -> m ())
-> MonadTrace m
forall (m :: * -> *). MonadTrace m => Monad (MetadataStorageT m)
forall (m :: * -> *).
MonadTrace m =>
MetadataStorageT m TraceContext
forall (m :: * -> *). MonadTrace m => MetadataStorageT m Reporter
forall (m :: * -> *).
MonadTrace m =>
TracingMetadata -> MetadataStorageT m ()
forall (m :: * -> *) a.
MonadTrace m =>
Text -> MetadataStorageT m a -> MetadataStorageT m a
attachMetadata :: TracingMetadata -> MetadataStorageT m ()
$cattachMetadata :: forall (m :: * -> *).
MonadTrace m =>
TracingMetadata -> MetadataStorageT m ()
currentReporter :: MetadataStorageT m Reporter
$ccurrentReporter :: forall (m :: * -> *). MonadTrace m => MetadataStorageT m Reporter
currentContext :: MetadataStorageT m TraceContext
$ccurrentContext :: forall (m :: * -> *).
MonadTrace m =>
MetadataStorageT m TraceContext
trace :: Text -> MetadataStorageT m a -> MetadataStorageT m a
$ctrace :: forall (m :: * -> *) a.
MonadTrace m =>
Text -> MetadataStorageT m a -> MetadataStorageT m a
$cp1MonadTrace :: forall (m :: * -> *). MonadTrace m => Monad (MetadataStorageT m)
Tracing.MonadTrace,
      Monad (MetadataStorageT m)
MetadataStorageT m (SourceResolver ('Postgres 'Vanilla))
MetadataStorageT m (SourceResolver 'MSSQL)
Monad (MetadataStorageT m)
-> MetadataStorageT m (SourceResolver ('Postgres 'Vanilla))
-> MetadataStorageT m (SourceResolver 'MSSQL)
-> MonadResolveSource (MetadataStorageT m)
forall (m :: * -> *).
Monad m
-> m (SourceResolver ('Postgres 'Vanilla))
-> m (SourceResolver 'MSSQL)
-> MonadResolveSource m
forall (m :: * -> *).
MonadResolveSource m =>
Monad (MetadataStorageT m)
forall (m :: * -> *).
MonadResolveSource m =>
MetadataStorageT m (SourceResolver ('Postgres 'Vanilla))
forall (m :: * -> *).
MonadResolveSource m =>
MetadataStorageT m (SourceResolver 'MSSQL)
getMSSQLSourceResolver :: MetadataStorageT m (SourceResolver 'MSSQL)
$cgetMSSQLSourceResolver :: forall (m :: * -> *).
MonadResolveSource m =>
MetadataStorageT m (SourceResolver 'MSSQL)
getPGSourceResolver :: MetadataStorageT m (SourceResolver ('Postgres 'Vanilla))
$cgetPGSourceResolver :: forall (m :: * -> *).
MonadResolveSource m =>
MetadataStorageT m (SourceResolver ('Postgres 'Vanilla))
$cp1MonadResolveSource :: forall (m :: * -> *).
MonadResolveSource m =>
Monad (MetadataStorageT m)
MonadResolveSource,
      Monad (MetadataStorageT m)
MetadataStorageT m Manager
Monad (MetadataStorageT m)
-> MetadataStorageT m Manager
-> HasHttpManagerM (MetadataStorageT m)
forall (m :: * -> *). Monad m -> m Manager -> HasHttpManagerM m
forall (m :: * -> *).
HasHttpManagerM m =>
Monad (MetadataStorageT m)
forall (m :: * -> *).
HasHttpManagerM m =>
MetadataStorageT m Manager
askHttpManager :: MetadataStorageT m Manager
$caskHttpManager :: forall (m :: * -> *).
HasHttpManagerM m =>
MetadataStorageT m Manager
$cp1HasHttpManagerM :: forall (m :: * -> *).
HasHttpManagerM m =>
Monad (MetadataStorageT m)
HasHttpManagerM,
      Monad (MetadataStorageT m)
MetadataStorageT m ServerConfigCtx
Monad (MetadataStorageT m)
-> MetadataStorageT m ServerConfigCtx
-> HasServerConfigCtx (MetadataStorageT m)
forall (m :: * -> *).
Monad m -> m ServerConfigCtx -> HasServerConfigCtx m
forall (m :: * -> *).
HasServerConfigCtx m =>
Monad (MetadataStorageT m)
forall (m :: * -> *).
HasServerConfigCtx m =>
MetadataStorageT m ServerConfigCtx
askServerConfigCtx :: MetadataStorageT m ServerConfigCtx
$caskServerConfigCtx :: forall (m :: * -> *).
HasServerConfigCtx m =>
MetadataStorageT m ServerConfigCtx
$cp1HasServerConfigCtx :: forall (m :: * -> *).
HasServerConfigCtx m =>
Monad (MetadataStorageT m)
HasServerConfigCtx,
      MonadBase b,
      MonadBaseControl b
    )

runMetadataStorageT ::
  MetadataStorageT m a -> m (Either QErr a)
runMetadataStorageT :: MetadataStorageT m a -> m (Either QErr a)
runMetadataStorageT =
  ExceptT QErr m a -> m (Either QErr a)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT QErr m a -> m (Either QErr a))
-> (MetadataStorageT m a -> ExceptT QErr m a)
-> MetadataStorageT m a
-> m (Either QErr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataStorageT m a -> ExceptT QErr m a
forall (m :: * -> *) a. MetadataStorageT m a -> ExceptT QErr m a
unMetadataStorageT

instance
  {-# OVERLAPPABLE #-}
  (Monad m, Monad (t m), MonadTrans t, MonadMetadataStorage (MetadataStorageT m)) =>
  MonadMetadataStorage (MetadataStorageT (t m))
  where
  fetchMetadataResourceVersion :: MetadataStorageT (t m) MetadataResourceVersion
fetchMetadataResourceVersion = (forall a. m a -> t m a)
-> MetadataStorageT m MetadataResourceVersion
-> MetadataStorageT (t m) MetadataResourceVersion
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift MetadataStorageT m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
m MetadataResourceVersion
fetchMetadataResourceVersion
  fetchMetadata :: MetadataStorageT (t m) (Metadata, MetadataResourceVersion)
fetchMetadata = (forall a. m a -> t m a)
-> MetadataStorageT m (Metadata, MetadataResourceVersion)
-> MetadataStorageT (t m) (Metadata, MetadataResourceVersion)
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift MetadataStorageT m (Metadata, MetadataResourceVersion)
forall (m :: * -> *).
MonadMetadataStorage m =>
m (Metadata, MetadataResourceVersion)
fetchMetadata
  fetchMetadataNotifications :: MetadataResourceVersion
-> InstanceId
-> MetadataStorageT
     (t m) [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b = (forall a. m a -> t m a)
-> MetadataStorageT
     m [(MetadataResourceVersion, CacheInvalidations)]
-> MetadataStorageT
     (t m) [(MetadataResourceVersion, CacheInvalidations)]
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m [(MetadataResourceVersion, CacheInvalidations)]
 -> MetadataStorageT
      (t m) [(MetadataResourceVersion, CacheInvalidations)])
-> MetadataStorageT
     m [(MetadataResourceVersion, CacheInvalidations)]
-> MetadataStorageT
     (t m) [(MetadataResourceVersion, CacheInvalidations)]
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId
-> MetadataStorageT
     m [(MetadataResourceVersion, CacheInvalidations)]
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion
-> InstanceId -> m [(MetadataResourceVersion, CacheInvalidations)]
fetchMetadataNotifications MetadataResourceVersion
a InstanceId
b
  setMetadata :: MetadataResourceVersion
-> Metadata -> MetadataStorageT (t m) MetadataResourceVersion
setMetadata MetadataResourceVersion
r = (forall a. m a -> t m a)
-> MetadataStorageT m MetadataResourceVersion
-> MetadataStorageT (t m) MetadataResourceVersion
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m MetadataResourceVersion
 -> MetadataStorageT (t m) MetadataResourceVersion)
-> (Metadata -> MetadataStorageT m MetadataResourceVersion)
-> Metadata
-> MetadataStorageT (t m) MetadataResourceVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MetadataResourceVersion
-> Metadata -> MetadataStorageT m MetadataResourceVersion
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> Metadata -> m MetadataResourceVersion
setMetadata MetadataResourceVersion
r
  notifySchemaCacheSync :: MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> MetadataStorageT (t m) ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall a b. (a -> b) -> a -> b
$ MetadataResourceVersion
-> InstanceId -> CacheInvalidations -> MetadataStorageT m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
MetadataResourceVersion -> InstanceId -> CacheInvalidations -> m ()
notifySchemaCacheSync MetadataResourceVersion
a InstanceId
b CacheInvalidations
c
  getCatalogState :: MetadataStorageT (t m) CatalogState
getCatalogState = (forall a. m a -> t m a)
-> MetadataStorageT m CatalogState
-> MetadataStorageT (t m) CatalogState
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift MetadataStorageT m CatalogState
forall (m :: * -> *). MonadMetadataStorage m => m CatalogState
getCatalogState
  setCatalogState :: CatalogStateType -> Value -> MetadataStorageT (t m) ()
setCatalogState CatalogStateType
a Value
b = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall a b. (a -> b) -> a -> b
$ CatalogStateType -> Value -> MetadataStorageT m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m ()
setCatalogState CatalogStateType
a Value
b

  getMetadataDbUid :: MetadataStorageT (t m) MetadataDbId
getMetadataDbUid = (forall a. m a -> t m a)
-> MetadataStorageT m MetadataDbId
-> MetadataStorageT (t m) MetadataDbId
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift MetadataStorageT m MetadataDbId
forall (m :: * -> *). MonadMetadataStorage m => m MetadataDbId
getMetadataDbUid
  checkMetadataStorageHealth :: MetadataStorageT (t m) ()
checkMetadataStorageHealth = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift MetadataStorageT m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
checkMetadataStorageHealth

  getDeprivedCronTriggerStats :: [TriggerName] -> MetadataStorageT (t m) [CronTriggerStats]
getDeprivedCronTriggerStats = (forall a. m a -> t m a)
-> MetadataStorageT m [CronTriggerStats]
-> MetadataStorageT (t m) [CronTriggerStats]
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m [CronTriggerStats]
 -> MetadataStorageT (t m) [CronTriggerStats])
-> ([TriggerName] -> MetadataStorageT m [CronTriggerStats])
-> [TriggerName]
-> MetadataStorageT (t m) [CronTriggerStats]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TriggerName] -> MetadataStorageT m [CronTriggerStats]
forall (m :: * -> *).
MonadMetadataStorage m =>
[TriggerName] -> m [CronTriggerStats]
getDeprivedCronTriggerStats
  getScheduledEventsForDelivery :: MetadataStorageT (t m) ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery = (forall a. m a -> t m a)
-> MetadataStorageT m ([CronEvent], [OneOffScheduledEvent])
-> MetadataStorageT (t m) ([CronEvent], [OneOffScheduledEvent])
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift MetadataStorageT m ([CronEvent], [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
m ([CronEvent], [OneOffScheduledEvent])
getScheduledEventsForDelivery
  insertCronEvents :: [CronEventSeed] -> MetadataStorageT (t m) ()
insertCronEvents = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> ([CronEventSeed] -> MetadataStorageT m ())
-> [CronEventSeed]
-> MetadataStorageT (t m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [CronEventSeed] -> MetadataStorageT m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m ()
insertCronEvents
  insertOneOffScheduledEvent :: OneOffEvent -> MetadataStorageT (t m) EventId
insertOneOffScheduledEvent = (forall a. m a -> t m a)
-> MetadataStorageT m EventId -> MetadataStorageT (t m) EventId
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m EventId -> MetadataStorageT (t m) EventId)
-> (OneOffEvent -> MetadataStorageT m EventId)
-> OneOffEvent
-> MetadataStorageT (t m) EventId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OneOffEvent -> MetadataStorageT m EventId
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m EventId
insertOneOffScheduledEvent
  insertScheduledEventInvocation :: Invocation 'ScheduledType
-> ScheduledEventType -> MetadataStorageT (t m) ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall a b. (a -> b) -> a -> b
$ Invocation 'ScheduledType
-> ScheduledEventType -> MetadataStorageT m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
Invocation 'ScheduledType -> ScheduledEventType -> m ()
insertScheduledEventInvocation Invocation 'ScheduledType
a ScheduledEventType
b
  setScheduledEventOp :: EventId
-> ScheduledEventOp
-> ScheduledEventType
-> MetadataStorageT (t m) ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall a b. (a -> b) -> a -> b
$ EventId
-> ScheduledEventOp -> ScheduledEventType -> MetadataStorageT m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventOp -> ScheduledEventType -> m ()
setScheduledEventOp EventId
a ScheduledEventOp
b ScheduledEventType
c
  unlockScheduledEvents :: ScheduledEventType -> [EventId] -> MetadataStorageT (t m) Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b = (forall a. m a -> t m a)
-> MetadataStorageT m Int -> MetadataStorageT (t m) Int
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m Int -> MetadataStorageT (t m) Int)
-> MetadataStorageT m Int -> MetadataStorageT (t m) Int
forall a b. (a -> b) -> a -> b
$ ScheduledEventType -> [EventId] -> MetadataStorageT m Int
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventType -> [EventId] -> m Int
unlockScheduledEvents ScheduledEventType
a [EventId]
b
  unlockAllLockedScheduledEvents :: MetadataStorageT (t m) ()
unlockAllLockedScheduledEvents = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall a b. (a -> b) -> a -> b
$ MetadataStorageT m ()
forall (m :: * -> *). MonadMetadataStorage m => m ()
unlockAllLockedScheduledEvents
  clearFutureCronEvents :: ClearCronEvents -> MetadataStorageT (t m) ()
clearFutureCronEvents = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> (ClearCronEvents -> MetadataStorageT m ())
-> ClearCronEvents
-> MetadataStorageT (t m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ClearCronEvents -> MetadataStorageT m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m ()
clearFutureCronEvents
  getOneOffScheduledEvents :: ScheduledEventPagination
-> [ScheduledEventStatus]
-> MetadataStorageT (t m) (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b = (forall a. m a -> t m a)
-> MetadataStorageT m (WithTotalCount [OneOffScheduledEvent])
-> MetadataStorageT (t m) (WithTotalCount [OneOffScheduledEvent])
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m (WithTotalCount [OneOffScheduledEvent])
 -> MetadataStorageT (t m) (WithTotalCount [OneOffScheduledEvent]))
-> MetadataStorageT m (WithTotalCount [OneOffScheduledEvent])
-> MetadataStorageT (t m) (WithTotalCount [OneOffScheduledEvent])
forall a b. (a -> b) -> a -> b
$ ScheduledEventPagination
-> [ScheduledEventStatus]
-> MetadataStorageT m (WithTotalCount [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
a [ScheduledEventStatus]
b
  getCronEvents :: TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> MetadataStorageT (t m) (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c = (forall a. m a -> t m a)
-> MetadataStorageT m (WithTotalCount [CronEvent])
-> MetadataStorageT (t m) (WithTotalCount [CronEvent])
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m (WithTotalCount [CronEvent])
 -> MetadataStorageT (t m) (WithTotalCount [CronEvent]))
-> MetadataStorageT m (WithTotalCount [CronEvent])
-> MetadataStorageT (t m) (WithTotalCount [CronEvent])
forall a b. (a -> b) -> a -> b
$ TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> MetadataStorageT m (WithTotalCount [CronEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
getCronEvents TriggerName
a ScheduledEventPagination
b [ScheduledEventStatus]
c
  getInvocations :: GetInvocationsBy
-> ScheduledEventPagination
-> MetadataStorageT
     (t m) (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b = (forall a. m a -> t m a)
-> MetadataStorageT m (WithTotalCount [ScheduledEventInvocation])
-> MetadataStorageT
     (t m) (WithTotalCount [ScheduledEventInvocation])
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m (WithTotalCount [ScheduledEventInvocation])
 -> MetadataStorageT
      (t m) (WithTotalCount [ScheduledEventInvocation]))
-> MetadataStorageT m (WithTotalCount [ScheduledEventInvocation])
-> MetadataStorageT
     (t m) (WithTotalCount [ScheduledEventInvocation])
forall a b. (a -> b) -> a -> b
$ GetInvocationsBy
-> ScheduledEventPagination
-> MetadataStorageT m (WithTotalCount [ScheduledEventInvocation])
forall (m :: * -> *).
MonadMetadataStorage m =>
GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
getInvocations GetInvocationsBy
a ScheduledEventPagination
b
  deleteScheduledEvent :: EventId -> ScheduledEventType -> MetadataStorageT (t m) ()
deleteScheduledEvent EventId
a ScheduledEventType
b = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall a b. (a -> b) -> a -> b
$ EventId -> ScheduledEventType -> MetadataStorageT m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m ()
deleteScheduledEvent EventId
a ScheduledEventType
b

  insertAction :: ActionName
-> SessionVariables
-> [Header]
-> Value
-> MetadataStorageT (t m) ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d = (forall a. m a -> t m a)
-> MetadataStorageT m ActionId -> MetadataStorageT (t m) ActionId
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m ActionId -> MetadataStorageT (t m) ActionId)
-> MetadataStorageT m ActionId -> MetadataStorageT (t m) ActionId
forall a b. (a -> b) -> a -> b
$ ActionName
-> SessionVariables
-> [Header]
-> Value
-> MetadataStorageT m ActionId
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionName -> SessionVariables -> [Header] -> Value -> m ActionId
insertAction ActionName
a SessionVariables
b [Header]
c Value
d
  fetchUndeliveredActionEvents :: MetadataStorageT (t m) [ActionLogItem]
fetchUndeliveredActionEvents = (forall a. m a -> t m a)
-> MetadataStorageT m [ActionLogItem]
-> MetadataStorageT (t m) [ActionLogItem]
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift MetadataStorageT m [ActionLogItem]
forall (m :: * -> *). MonadMetadataStorage m => m [ActionLogItem]
fetchUndeliveredActionEvents
  setActionStatus :: ActionId -> AsyncActionStatus -> MetadataStorageT (t m) ()
setActionStatus ActionId
a AsyncActionStatus
b = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall a b. (a -> b) -> a -> b
$ ActionId -> AsyncActionStatus -> MetadataStorageT m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> AsyncActionStatus -> m ()
setActionStatus ActionId
a AsyncActionStatus
b
  fetchActionResponse :: ActionId -> MetadataStorageT (t m) ActionLogResponse
fetchActionResponse = (forall a. m a -> t m a)
-> MetadataStorageT m ActionLogResponse
-> MetadataStorageT (t m) ActionLogResponse
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m ActionLogResponse
 -> MetadataStorageT (t m) ActionLogResponse)
-> (ActionId -> MetadataStorageT m ActionLogResponse)
-> ActionId
-> MetadataStorageT (t m) ActionLogResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionId -> MetadataStorageT m ActionLogResponse
forall (m :: * -> *).
MonadMetadataStorage m =>
ActionId -> m ActionLogResponse
fetchActionResponse
  clearActionData :: ActionName -> MetadataStorageT (t m) ()
clearActionData = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> (ActionName -> MetadataStorageT m ())
-> ActionName
-> MetadataStorageT (t m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ActionName -> MetadataStorageT m ()
forall (m :: * -> *). MonadMetadataStorage m => ActionName -> m ()
clearActionData
  setProcessingActionLogsToPending :: LockedActionIdArray -> MetadataStorageT (t m) ()
setProcessingActionLogsToPending = (forall a. m a -> t m a)
-> MetadataStorageT m () -> MetadataStorageT (t m) ()
forall k (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
       (b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
hoist forall a. m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (MetadataStorageT m () -> MetadataStorageT (t m) ())
-> (LockedActionIdArray -> MetadataStorageT m ())
-> LockedActionIdArray
-> MetadataStorageT (t m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LockedActionIdArray -> MetadataStorageT m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
LockedActionIdArray -> m ()
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 EventId
  createOneOffScheduledEvent = OneOffEvent -> m EventId
forall (m :: * -> *).
MonadMetadataStorage m =>
OneOffEvent -> m EventId
insertOneOffScheduledEvent

  -- | Record a cron event
  createCronEvents :: [CronEventSeed] -> m ()
  createCronEvents = [CronEventSeed] -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
[CronEventSeed] -> m ()
insertCronEvents

  -- | Clear cron events
  dropFutureCronEvents :: ClearCronEvents -> m ()
  dropFutureCronEvents = ClearCronEvents -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
ClearCronEvents -> m ()
clearFutureCronEvents

  -- | Delete async action logs
  deleteActionData :: ActionName -> m ()
  deleteActionData = ActionName -> m ()
forall (m :: * -> *). MonadMetadataStorage m => ActionName -> m ()
clearActionData

  -- | Fetch cron/oneoff scheduled event invocations
  fetchInvocations ::
    GetInvocationsBy ->
    ScheduledEventPagination ->
    m (WithTotalCount [ScheduledEventInvocation])
  fetchInvocations = GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
forall (m :: * -> *).
MonadMetadataStorage m =>
GetInvocationsBy
-> ScheduledEventPagination
-> m (WithTotalCount [ScheduledEventInvocation])
getInvocations

  -- | Fetch cron/oneoff scheduled events
  fetchScheduledEvents :: GetScheduledEvents -> m Value
  fetchScheduledEvents GetScheduledEvents {[ScheduledEventStatus]
ScheduledEvent
ScheduledEventPagination
_gseStatus :: GetScheduledEvents -> [ScheduledEventStatus]
_gsePagination :: GetScheduledEvents -> ScheduledEventPagination
_gseScheduledEvent :: GetScheduledEvents -> ScheduledEvent
_gseStatus :: [ScheduledEventStatus]
_gsePagination :: ScheduledEventPagination
_gseScheduledEvent :: ScheduledEvent
..} = do
    let totalCountToJSON :: WithTotalCount v -> Value
totalCountToJSON WithTotalCount {v
Int
_wtcData :: forall a. WithTotalCount a -> a
_wtcCount :: forall a. WithTotalCount a -> Int
_wtcData :: v
_wtcCount :: Int
..} =
          [Pair] -> Value
object [Key
"count" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
_wtcCount, Key
"events" Key -> v -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= v
_wtcData]
    case ScheduledEvent
_gseScheduledEvent of
      ScheduledEvent
SEOneOff -> WithTotalCount [OneOffScheduledEvent] -> Value
forall v. ToJSON v => WithTotalCount v -> Value
totalCountToJSON (WithTotalCount [OneOffScheduledEvent] -> Value)
-> m (WithTotalCount [OneOffScheduledEvent]) -> m Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [OneOffScheduledEvent])
getOneOffScheduledEvents ScheduledEventPagination
_gsePagination [ScheduledEventStatus]
_gseStatus
      SECron TriggerName
name -> WithTotalCount [CronEvent] -> Value
forall v. ToJSON v => WithTotalCount v -> Value
totalCountToJSON (WithTotalCount [CronEvent] -> Value)
-> m (WithTotalCount [CronEvent]) -> m Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
forall (m :: * -> *).
MonadMetadataStorage m =>
TriggerName
-> ScheduledEventPagination
-> [ScheduledEventStatus]
-> m (WithTotalCount [CronEvent])
getCronEvents TriggerName
name ScheduledEventPagination
_gsePagination [ScheduledEventStatus]
_gseStatus

  -- | Drop a cron/oneoff scheduled event
  dropEvent :: ScheduledEventId -> ScheduledEventType -> m ()
  dropEvent = EventId -> ScheduledEventType -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
EventId -> ScheduledEventType -> m ()
deleteScheduledEvent

  -- | Retrieve the state from metadata storage catalog
  fetchCatalogState :: m CatalogState
  fetchCatalogState = m CatalogState
forall (m :: * -> *). MonadMetadataStorage m => m CatalogState
getCatalogState

  -- | Update the state from metadata storage catalog
  updateCatalogState :: CatalogStateType -> Value -> m ()
  updateCatalogState = CatalogStateType -> Value -> m ()
forall (m :: * -> *).
MonadMetadataStorage m =>
CatalogStateType -> Value -> m ()
setCatalogState

instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (ReaderT r m)

instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (StateT s m)

instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (Tracing.TraceT m)

instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (MetadataT m)

instance (MonadMetadataStorageQueryAPI m) => MonadMetadataStorageQueryAPI (Q.TxET QErr m)