serveJobsAPI
-- * Parsing and reading @GargJob@s from disk
, readPrios
+ -- * Handy re-exports
+ , MonadJobStatus(..)
) where
import Control.Monad.Except
import Control.Monad.Reader
import Data.Aeson (ToJSON)
-import Data.Monoid (Dual)
import Prelude
import System.Directory (doesFileExist)
import Text.Read (readMaybe)
import Gargantext.API.Admin.EnvTypes
import Gargantext.API.Prelude
import qualified Gargantext.Utils.Jobs.Internal as Internal
-import Gargantext.Utils.Jobs.Map
import Gargantext.Utils.Jobs.Monad
import qualified Servant.Job.Async as SJ
, Show (JobType m)
, ToJSON (JobEventType m)
, ToJSON (JobOutputType m)
- , MonadJobStatus m Dual
- , m ~ (GargM env GargError)
+ , MonadJobStatus m
+ , m ~ (GargM Env GargError)
+ , JobEventType m ~ JobOutputType m
)
=> JobType m
- -> (Internal.JobHandle -> input -> Logger (JobEventType m) -> m (JobOutputType m))
+ -> (JobHandle m -> input -> m ())
-> SJ.AsyncJobsServerT' ctI ctO callbacks (JobEventType m) input (JobOutputType m) m
-serveJobsAPI jobType f = Internal.serveJobsAPI ask jobType jobErrorToGargError $ \env jHandle i l -> do
+serveJobsAPI jobType f = Internal.serveJobsAPI mkJobHandle ask jobType jobErrorToGargError $ \env jHandle i -> do
putStrLn ("Running job of type: " ++ show jobType)
- runExceptT $ runReaderT (f jHandle i l) env
+ runExceptT $ runReaderT (f jHandle i >> getLatestJobStatus jHandle) env
parseGargJob :: String -> Maybe GargJob
parseGargJob s = case s of