File tree Expand file tree Collapse file tree 2 files changed +49
-3
lines changed Expand file tree Collapse file tree 2 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -1482,6 +1482,31 @@ needsClient = do
14821482 2
14831483 lift $ C. waitWorkflowResult wfH `shouldReturn` 25
14841484
1485+ it " works with workflow that starts an activity before installing the signal handler" $ \ TestEnv {.. } -> do
1486+ let conf = provideCallStack $ configure () (discoverDefinitions @ () $$ (discoverInstances) $$ (discoverInstances)) baseConf
1487+ withWorker conf $ do
1488+ let opts =
1489+ (C. startWorkflowOptions taskQueue)
1490+ { C. workflowIdReusePolicy = Just W. WorkflowIdReusePolicyAllowDuplicate
1491+ , C. timeouts =
1492+ C. TimeoutOptions
1493+ { C. runTimeout = Just $ seconds 4
1494+ , C. executionTimeout = Nothing
1495+ , C. taskTimeout = Nothing
1496+ }
1497+ }
1498+ useClient $ do
1499+ liftIO $ putStrLn " signalWithStart call"
1500+ wfH <-
1501+ C. signalWithStart
1502+ SignalWithActivityWorkflow
1503+ " signalWithStartWithActivity"
1504+ opts
1505+ signalWithArgs
1506+ 0
1507+
1508+ lift $ C. waitWorkflowResult wfH `shouldReturn` 0
1509+
14851510 -- specify "works as intended and returns correct runId" pending
14861511 describe " RetryPolicy" $ do
14871512 specify " is used for retryable failures" $ \ TestEnv {.. } -> do
Original file line number Diff line number Diff line change 99
1010module IntegrationSpec.Signals where
1111
12- import Control.Exception
13- import Control.Monad
14- import Control.Monad.Logger
12+ import Control.Concurrent ( threadDelay )
13+ import Control.Monad.IO.Class ( liftIO )
14+ import Control.Monad.Logger ( logDebug )
1515import RequireCallStack (provideCallStack )
16+ import Temporal.Activity (Activity )
1617import Temporal.Duration
1718import Temporal.Payload
1819import Temporal.TH
@@ -53,3 +54,23 @@ signalWithArgsWorkflow init = provideCallStack do
5354
5455
5556registerWorkflow 'signalWithArgsWorkflow
57+
58+
59+ signalWithActivityA :: Activity () ()
60+ signalWithActivityA = liftIO $ threadDelay 1_000_000
61+
62+ registerActivity 'signalWithActivityA
63+
64+ signalWithActivityWorkflow :: Workflow Int
65+ signalWithActivityWorkflow = provideCallStack do
66+ executeActivity SignalWithActivityA (defaultStartActivityOptions $ StartToClose $ seconds 2 )
67+
68+ var <- newStateVar []
69+ setSignalHandler signalWithArgs $ \ i -> do
70+ $ (logDebug) " updating value and unblocking workflow"
71+ readStateVar var >>= \ s -> writeStateVar var (i : s)
72+
73+ waitCondition (not . null ) <$> readStateVar var
74+ head <$> readStateVar var
75+
76+ registerWorkflow 'signalWithActivityWorkflow
You can’t perform that action at this time.
0 commit comments