77
88from google .protobuf import timestamp_pb2 , wrappers_pb2
99
10+ from durabletask .entities .entity_instance_id import EntityInstanceId
1011import durabletask .internal .orchestrator_service_pb2 as pb
1112
1213# TODO: The new_xxx_event methods are only used by test code and should be moved elsewhere
@@ -195,26 +196,30 @@ def new_schedule_task_action(id: int, name: str, encoded_input: Optional[str],
195196 ))
196197
197198
198- def new_call_entity_action (id : int , name : str , encoded_input : Optional [str ]):
199+ def new_call_entity_action (id : int , parent_instance_id : str , entity_id : EntityInstanceId , operation : str , encoded_input : Optional [str ]):
199200 return pb .OrchestratorAction (id = id , sendEntityMessage = pb .SendEntityMessageAction (entityOperationCalled = pb .EntityOperationCalledEvent (
200- requestId = None ,
201- targetInstanceId = get_string_value (name ),
202- input = get_string_value (encoded_input )
201+ requestId = f"{ parent_instance_id } :{ id } " ,
202+ parentInstanceId = get_string_value (parent_instance_id ),
203+ targetInstanceId = get_string_value (str (entity_id )),
204+ input = get_string_value (encoded_input ),
205+ operation = operation
203206 )))
204207
205208
206- def new_signal_entity_action (id : int , name : str ):
209+ def new_signal_entity_action (id : int , entity_id : EntityInstanceId , operation : str , encoded_input : Optional [ str ] ):
207210 return pb .OrchestratorAction (id = id , sendEntityMessage = pb .SendEntityMessageAction (entityOperationSignaled = pb .EntityOperationSignaledEvent (
208- requestId = None ,
209- targetInstanceId = get_string_value (name )
211+ requestId = f"{ entity_id } :{ id } " ,
212+ targetInstanceId = get_string_value (str (entity_id )),
213+ operation = operation ,
214+ input = get_string_value (encoded_input )
210215 )))
211216
212217
213- def new_lock_entities_action (id : int , instance_id : str , critical_section_id : str , entity_ids : list [str ]):
218+ def new_lock_entities_action (id : int , parent_instance_id : str , critical_section_id : str , entity_ids : list [EntityInstanceId ]):
214219 return pb .OrchestratorAction (id = id , sendEntityMessage = pb .SendEntityMessageAction (entityLockRequested = pb .EntityLockRequestedEvent (
215- parentInstanceId = get_string_value (instance_id ),
220+ parentInstanceId = get_string_value (parent_instance_id ),
216221 criticalSectionId = critical_section_id ,
217- lockSet = entity_ids ,
222+ lockSet = [ str ( eid ) for eid in entity_ids ] ,
218223 position = 0
219224 )))
220225
@@ -236,7 +241,10 @@ def convert_to_entity_batch_request(req: pb.EntityRequest) -> tuple[pb.EntityBat
236241 operation = op .entityOperationCalled .operation ,
237242 input = op .entityOperationCalled .input ))
238243 operation_infos .append (pb .OperationInfo (requestId = op .entityOperationCalled .requestId ,
239- responseDestination = None ))
244+ responseDestination = pb .OrchestrationInstance (
245+ instanceId = op .entityOperationCalled .parentInstanceId .value ,
246+ executionId = op .entityOperationCalled .parentExecutionId
247+ )))
240248
241249 return batch_request , operation_infos
242250
0 commit comments