Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/aws_durable_execution_sdk_python/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from collections.abc import Callable, Sequence

from aws_durable_execution_sdk_python.state import CheckpointedResult
from aws_durable_execution_sdk_python.types import LambdaContext

P = TypeVar("P") # Payload type
R = TypeVar("R") # Result type
Expand Down Expand Up @@ -149,7 +150,7 @@ class DurableContext(DurableContextProtocol):
def __init__(
self,
state: ExecutionState,
lambda_context: Any | None = None,
lambda_context: LambdaContext | None = None,
parent_id: str | None = None,
logger: Logger | None = None,
) -> None:
Expand All @@ -171,7 +172,7 @@ def __init__(
@staticmethod
def from_lambda_context(
state: ExecutionState,
lambda_context: Any,
lambda_context: LambdaContext,
):
return DurableContext(
state=state,
Expand Down
6 changes: 4 additions & 2 deletions src/aws_durable_execution_sdk_python/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
if TYPE_CHECKING:
from collections.abc import Callable, MutableMapping

from aws_durable_execution_sdk_python.types import LambdaContext


logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -187,10 +189,10 @@ def create_succeeded(cls, result: str) -> DurableExecutionInvocationOutput:

def durable_handler(
func: Callable[[Any, DurableContext], Any],
) -> Callable[[Any, Any], Any]:
) -> Callable[[Any, LambdaContext], Any]:
logger.debug("Starting durable execution handler...")

def wrapper(event: Any, context: Any) -> MutableMapping[str, Any]:
def wrapper(event: Any, context: LambdaContext) -> MutableMapping[str, Any]:
invocation_input: DurableExecutionInvocationInput
service_client: DurableServiceClient

Expand Down
16 changes: 16 additions & 0 deletions src/aws_durable_execution_sdk_python/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,19 @@ def create_callback(
) -> Callback:
"""Create a callback."""
... # pragma: no cover


class LambdaContext(Protocol): # pragma: no cover
aws_request_id: str
log_group_name: str | None = None
log_stream_name: str | None = None
function_name: str | None = None
memory_limit_in_mb: str | None = None
function_version: str | None = None
invoked_function_arn: str | None = None
tenant_id: str | None = None
client_context: Any | None = None
identity: Any | None = None

def get_remaining_time_in_millis(self) -> int: ...
def log(self, msg) -> None: ...