-
Notifications
You must be signed in to change notification settings - Fork 139
feat(actor): Add reminder failure policy #953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
1Ninad
wants to merge
5
commits into
dapr:main
Choose a base branch
from
1Ninad:feat-reminder-failure-policy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+372
−15
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3eb01f3
feat(actor): add reminder failure policy
1Ninad 3ccaa9e
Potential fix for pull request finding
1Ninad 63edfc9
fix: copilot feedback
1Ninad 7879792
Merge branch 'main' into feat-reminder-failure-policy
acroca 011799f
fix: copilot feedback
1Ninad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| """ | ||
| Copyright 2026 The Dapr Authors | ||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| """ | ||
|
|
||
| # Backward-compatible shim — import from the public module instead. | ||
| from dapr.actor.runtime.failure_policy import ActorReminderFailurePolicy | ||
|
|
||
| __all__ = ['ActorReminderFailurePolicy'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| """ | ||
| Copyright 2026 The Dapr Authors | ||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| """ | ||
|
|
||
| from datetime import timedelta | ||
| from typing import Any, Dict, Optional | ||
|
|
||
|
|
||
| class ActorReminderFailurePolicy: | ||
| """Defines what happens when an actor reminder fails to trigger. | ||
|
|
||
| Use :meth:`drop_policy` to discard failed ticks without retrying, or | ||
| :meth:`constant_policy` to retry at a fixed interval. | ||
|
|
||
| Attributes: | ||
| drop: whether this is a drop (no-retry) policy. | ||
| interval: the retry interval for a constant policy. | ||
| max_retries: the maximum number of retries for a constant policy. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| drop: bool = False, | ||
| interval: Optional[timedelta] = None, | ||
| max_retries: Optional[int] = None, | ||
| ): | ||
| """Creates a new :class:`ActorReminderFailurePolicy` instance. | ||
|
|
||
| Args: | ||
| drop (bool): if True, creates a drop policy that discards the reminder | ||
| tick on failure without retrying. Cannot be combined with interval | ||
| or max_retries. | ||
| interval (datetime.timedelta): the retry interval for a constant policy. | ||
| max_retries (int): the maximum number of retries for a constant policy. | ||
| If not set, retries indefinitely. | ||
|
|
||
| Raises: | ||
| ValueError: if drop is combined with interval or max_retries, or if | ||
| neither drop=True nor at least one of interval/max_retries is provided. | ||
| """ | ||
| if drop and (interval is not None or max_retries is not None): | ||
| raise ValueError('drop policy cannot be combined with interval or max_retries') | ||
| if not drop and interval is None and max_retries is None: | ||
| raise ValueError('specify either drop=True or at least one of interval or max_retries') | ||
| self._drop = drop | ||
| self._interval = interval | ||
| self._max_retries = max_retries | ||
|
|
||
| @classmethod | ||
| def drop_policy(cls) -> 'ActorReminderFailurePolicy': | ||
| """Returns a policy that drops the reminder tick on failure (no retry).""" | ||
| return cls(drop=True) | ||
|
|
||
| @classmethod | ||
| def constant_policy( | ||
| cls, | ||
| interval: Optional[timedelta] = None, | ||
| max_retries: Optional[int] = None, | ||
| ) -> 'ActorReminderFailurePolicy': | ||
| """Returns a policy that retries at a constant interval on failure. | ||
|
|
||
| Args: | ||
| interval (datetime.timedelta): the time between retry attempts. | ||
| max_retries (int): the maximum number of retry attempts. If not set, | ||
| retries indefinitely. | ||
| """ | ||
| return cls(interval=interval, max_retries=max_retries) | ||
|
|
||
| @property | ||
| def drop(self) -> bool: | ||
| """Returns True if this is a drop policy.""" | ||
| return self._drop | ||
|
|
||
| @property | ||
| def interval(self) -> Optional[timedelta]: | ||
| """Returns the retry interval for a constant policy.""" | ||
| return self._interval | ||
|
|
||
| @property | ||
| def max_retries(self) -> Optional[int]: | ||
| """Returns the maximum retries for a constant policy.""" | ||
| return self._max_retries | ||
|
|
||
| def as_dict(self) -> Dict[str, Any]: | ||
| """Gets :class:`ActorReminderFailurePolicy` as a dict object.""" | ||
| if self._drop: | ||
| return {'drop': {}} | ||
| d: Dict[str, Any] = {} | ||
| if self._interval is not None: | ||
| d['interval'] = self._interval | ||
| if self._max_retries is not None: | ||
| d['maxRetries'] = self._max_retries | ||
| return {'constant': d} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.