Skip to content

feat: Enhance actor timer and reminder functionality with repetitions and TTL options - #1825

Merged
dapr-bot merged 1 commit into
dapr:masterfrom
matheusandre1:feat/actor-timer-reminder-ttl-repetitions
Oct 8, 2026
Merged

dapr-bot merged 1 commit into
dapr:masterfrom
matheusandre1:feat/actor-timer-reminder-ttl-repetitions

Conversation

@matheusandre1

Copy link
Copy Markdown
Contributor

Description

Adds support for TTL, repetitions (ISO 8601 Rn/ periods) and optional dueTime/period to actor timers and reminders, aligning the Java SDK with the Dapr runtime and with the API agreed in #681 (keep the existing signatures, add a builder-based API).

New API

Two new builder-based option classes in io.dapr.actors.runtime:

  • ActorReminderOptions
  • ActorTimerOptions

Both expose dueTime, period, repetitions and ttl, all optional. AbstractActor gets new overloads that accept them:

registerReminder("myreminder", state, ActorReminderOptions.builder()
    .setPeriod(Duration.ofSeconds(10))
    .setRepetitions(5)
    .setTtl(Duration.ofMinutes(1))
    .build());
registerActorTimer("mytimer", "callback", state, ActorTimerOptions.builder()
    .setDueTime(Duration.ofSeconds(1))
    .setPeriod(Duration.ofSeconds(2))
    .setRepetitions(3)
    .build());

The existing registerReminder(String, T, Duration, Duration) and registerActorTimer(String, String, T, Duration, Duration) methods keep working unchanged and now delegate to the new overloads.

Behavior

  • dueTime not set → sent as empty, so the runtime fires immediately.
  • period not set → the timer/reminder fires only once.
  • repetitions set → period is sent in ISO 8601 format (R5/PT10S). It requires a positive period in whole seconds, because the runtime's ISO 8601 parser only accepts integer seconds.
  • ttl set → sent in the new ttl field of RegisterActorReminderRequest / RegisterActorTimerRequest, which already exists in actors.proto.
  • Validation: repetitions > 0, and ttl must not be negative.

Reminder/timer callbacks

The runtime echoes the registered period string back in the reminder/timer callback payload (ReminderPeriod.String() returns the raw value). Previously an ISO 8601 value such as R5/PT10S was silently parsed as Duration.ZERO. Now:

  • DurationUtils.convertDurationFromDaprFormat also accepts ISO 8601 durations, with or without the Rn/ prefix.
  • ActorObjectSerializer reads/writes ttl and the repetitions, and omits unset fields.

Other changes

  • DurationUtils.convertDurationToIso8601Format(Duration) added.
  • New package-private ActorScheduleUtils that centralizes the validation and formatting shared by timers and reminders.

Issue reference

Closes: #681
Closes: #652
Closes: #569

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@matheusandre1
matheusandre1 force-pushed the feat/actor-timer-reminder-ttl-repetitions branch from 41c1893 to 09e06f2 Compare October 7, 2026 02:57
@matheusandre1
matheusandre1 marked this pull request as ready for review October 7, 2026 03:02
@matheusandre1
matheusandre1 requested review from a team as code owners October 7, 2026 03:02

@javier-aliaga javier-aliaga left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matheusandre1 thanks! Can you check my comments?

… and TTL options

Signed-off-by: Matheus André <matheusandr2@gmail.com>
@matheusandre1
matheusandre1 force-pushed the feat/actor-timer-reminder-ttl-repetitions branch from 09e06f2 to 91087a6 Compare October 7, 2026 14:32
@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.66%. Comparing base (8f59769) to head (91087a6).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1825      +/-   ##
============================================
+ Coverage     79.26%   79.66%   +0.39%     
- Complexity     2615     2683      +68     
============================================
  Files           264      267       +3     
  Lines          7785     7923     +138     
  Branches        820      839      +19     
============================================
+ Hits           6171     6312     +141     
+ Misses         1254     1252       -2     
+ Partials        360      359       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dapr-bot
dapr-bot merged commit 92d4695 into dapr:master Oct 8, 2026
24 of 25 checks passed
@matheusandre1
matheusandre1 deleted the feat/actor-timer-reminder-ttl-repetitions branch October 8, 2026 10:06
javier-aliaga pushed a commit that referenced this pull request Oct 8, 2026
… and TTL options (#1825) (#1829)

(cherry picked from commit 92d4695)

Signed-off-by: Matheus André <matheusandr2@gmail.com>
Co-authored-by: Matheus André <92062874+matheusandre1@users.noreply.github.com>
@nelson-parente nelson-parente added this to the v1.19 milestone Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

4 participants