Skip to content

Commit 0b928f8

Browse files
Fixes double code
Signed-off-by: Elena Kolevska <[email protected]>
1 parent cb05385 commit 0b928f8

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

dapr/clients/grpc/_request.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ def operation_type(self) -> TransactionOperationType:
331331
@property
332332
def metadata(self) -> Dict[str, str]:
333333
"""Gets metadata."""
334-
return self._metadata
334+
return {} if self._metadata is None else self._metadata
335+
335336

336337
class EncryptRequestIterator(DaprRequest):
337338
"""An iterator for cryptography encrypt API requests.

dapr/clients/grpc/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ def execute_state_transaction(
939939
key=o.key,
940940
value=to_bytes(o.data) if o.data is not None else to_bytes(''),
941941
etag=common_v1.Etag(value=o.etag) if o.etag is not None else None,
942-
metadata=o.metadata if o.metadata is not None else dict(),
942+
metadata=o.metadata,
943943
),
944944
)
945945
for o in operations

examples/state_store/state_store.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,20 @@
9090

9191
# Outbox pattern
9292
# pass in the ("outbox.projection", "true") metadata to the transaction to enable the outbox pattern.
93-
d.execute_state_transaction(store_name=storeName, operations=[
94-
TransactionalStateOperation(key="key1", data="val1",
95-
metadata={"outbox.projection": "false"}),
96-
TransactionalStateOperation(key="key1", data="val2",
97-
metadata={"outbox.projection": "true"}), ], )
98-
print("Transaction with outbox pattern executed successfully!")
99-
100-
val = d.get_state(store_name=storeName, key="key1").data
93+
d.execute_state_transaction(
94+
store_name=storeName,
95+
operations=[
96+
TransactionalStateOperation(
97+
key='key1', data='val1', metadata={'outbox.projection': 'false'}
98+
),
99+
TransactionalStateOperation(
100+
key='key1', data='val2', metadata={'outbox.projection': 'true'}
101+
),
102+
],
103+
)
104+
print('Transaction with outbox pattern executed successfully!')
105+
106+
val = d.get_state(store_name=storeName, key='key1').data
101107
print(f'Got value after outbox pattern: {val}')
102108

103109
# Transaction delete

0 commit comments

Comments
 (0)