Share via


DurableEntityContext Class

Context of the durable entity context.

Describes the API used to specify durable entity user code.

Context of the durable entity context.

Describes the API used to specify durable entity user code.

Constructor

DurableEntityContext(name: str, key: str, exists: bool, state: Any)

Parameters

Name Description
name
Required
str

The name of the Durable Entity

key
Required
str

The key of the Durable Entity

exists
Required

Flag to determine if the entity exists

state
Required
Any

The internal state of the Durable Entity

Methods

destruct_on_exit

Delete this entity after the operation completes.

from_json

Instantiate a DurableEntityContext from a JSON-formatted string.

get_input

Get the input for this operation.

get_state

Get the current state of this entity.

set_result

Set the result (return value) of the entity.

Paramaters

result: Any The result / return value for the entity

set_state

Set the state of the entity.

Parameter

state: Any The new state of the entity

destruct_on_exit

Delete this entity after the operation completes.

destruct_on_exit() -> None

from_json

Instantiate a DurableEntityContext from a JSON-formatted string.

from_json(json_str: str) -> Tuple[DurableEntityContext, List[Dict[str, Any]]]

Parameters

Name Description
json_string
Required
str

A JSON-formatted string, returned by the durable-extension, which represents the entity context

json_str
Required

Returns

Type Description

The DurableEntityContext originated from the input string

get_input

Get the input for this operation.

get_input() -> Any

Returns

Type Description
Any

The input for the current operation

get_state

Get the current state of this entity.

get_state(initializer: Callable[[], Any] | None = None) -> Any

Parameters

Name Description
initializer
<xref:Optional>[<xref:Callable>[[], <xref:Any>]]

A 0-argument function to provide an initial state. Defaults to None.

Default value: None

Returns

Type Description
Any

The current state of the entity

set_result

Set the result (return value) of the entity.

Paramaters

result: Any The result / return value for the entity

set_result(result: Any) -> None

Parameters

Name Description
result
Required

set_state

Set the state of the entity.

Parameter

state: Any The new state of the entity

set_state(state: Any) -> None

Parameters

Name Description
state
Required

Attributes

entity_key

Get the Entity key.

Returns

Type Description
str

The entity key

entity_name

Get the name of the Entity.

Returns

Type Description
str

The name of the entity

is_newly_constructed

Determine if the Entity was newly constructed.

Returns

Type Description

True if the Entity was newly constructed. False otherwise.

operation_name

Get the current operation name.

Returns

Type Description

The current operation name