Skip to content

[stage] Add Actor State TTL support - #1920

Closed
adityav1709 wants to merge 5 commits into
dapr:masterfrom
adityav1709:actor-state-ttl-1338-dco
Closed

adityav1709 wants to merge 5 commits into
dapr:masterfrom
adityav1709:actor-state-ttl-1338-dco

Conversation

@adityav1709

Copy link
Copy Markdown

Fixes #849.

This builds on #1338, rebased onto current master.

What it does

  • Adds an overload to save actor state with a TTL, while add(String, T) and set(String, T) stay as they are. No @deprecated on set while the feature is in preview.
  • DaprClientImpl sends ttlInSeconds on save and reads ttlExpireTime on read, so the ActorStateManager cache knows when a key expires.
  • Removes unused imports in DaprStateAsyncProvider.
  • Preview feature flags are now supported in the testcontainers Configuration, so the test can enable ActorStateTTL.

Tests

  • New TTL integration test on MySQL with the ActorStateTTL preview flag enabled. Other actor tests stay on Redis, because Redis does not return ttlExpireTime.
  • Unit tests cover ttlInSeconds and ttlExpireTime handling in DaprClientImpl.

Caveat: the cache only knows a key expired when the store returns ttlExpireTime. Redis does not, so the MySQL test is the one that proves the expiry path.

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Aditya Vijay <215045064+adityav1709@users.noreply.github.com>
Keep add(String, T) as it is and add an overload taking the
expiration instead of changing the signature. No @deprecated on
set(String, T) while ActorStateTTL is a preview feature; the TTL
variant documents the preview flag and that the cache only knows
the expiration when the store returns ttlExpireTime. Remove the
unused imports in DaprStateAsyncProvider. Add unit tests for the
ttlInSeconds and ttlExpireTime handling in DaprClientImpl.

Signed-off-by: Aditya Vijay <215045064+adityav1709@users.noreply.github.com>
The testcontainers Configuration model had no way to enable a Dapr
preview feature. Add a Feature value type (name + enabled), a
features list on Configuration, and spec.features output in the
YAML converter, so integration tests can turn on preview features
such as ActorStateTTL.

Signed-off-by: Aditya Vijay <215045064+adityav1709@users.noreply.github.com>
Cover the new actor state TTL support end to end: a new
ActorStateTtlIT writes a value with a two second TTL, sees it served
while the TTL holds, sees it gone from the actor cache once the TTL
elapses, and after an app restart sees it gone from the store too.

The test runs against MySQL instead of the Redis used by the other
actor tests, because Redis does not return the ttlExpireTime of a
state key. The ActorStateTTL preview feature is enabled through the
new Configuration features support. The shared test infra gains a
reused MySQL container and a mysqlStateStore helper, and the test
actor gains a writeMessageWithTtl method.

Signed-off-by: Aditya Vijay <215045064+adityav1709@users.noreply.github.com>
@adityav1709
adityav1709 requested review from a team as code owners November 22, 2026 17:15
@cicoyle cicoyle self-assigned this Nov 23, 2026
Signed-off-by: Aditya <adityav170920@gmail.com>
@adityav1709

Copy link
Copy Markdown
Author

Superseded by #1921, which has the same change with the DCO sign-off fixed on all commits.

@cicoyle cicoyle removed their assignment Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEATURE PREVIEW: Add Actor State TTL support

2 participants