Copyright | (c) CNRS 2017 |
---|---|
License | AGPL + CECILL v3 |
Maintainer | team@gargantext.org |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- serveJobsAPI :: (Foldable callbacks, Ord (JobType m), Show (JobType m), ToJSON (JobEventType m), ToJSON (JobOutputType m), MonadJobStatus m, m ~ GargM Env BackendInternalError, JobEventType m ~ JobOutputType m, MonadLogger m) => JobType m -> (JobHandle m -> input -> m ()) -> AsyncJobsServerT' ctI ctO callbacks (JobEventType m) input (JobOutputType m) m
- readPrios :: Logger IO -> FilePath -> IO [(GargJob, Int)]
- class MonadJobStatus m where
- type JobHandle m :: Type
- type JobType m :: Type
- type JobOutputType m :: Type
- type JobEventType m :: Type
- noJobHandle :: Proxy m -> JobHandle m
- getLatestJobStatus :: JobHandle m -> m (JobEventType m)
- withTracer :: Logger (JobEventType m) -> JobHandle m -> (JobHandle m -> m a) -> m a
- markStarted :: Int -> JobHandle m -> m ()
- markProgress :: Int -> JobHandle m -> m ()
- markFailure :: forall e. ToHumanFriendlyError e => Int -> Maybe e -> JobHandle m -> m ()
- markComplete :: JobHandle m -> m ()
- markFailed :: forall e. ToHumanFriendlyError e => Maybe e -> JobHandle m -> m ()
- addMoreSteps :: MonadJobStatus m => Int -> JobHandle m -> m ()
- markFailureNoErr :: MonadJobStatus m => Int -> JobHandle m -> m ()
- markFailedNoErr :: MonadJobStatus m => JobHandle m -> m ()
Serving the JOBS API
serveJobsAPI :: (Foldable callbacks, Ord (JobType m), Show (JobType m), ToJSON (JobEventType m), ToJSON (JobOutputType m), MonadJobStatus m, m ~ GargM Env BackendInternalError, JobEventType m ~ JobOutputType m, MonadLogger m) => JobType m -> (JobHandle m -> input -> m ()) -> AsyncJobsServerT' ctI ctO callbacks (JobEventType m) input (JobOutputType m) m #
Parsing and reading GargJob
s from disk
Handy re-exports
class MonadJobStatus m where #
A monad to query for the status of a particular job and submit updates for in-progress jobs.
This is type family for the concrete JobHandle
that is associated to
a job when it starts and it can be used to query for its completion status. Different environment
can decide how this will look like.
type JobOutputType m :: Type #
type JobEventType m :: Type #
noJobHandle :: Proxy m -> JobHandle m #
A job handle that doesn't do anything. Sometimes useful in all those circumstances
where we need to test a function taking a JobHandle
as input but we are not interested
in the progress tracking.
getLatestJobStatus :: JobHandle m -> m (JobEventType m) #
Retrevies the latest JobEventType
from the underlying monad. It can be
used to query the latest status for a particular job, given its JobHandle
as input.
withTracer :: Logger (JobEventType m) -> JobHandle m -> (JobHandle m -> m a) -> m a #
Adds an extra "tracer" that logs events to the passed action. Produces
a new JobHandle
.
markStarted :: Int -> JobHandle m -> m () #
Start tracking a new JobEventType
with n
remaining steps.
markProgress :: Int -> JobHandle m -> m () #
Mark n
steps of the job as succeeded, while simultaneously substracting this number
from the remaining steps.
markFailure :: forall e. ToHumanFriendlyError e => Int -> Maybe e -> JobHandle m -> m () #
Mark n
step of the job as failed, while simultaneously substracting this number
from the remaining steps. Attach an optional error message to the failure.
markComplete :: JobHandle m -> m () #
Finish tracking a job by marking all the remaining steps as succeeded.
markFailed :: forall e. ToHumanFriendlyError e => Maybe e -> JobHandle m -> m () #
Finish tracking a job by marking all the remaining steps as failed. Attach an optional message to the failure.
addMoreSteps :: MonadJobStatus m => Int -> JobHandle m -> m () #
Add n
more steps to the running computation, they will be marked as remaining.
Instances
markFailureNoErr :: MonadJobStatus m => Int -> JobHandle m -> m () #
markFailedNoErr :: MonadJobStatus m => JobHandle m -> m () #
Helper on top of markFailed
for when we don't have a diagnostic to log.