Ejemplo n.º 1
0
 def get_version(change_id: str, min_supported: int, max_supported: int):
     from cadence.decision_loop import ITask
     from cadence.decision_loop import DecisionContext
     task: ITask = ITask.current()
     decision_context: DecisionContext = task.decider.decision_context
     return decision_context.get_version(change_id, min_supported,
                                         max_supported)
Ejemplo n.º 2
0
 def new_activity_stub(activities_cls):
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     assert task
     cls = activities_cls()
     cls._decision_context = task.decider.decision_context
     return cls
Ejemplo n.º 3
0
 def new_activity_stub(activities_cls, retry_parameters: RetryParameters = None):
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     assert task
     cls = activities_cls()
     cls._decision_context = task.decider.decision_context
     cls._retry_parameters = retry_parameters
     return cls
Ejemplo n.º 4
0
 def get_logger(name):
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     return task.decider.decision_context.get_logger(name)
Ejemplo n.º 5
0
 def new_random() -> random.Random:
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     return task.decider.decision_context.new_random()
Ejemplo n.º 6
0
 def random_uuid() -> uuid.UUID:
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     return task.decider.decision_context.random_uuid()
Ejemplo n.º 7
0
 def now() -> datetime.datetime:
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     now_in_ms = task.decider.decision_context.current_time_millis()
     return datetime.datetime.fromtimestamp(now_in_ms / 1000)
Ejemplo n.º 8
0
 def current_time_millis() -> int:
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     return task.decider.decision_context.current_time_millis()
Ejemplo n.º 9
0
 async def sleep(seconds: int):
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     await task.decider.decision_context.schedule_timer(seconds)
Ejemplo n.º 10
0
 async def await_till(c: Callable, timeout_seconds: int = 0) -> bool:
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     assert task
     return await task.await_till(c, timeout_seconds)
Ejemplo n.º 11
0
 def interceptor(*args, **kwargs):
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     if not task.decider.decision_context.is_replaying():
         return fn(*args, **kwargs)
Ejemplo n.º 12
0
 def get_execution_id():
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     return task.decider.execution_id
Ejemplo n.º 13
0
 def get_workflow_id():
     from cadence.decision_loop import ITask
     task: ITask = ITask.current()
     return task.decider.workflow_id