Skip to content

Commit

Permalink
feat(primer-api): run evaluation requests outside STM (#1244)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhess committed Apr 18, 2024
2 parents fedd890 + 0fe3254 commit 17171c7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions primer-api/src/Primer/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,16 +1188,18 @@ evalStep ::
SessionId ->
EvalReq ->
PrimerM m (Either ProgError EvalResp)
evalStep = curry $ logAPI (leftResultError EvalStep) $ \(sid, req) ->
liftQueryAppM (handleEvalRequest req) sid
evalStep = curry $ logAPI (leftResultError EvalStep) $ \(sid, req) -> do
app <- getApp sid
runQueryAppM (handleEvalRequest req) app

evalFull ::
(MonadIO m, MonadThrow m, MonadAPILog l m, ConvertLogMessage EvalLog l) =>
SessionId ->
EvalFullReq ->
PrimerM m (Either ProgError App.EvalFullResp)
evalFull = curry $ logAPI (leftResultError EvalFull) $ \(sid, req) ->
liftQueryAppM (handleEvalFullRequest req) sid
evalFull = curry $ logAPI (leftResultError EvalFull) $ \(sid, req) -> do
app <- getApp sid
runQueryAppM (handleEvalFullRequest req) app

-- | This type is the API's view of a 'App.EvalFullResp
-- (this is expected to evolve as we flesh out the API)
Expand All @@ -1219,14 +1221,15 @@ evalFull' ::
Maybe NormalOrderOptions ->
GVarName ->
PrimerM m EvalFullResp
evalFull' = curry4 $ logAPI (noError EvalFull') $ \(sid, lim, closed, d) ->
noErr <$> liftQueryAppM (q lim closed d) sid
evalFull' = curry4 $ logAPI (noError EvalFull') $ \(sid, lim, closed, d) -> do
app <- getApp sid
noErr <$> runQueryAppM (q lim closed d) app
where
q ::
Maybe TerminationBound ->
Maybe NormalOrderOptions ->
GVarName ->
QueryAppM (PureLog (WithSeverity l)) Void EvalFullResp
QueryAppM (PrimerM m) Void EvalFullResp
q lim closed d = do
-- We don't care about uniqueness of this ID, and we do not want to
-- disturb any FreshID state, since that could break undo/redo.
Expand Down

0 comments on commit 17171c7

Please sign in to comment.