Skip to content

Commit 640d4e6

Browse files
FullyTypedAstraea Quinn S
authored andcommitted
[feat][DurableContext] Use a blake2 to generate step_id
Feature: - Replaces existing mechanism to produce durable operation ids with Test Changes: - Instead of testing manually the steps, we a/ produce a generator so that we can rely on next(_) to get the sequence - We verify invariance over behaviour: - deterministic execution - identical generation for every new context - parent step id participates in the generation Signed-off-by: Astraea Sinclair <[email protected]>
1 parent b5496ca commit 640d4e6

File tree

4 files changed

+227
-38
lines changed

4 files changed

+227
-38
lines changed

src/aws_durable_execution_sdk_python/context.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import hashlib
34
import logging
45
from typing import TYPE_CHECKING, Any, Concatenate, Generic, ParamSpec, TypeVar
56

@@ -220,9 +221,10 @@ def _create_step_id(self) -> str:
220221
the id generated by this method. It is subject to change without notice.
221222
"""
222223
new_counter: int = self._step_counter.increment()
223-
return (
224+
step_id = (
224225
f"{self._parent_id}-{new_counter}" if self._parent_id else str(new_counter)
225226
)
227+
return hashlib.blake2b(step_id.encode()).hexdigest()[:64]
226228

227229
# region Operations
228230

0 commit comments

Comments
 (0)