distro-tools/common/temporal.py

30 lines
628 B
Python
Raw Normal View History

2023-02-01 21:37:16 +00:00
"""
Temporal helper methods
"""
from temporalio.client import Client
from common.info import Info
class Temporal(object):
"""
Temporal helper singleton class
"""
client = None
def __init__(self, initialize=False):
if Temporal.client is None and not initialize:
raise Exception("Temporal client not initialized")
self.client = Temporal.client
async def connect(self):
info = Info()
Temporal.client = await Client.connect(
info.temporal_host(),
namespace=info.temporal_namespace(),
)
self.client = Temporal.client