graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Trans.Managed

Synopsis

Documentation

newtype ManagedT m a Source #

This type is like a transformer version of the Managed monad from the managed library. It can be used to manage resources by pairing together their allocation with their finalizers.

The documentation for the managed library is an excellent introduction to the idea here.

We could use Codensity directly, but we'd have to define an orphan instance for MonadFix. This also gives us the opportunity to give it a slightly more friendly name.

We could also have used ResourceT, but that would have involved writing instances for MonadUnliftIO. That could still be a good option to consider later, however.

Constructors

ManagedT 

Fields

Instances

Instances details
MonadTrans ManagedT Source # 
Instance details

Defined in Control.Monad.Trans.Managed

Methods

lift :: Monad m => m a -> ManagedT m a #

MonadReader r m => MonadReader r (ManagedT m) Source # 
Instance details

Defined in Control.Monad.Trans.Managed

Methods

ask :: ManagedT m r #

local :: (r -> r) -> ManagedT m a -> ManagedT m a #

reader :: (r -> a) -> ManagedT m a #

MonadReader s m => MonadState s (ManagedT m) Source # 
Instance details

Defined in Control.Monad.Trans.Managed

Methods

get :: ManagedT m s #

put :: s -> ManagedT m () #

state :: (s -> (a, s)) -> ManagedT m a #

MonadIO m => MonadFix (ManagedT m) Source #

We need this instance to tie the knot when initializing resources. It'd be nice if we could do this with a MonadFix constraint on the underlying monad, but here we just use MonadIO to tie the knot using a lazily-evaluated MVar-based promise for the eventual result.

We need to be careful not to leak allocated resources via the use of recursively-defined monadic actions when making use of this instance.

Instance details

Defined in Control.Monad.Trans.Managed

Methods

mfix :: (a -> ManagedT m a) -> ManagedT m a #

MonadIO m => MonadIO (ManagedT m) Source # 
Instance details

Defined in Control.Monad.Trans.Managed

Methods

liftIO :: IO a -> ManagedT m a #

Applicative (ManagedT m) Source # 
Instance details

Defined in Control.Monad.Trans.Managed

Methods

pure :: a -> ManagedT m a #

(<*>) :: ManagedT m (a -> b) -> ManagedT m a -> ManagedT m b #

liftA2 :: (a -> b -> c) -> ManagedT m a -> ManagedT m b -> ManagedT m c #

(*>) :: ManagedT m a -> ManagedT m b -> ManagedT m b #

(<*) :: ManagedT m a -> ManagedT m b -> ManagedT m a #

Functor (ManagedT m) Source # 
Instance details

Defined in Control.Monad.Trans.Managed

Methods

fmap :: (a -> b) -> ManagedT m a -> ManagedT m b #

(<$) :: a -> ManagedT m b -> ManagedT m a #

Monad (ManagedT m) Source # 
Instance details

Defined in Control.Monad.Trans.Managed

Methods

(>>=) :: ManagedT m a -> (a -> ManagedT m b) -> ManagedT m b #

(>>) :: ManagedT m a -> ManagedT m b -> ManagedT m b #

return :: a -> ManagedT m a #

MonadEECredentialsStorage m => MonadEECredentialsStorage (ManagedT m) Source # 
Instance details

Defined in Hasura.Metadata.Class

MonadMetadataStorage m => MonadMetadataStorage (ManagedT m) Source # 
Instance details

Defined in Hasura.Metadata.Class

Methods

fetchMetadataResourceVersion :: ManagedT m (Either QErr MetadataResourceVersion) Source #

fetchMetadata :: ManagedT m (Either QErr MetadataWithResourceVersion) Source #

fetchMetadataNotifications :: MetadataResourceVersion -> InstanceId -> ManagedT m (Either QErr [(MetadataResourceVersion, CacheInvalidations)]) Source #

setMetadata :: MetadataResourceVersion -> Metadata -> ManagedT m (Either QErr MetadataResourceVersion) Source #

notifySchemaCacheSync :: MetadataResourceVersion -> InstanceId -> CacheInvalidations -> ManagedT m (Either QErr ()) Source #

getCatalogState :: ManagedT m (Either QErr CatalogState) Source #

setCatalogState :: CatalogStateType -> Value -> ManagedT m (Either QErr ()) Source #

fetchSourceIntrospection :: MetadataResourceVersion -> ManagedT m (Either QErr (Maybe StoredIntrospection)) Source #

storeSourceIntrospection :: StoredIntrospection -> MetadataResourceVersion -> ManagedT m (Either QErr ()) Source #

getMetadataDbUid :: ManagedT m (Either QErr MetadataDbId) Source #

checkMetadataStorageHealth :: ManagedT m (Either QErr ()) Source #

getDeprivedCronTriggerStats :: [TriggerName] -> ManagedT m (Either QErr [CronTriggerStats]) Source #

getScheduledEventsForDelivery :: [TriggerName] -> ManagedT m (Either QErr ([CronEvent], [OneOffScheduledEvent])) Source #

insertCronEvents :: [CronEventSeed] -> ManagedT m (Either QErr ()) Source #

insertOneOffScheduledEvent :: OneOffEvent -> ManagedT m (Either QErr EventId) Source #

insertScheduledEventInvocation :: Invocation 'ScheduledType -> ScheduledEventType -> ManagedT m (Either QErr ()) Source #

setScheduledEventOp :: ScheduledEventId -> ScheduledEventOp -> ScheduledEventType -> ManagedT m (Either QErr ()) Source #

unlockScheduledEvents :: ScheduledEventType -> [ScheduledEventId] -> ManagedT m (Either QErr Int) Source #

unlockAllLockedScheduledEvents :: ManagedT m (Either QErr ()) Source #

clearFutureCronEvents :: ClearCronEvents -> ManagedT m (Either QErr ()) Source #

getOneOffScheduledEvents :: ScheduledEventPagination -> [ScheduledEventStatus] -> RowsCountOption -> ManagedT m (Either QErr (WithOptionalTotalCount [OneOffScheduledEvent])) Source #

getCronEvents :: TriggerName -> ScheduledEventPagination -> [ScheduledEventStatus] -> RowsCountOption -> ManagedT m (Either QErr (WithOptionalTotalCount [CronEvent])) Source #

getScheduledEventInvocations :: GetScheduledEventInvocations -> ManagedT m (Either QErr (WithOptionalTotalCount [ScheduledEventInvocation])) Source #

deleteScheduledEvent :: ScheduledEventId -> ScheduledEventType -> ManagedT m (Either QErr ()) Source #

insertAction :: ActionName -> SessionVariables -> [Header] -> Value -> ManagedT m (Either QErr ActionId) Source #

fetchUndeliveredActionEvents :: ManagedT m (Either QErr [ActionLogItem]) Source #

setActionStatus :: ActionId -> AsyncActionStatus -> ManagedT m (Either QErr ()) Source #

fetchActionResponse :: ActionId -> ManagedT m (Either QErr ActionLogResponse) Source #

clearActionData :: ActionName -> ManagedT m (Either QErr ()) Source #

setProcessingActionLogsToPending :: LockedActionIdArray -> ManagedT m (Either QErr ()) Source #

allocate :: MonadBaseControl IO m => m a -> (a -> m b) -> ManagedT m a Source #

Allocate a resource by providing setup and finalizer actions.

allocate_ :: MonadBaseControl IO m => m a -> m b -> ManagedT m () Source #

Allocate a resource but do not return a reference to it.

lowerManagedT :: Monad m => ManagedT m a -> m a Source #

Run the provided computation by returning its result, and run any finalizers. Watch out: this function might leak finalized resources.