@@ -329,7 +329,9 @@ def invoke_method(
329
329
),
330
330
)
331
331
332
- response , call = self ._stub .InvokeService .with_call (req , metadata = metadata , timeout = timeout )
332
+ response , call = self .retry_policy .run_rpc (
333
+ self ._stub .InvokeService .with_call , req , metadata = metadata , timeout = timeout
334
+ )
333
335
334
336
resp_data = InvokeMethodResponse (response .data , response .content_type )
335
337
resp_data .headers = call .initial_metadata () # type: ignore
@@ -390,7 +392,9 @@ def invoke_binding(
390
392
operation = operation ,
391
393
)
392
394
393
- response , call = self ._stub .InvokeBinding .with_call (req , metadata = metadata )
395
+ response , call = self .retry_policy .run_rpc (
396
+ self ._stub .InvokeBinding .with_call , req , metadata = metadata
397
+ )
394
398
return BindingResponse (response .data , dict (response .metadata ), call .initial_metadata ())
395
399
396
400
def publish_event (
@@ -462,7 +466,9 @@ def publish_event(
462
466
463
467
try :
464
468
# response is google.protobuf.Empty
465
- _ , call = self ._stub .PublishEvent .with_call (req , metadata = metadata )
469
+ _ , call = self .retry_policy .run_rpc (
470
+ self ._stub .PublishEvent .with_call , req , metadata = metadata
471
+ )
466
472
except RpcError as err :
467
473
raise DaprGrpcError (err ) from err
468
474
@@ -509,7 +515,9 @@ def get_state(
509
515
raise ValueError ('State store name cannot be empty' )
510
516
req = api_v1 .GetStateRequest (store_name = store_name , key = key , metadata = state_metadata )
511
517
try :
512
- response , call = self ._stub .GetState .with_call (req , metadata = metadata )
518
+ response , call = self .retry_policy .run_rpc (
519
+ self ._stub .GetState .with_call , req , metadata = metadata
520
+ )
513
521
return StateResponse (
514
522
data = response .data , etag = response .etag , headers = call .initial_metadata ()
515
523
)
@@ -562,7 +570,9 @@ def get_bulk_state(
562
570
)
563
571
564
572
try :
565
- response , call = self ._stub .GetBulkState .with_call (req , metadata = metadata )
573
+ response , call = self .retry_policy .run_rpc (
574
+ self ._stub .GetBulkState .with_call , req , metadata = metadata
575
+ )
566
576
except RpcError as err :
567
577
raise DaprGrpcError (err ) from err
568
578
@@ -624,7 +634,7 @@ def query_state(
624
634
req = api_v1 .QueryStateRequest (store_name = store_name , query = query , metadata = states_metadata )
625
635
626
636
try :
627
- response , call = self ._stub .QueryStateAlpha1 .with_call ( req )
637
+ response , call = self .retry_policy . run_rpc ( self . _stub .QueryStateAlpha1 .with_call , req )
628
638
except RpcError as err :
629
639
raise DaprGrpcError (err ) from err
630
640
@@ -779,7 +789,9 @@ def save_bulk_state(
779
789
req = api_v1 .SaveStateRequest (store_name = store_name , states = req_states )
780
790
781
791
try :
782
- _ , call = self ._stub .SaveState .with_call (req , metadata = metadata )
792
+ _ , call = self .retry_policy .run_rpc (
793
+ self ._stub .SaveState .with_call , req , metadata = metadata
794
+ )
783
795
return DaprResponse (headers = call .initial_metadata ())
784
796
except RpcError as err :
785
797
raise DaprGrpcError (err ) from err
@@ -848,7 +860,9 @@ def execute_state_transaction(
848
860
)
849
861
850
862
try :
851
- _ , call = self ._stub .ExecuteStateTransaction .with_call (req , metadata = metadata )
863
+ _ , call = self .retry_policy .run_rpc (
864
+ self ._stub .ExecuteStateTransaction .with_call , req , metadata = metadata
865
+ )
852
866
return DaprResponse (headers = call .initial_metadata ())
853
867
except RpcError as err :
854
868
raise DaprGrpcError (err ) from err
@@ -916,7 +930,9 @@ def delete_state(
916
930
)
917
931
918
932
try :
919
- _ , call = self ._stub .DeleteState .with_call (req , metadata = metadata )
933
+ _ , call = self .retry_policy .run_rpc (
934
+ self ._stub .DeleteState .with_call , req , metadata = metadata
935
+ )
920
936
return DaprResponse (headers = call .initial_metadata ())
921
937
except RpcError as err :
922
938
raise DaprGrpcError (err ) from err
@@ -968,7 +984,9 @@ def get_secret(
968
984
969
985
req = api_v1 .GetSecretRequest (store_name = store_name , key = key , metadata = secret_metadata )
970
986
971
- response , call = self ._stub .GetSecret .with_call (req , metadata = metadata )
987
+ response , call = self .retry_policy .run_rpc (
988
+ self ._stub .GetSecret .with_call , req , metadata = metadata
989
+ )
972
990
973
991
return GetSecretResponse (secret = response .data , headers = call .initial_metadata ())
974
992
@@ -1015,7 +1033,9 @@ def get_bulk_secret(
1015
1033
1016
1034
req = api_v1 .GetBulkSecretRequest (store_name = store_name , metadata = secret_metadata )
1017
1035
1018
- response , call = self ._stub .GetBulkSecret .with_call (req , metadata = metadata )
1036
+ response , call = self .retry_policy .run_rpc (
1037
+ self ._stub .GetBulkSecret .with_call , req , metadata = metadata
1038
+ )
1019
1039
1020
1040
secrets_map = {}
1021
1041
for key in response .data .keys ():
@@ -1055,7 +1075,7 @@ def get_configuration(
1055
1075
req = api_v1 .GetConfigurationRequest (
1056
1076
store_name = store_name , keys = keys , metadata = config_metadata
1057
1077
)
1058
- response , call = self ._stub .GetConfiguration .with_call ( req )
1078
+ response , call = self .retry_policy . run_rpc ( self . _stub .GetConfiguration .with_call , req )
1059
1079
return ConfigurationResponse (items = response .items , headers = call .initial_metadata ())
1060
1080
1061
1081
def subscribe_configuration (
@@ -1163,7 +1183,7 @@ def try_lock(
1163
1183
lock_owner = lock_owner ,
1164
1184
expiry_in_seconds = expiry_in_seconds ,
1165
1185
)
1166
- response , call = self ._stub .TryLockAlpha1 .with_call ( req )
1186
+ response , call = self .retry_policy . run_rpc ( self . _stub .TryLockAlpha1 .with_call , req )
1167
1187
return TryLockResponse (
1168
1188
success = response .success ,
1169
1189
client = self ,
@@ -1201,7 +1221,7 @@ def unlock(self, store_name: str, resource_id: str, lock_owner: str) -> UnlockRe
1201
1221
req = api_v1 .UnlockRequest (
1202
1222
store_name = store_name , resource_id = resource_id , lock_owner = lock_owner
1203
1223
)
1204
- response , call = self ._stub .UnlockAlpha1 .with_call ( req )
1224
+ response , call = self .retry_policy . run_rpc ( self . _stub .UnlockAlpha1 .with_call , req )
1205
1225
1206
1226
return UnlockResponse (
1207
1227
status = UnlockResponseStatus (response .status ), headers = call .initial_metadata ()
@@ -1267,7 +1287,7 @@ def start_workflow(
1267
1287
)
1268
1288
1269
1289
try :
1270
- response = self ._stub .StartWorkflowBeta1 ( req )
1290
+ response , call = self .retry_policy . run_rpc ( self . _stub .StartWorkflowBeta1 . with_call , req )
1271
1291
return StartWorkflowResponse (instance_id = response .instance_id )
1272
1292
except RpcError as err :
1273
1293
raise DaprInternalError (err .details ())
@@ -1297,7 +1317,7 @@ def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflow
1297
1317
)
1298
1318
1299
1319
try :
1300
- resp = self ._stub .GetWorkflowBeta1 ( req )
1320
+ resp = self .retry_policy . run_rpc ( self . _stub .GetWorkflowBeta1 , req )
1301
1321
if resp .created_at is None :
1302
1322
resp .created_at = datetime .now ()
1303
1323
if resp .last_updated_at is None :
@@ -1339,7 +1359,7 @@ def terminate_workflow(self, instance_id: str, workflow_component: str) -> DaprR
1339
1359
)
1340
1360
1341
1361
try :
1342
- _ , call = self ._stub .TerminateWorkflowBeta1 .with_call ( req )
1362
+ _ , call = self .retry_policy . run_rpc ( self . _stub .TerminateWorkflowBeta1 .with_call , req )
1343
1363
return DaprResponse (headers = call .initial_metadata ())
1344
1364
except RpcError as err :
1345
1365
raise DaprInternalError (err .details ())
@@ -1410,7 +1430,7 @@ def raise_workflow_event(
1410
1430
)
1411
1431
1412
1432
try :
1413
- _ , call = self ._stub .RaiseEventWorkflowBeta1 .with_call ( req )
1433
+ _ , call = self .retry_policy . run_rpc ( self . _stub .RaiseEventWorkflowBeta1 .with_call , req )
1414
1434
return DaprResponse (headers = call .initial_metadata ())
1415
1435
except RpcError as err :
1416
1436
raise DaprInternalError (err .details ())
@@ -1441,7 +1461,7 @@ def pause_workflow(self, instance_id: str, workflow_component: str) -> DaprRespo
1441
1461
)
1442
1462
1443
1463
try :
1444
- _ , call = self ._stub .PauseWorkflowBeta1 .with_call ( req )
1464
+ _ , call = self .retry_policy . run_rpc ( self . _stub .PauseWorkflowBeta1 .with_call , req )
1445
1465
1446
1466
return DaprResponse (headers = call .initial_metadata ())
1447
1467
except RpcError as err :
@@ -1472,7 +1492,7 @@ def resume_workflow(self, instance_id: str, workflow_component: str) -> DaprResp
1472
1492
)
1473
1493
1474
1494
try :
1475
- _ , call = self ._stub .ResumeWorkflowBeta1 .with_call ( req )
1495
+ _ , call = self .retry_policy . run_rpc ( self . _stub .ResumeWorkflowBeta1 .with_call , req )
1476
1496
1477
1497
return DaprResponse (headers = call .initial_metadata ())
1478
1498
except RpcError as err :
@@ -1503,7 +1523,7 @@ def purge_workflow(self, instance_id: str, workflow_component: str) -> DaprRespo
1503
1523
)
1504
1524
1505
1525
try :
1506
- _ , call = self ._stub .PurgeWorkflowBeta1 .with_call ( req )
1526
+ response , call = self .retry_policy . run_rpc ( self . _stub .PurgeWorkflowBeta1 .with_call , req )
1507
1527
1508
1528
return DaprResponse (headers = call .initial_metadata ())
1509
1529
@@ -1559,7 +1579,7 @@ def get_metadata(self) -> GetMetadataResponse:
1559
1579
capabilities.
1560
1580
"""
1561
1581
try :
1562
- _resp , call = self ._stub .GetMetadata .with_call ( GrpcEmpty ())
1582
+ _resp , call = self .retry_policy . run_rpc ( self . _stub .GetMetadata .with_call , GrpcEmpty ())
1563
1583
except RpcError as err :
1564
1584
raise DaprGrpcError (err ) from err
1565
1585
@@ -1605,7 +1625,7 @@ def set_metadata(self, attributeName: str, attributeValue: str) -> DaprResponse:
1605
1625
validateNotNone (attributeValue = attributeValue )
1606
1626
# Actual invocation
1607
1627
req = api_v1 .SetMetadataRequest (key = attributeName , value = attributeValue )
1608
- _ , call = self ._stub .SetMetadata .with_call ( req )
1628
+ _ , call = self .retry_policy . run_rpc ( self . _stub .SetMetadata .with_call , req )
1609
1629
1610
1630
return DaprResponse (call .initial_metadata ())
1611
1631
@@ -1625,6 +1645,6 @@ def shutdown(self) -> DaprResponse:
1625
1645
:class:`DaprResponse` gRPC metadata returned from callee
1626
1646
"""
1627
1647
1628
- _ , call = self ._stub .Shutdown .with_call ( GrpcEmpty ())
1648
+ _ , call = self .retry_policy . run_rpc ( self . _stub .Shutdown .with_call , GrpcEmpty ())
1629
1649
1630
1650
return DaprResponse (call .initial_metadata ())
0 commit comments