Safe Haskell | None |
---|---|
Language | Haskell2010 |
RIO is equivalent to ResourceT (WriterT Warmup IO)
It can be used to instantiate "components as records of functions"
where each component can allocate resources and have a "warmup phase"
to preload data or assess if it is working properly.
Synopsis
- newtype Stop = Stop InternalState
- runStop :: Stop -> IO ()
- newtype RIO a = RIO {}
- withRIO :: RIO a -> (a -> IO ()) -> IO Result
- withRegistry :: forall a b ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> (Result -> a -> IO b) -> IO b
- runRegistryT :: forall a ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> ResourceT IO (a, Warmup)
- withNoWarmupRIO :: RIO a -> (a -> IO b) -> IO b
- executeRegistry :: forall a ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> IO (a, Warmup, Stop)
- unsafeRun :: forall a ins out. (Typeable a, Contains (RIO a) out) => Registry ins out -> IO a
- unsafeRunDynamic :: forall a ins out. Typeable a => Registry ins out -> IO a
- unsafeRunWithStop :: forall a ins out. (Typeable a, Contains (RIO a) out) => Registry ins out -> IO (a, Stop)
- unsafeRunDynamicWithStop :: forall a ins out. Typeable a => Registry ins out -> IO (a, Stop)
- warmupWith :: Warmup -> RIO ()
- allocate :: IO a -> (a -> IO ()) -> RIO a
Documentation
This newtype creates a monad to sequence component creation actions, cumulating start/stop tasks found along the way
Instances
Monad RIO Source # | |
Functor RIO Source # | |
Applicative RIO Source # | |
MonadIO RIO Source # | |
Defined in Data.Registry.RIO | |
MonadThrow RIO Source # | |
Defined in Data.Registry.RIO | |
MonadResource RIO Source # | |
Defined in Data.Registry.RIO liftResourceT :: ResourceT IO a -> RIO a # | |
MonadBase IO RIO Source # | |
Defined in Data.Registry.RIO |
For production
withRIO :: RIO a -> (a -> IO ()) -> IO Result Source #
Use a RIO value and make sure that resources are closed Only run the action if the warmup is successful
withRegistry :: forall a b ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> (Result -> a -> IO b) -> IO b Source #
This function must be used to run services involving a top component It creates the top component and invokes all warmup functions
The passed function f
is used to decide whether to continue or
not depending on the Result
runRegistryT :: forall a ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> ResourceT IO (a, Warmup) Source #
This can be used if you want to insert the component creation inside
another action managed with ResourceT
. Or if you want to call runResourceT
yourself later
For testing
withNoWarmupRIO :: RIO a -> (a -> IO b) -> IO b Source #
Use a RIO value and make sure that resources are closed Don't run the warmup
executeRegistry :: forall a ins out. (Typeable a, Contains (RIO a) out, Solvable ins out) => Registry ins out -> IO (a, Warmup, Stop) Source #
Instantiate the component but don't execute the warmup (it may take time) and keep the Stop value to clean resources later This function statically checks that the component can be instantiated
unsafeRun :: forall a ins out. (Typeable a, Contains (RIO a) out) => Registry ins out -> IO a Source #
Instantiate the component but don't execute the warmup (it may take time) and lose a way to cleanu up resources | Almost no compilation time is spent on checking that component resolution is possible
unsafeRunDynamic :: forall a ins out. Typeable a => Registry ins out -> IO a Source #
Instantiate the component but don't execute the warmup (it may take time) and lose a way to cleanu up resources Don't even check that a component can be built out of the registry
unsafeRunWithStop :: forall a ins out. (Typeable a, Contains (RIO a) out) => Registry ins out -> IO (a, Stop) Source #