forked from temporalio/samples-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplayer.py
More file actions
25 lines (18 loc) · 819 Bytes
/
replayer.py
File metadata and controls
25 lines (18 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import asyncio
from temporalio.client import Client
from temporalio.envconfig import ClientConfig
from temporalio.worker import Replayer
from replay.worker import JustActivity, JustTimer, TimerThenActivity
async def main():
# Connect client
config = ClientConfig.load_client_connect_config()
config.setdefault("target_host", "localhost:7233")
client = await Client.connect(**config)
# Fetch the histories of the workflows to be replayed
workflows = client.list_workflows('WorkflowId="replayer-workflow-id"')
histories = workflows.map_histories()
replayer = Replayer(workflows=[JustActivity, JustTimer, TimerThenActivity])
results = await replayer.replay_workflows(histories, raise_on_replay_failure=False)
print(results)
if __name__ == "__main__":
asyncio.run(main())